Using WPDirectory

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 register_rest_route() and register_rest_field().

Regex: (register_rest_route|register_rest_field)\(

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_request()wp_remote_get() and wp_remote_post(), combined with the root of the REST API URL /wp-json/wp/.

Regex: wp_remote_(request|get|post)\([\s|'|"]+(.+)\/wp-json\/wp\/


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.

Regex: register_block_type\(

Due to Gutenberg being primarily JavaScript it is also possible to develop without any PHP so we need to get more creative. It is possible to modify existing blocks with registerBlockStyle() and you can filter existing blocks with wp.hooks.addFilter().

Regex: wp.hooks.addFilter\(

Next up, how about we look at people removing blocks and/or preventing blocks from showing in the inserter.

Regex: (wp.blocks.unregisterBlockType\(|add_filter\([\s|'|"]+allowed_block_types)



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”.

Regex: WP_CLI::add_command\(

We can go one step further than this and look at all the ways plugins might integrate with WPCLI.

Regex: WP_CLI::(run_command|runcommand|launch_self|launch|get_config|read_value|confirm|error_multi_line|halt|error|warning|debug|success|log|line|colorize|add_command|add_hook|do_hook|add_wp_hook)


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:

Regex: aria-label=[\s|'|"]+\w*['|"]


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.