Edit Yoast SEO breadcrumbs output [closed]

They are all null. You haven’t set any of those variables. Here is your function.

function ss_breadcrumb_output() {
    return apply_filters( 'ss_breadcrumb_output', '<' . $wrapper . $id . $class . ' xmlns:v="http://rdf.data-vocabulary.org/#">' . $output . '</' . $wrapper . '>' );
}

All of the variables in that function are isolated to that function. Variables set outside that function don’t work. Since you haven’t set any variables (in the function), and they aren’t passed into the function, they are empty. It is a matter of scope. There are ways around that, like globalization, but that isn’t critical to this question so I’ll leave you to your own devices.

But to your problem… Look at the filter where it is applied in the plugin.

return apply_filters( 'wpseo_breadcrumb_output', '<' . $wrapper . $id . $class . ' xmlns:v="http://rdf.data-vocabulary.org/#">' . $output . '</' . $wrapper . '>' );

I think this may be where you are going wrong. This–'<' . $wrapper . $id . $class . ' xmlns:v="http://rdf.data-vocabulary.org/#">' . $output . '</' . $wrapper . '>'— is all one parameter. That . is string concatenation operator, meaning all of that is merged together into a string. When that is passed to the filter, there are no variables anymore. They are passed to the filter as a simple string.

Your function could catch and manipulate that string if you added parameter like:

function ss_breadcrumb_output($output) {
    var_dump($output); // you should see the string referred to above
    return apply_filters( 'ss_breadcrumb_output', '<' . $wrapper . $id . $class . ' xmlns:v="http://rdf.data-vocabulary.org/#">' . $output . '</' . $wrapper . '>' );
}

I am confused about this part: return apply_filters( 'ss_breadcrumb_output', '<' . $wrapper . $id . $class . ' xmlns:v="http://rdf.data-vocabulary.org/#">' . $output . '</' . $wrapper . '>' );

If you are trying to pass the breadcrumb output to another filter (of your creation, I assume) you’d want:

function ss_breadcrumb_output($output) {
    return apply_filters( 'ss_breadcrumb_output', $output );
}

But why? Anything you could do with that you could do with the wpseo_breadcrumb_output filter.

I think you just want:

function ss_breadcrumb_output($output) {
    $output = preg_replace('/([^>]+)>(.*)/','$1 aria-labelledby="breadcrumblabel" >$2',$output);
    return $output;
}

I should also not that regex on markup is pretty dicey. It is easy to get it wrong. Use with caution.