Using WPDirectory for regex searching all code in the WordPress Plugin and Theme Directories might sound cool, but what would you actually do that for? That is what we are going to find out!
I believe the most important use for WordPress to date has been checking the use of features/functions across Plugins and Themes when considering deprecation. This helps the core developers to understand the implications of their actions and allows them to proactively seek to mitigate them.
With how quick and easy WPDirectory makes searches though I am certain there are many more uses which could be valuable across the various WordPress teams, stretching much further than just core. So let us take a look at how several teams might use WPDirectory with practical examples…
The REST API allows external services to query WP sites for data and it can be added to and/or extended with code. Lets start with the basics and check how many plugins are registering endpoints and/or adding fields. We want to check for the use of two functions
Let’s say we want to check the reverse of this, how many plugins are using the REST API to query for content. We can do this by checking for the use of the three HTTP call functions
wp_remote_post(), combined with the root of the REST API URL
With it being the hot topic right now it would be rude to ignore it. The first thing the Gutenberg team might want to do is check for plugins creating blocks to track adoption.
registerBlockStyle() and you can filter existing blocks with
Next up, how about we look at people removing blocks and/or preventing blocks from showing in the inserter.
Alain Schlesser WPCLI maintainer was one of the first people to use the first prototype and said: “Oh, nice, this is currently the best way of finding plugins which come with builtin WPCLI commands”.
We can go one step further than this and look at all the ways plugins might integrate with WPCLI.
With a11y a hot topic at the moment it seemed worth exploring how WPDir might help the team. It should be possible to roughly measure accessilbity usage across Plugins and Themes. An example of this is by tracking the
accessibility-readytag in themes:
Regex: Tags\: (.+)accessibility-ready
We could also focus on how many Themes have matches to see how many use
aria-label at all with:
While relatively simple this should give you a good idea of the potential of WPDirectory. It can be used easily by many areas of the WordPress community and the potential is only limited by regex knowledge. I plan on making further, more advanced, posts in the future.