I have fiddled around with actions and filters and the like in a previous version of the Yoast plugin but now I can see that the PHP coding style has radically changed and I'm a bit lost. I'm more familiar with the old-school coding style.
I would like to grab the $schema array before it is output and be able to add stuff into it. I have seen that there are many specific classes in the Yoast plugin to manipulate the schema pieces but I can't make head or tail of it.
The $schema array is set up in the file \wordpress-seo\src\presenters\schema-presenter.php and returned from there, presumably to a higher function to be output, and it seems that this is probably the simplest place to add to the data.
So basically I would like to be able to hook into that function from any template piece and insert an array block before it's returned.
I have looked at the documentation at Yoast developer but I'm not really any the wiser!
Does anyone have any experience of doing this ?
Thanks :)
Schema_Generator
class. In there you'll find a bunch of filters that start withwpseo_schema_
that allow you to tweak things. There's even a filter calledwpseo_schema_graph_pieces
that will allow you to write a custom class to have your own schema added.