Automatically determine minimum WordPress version required for a plugin?

When developing a plugin, is there a way to automatically determine the minimum version of WordPress that’s required to run it? I want to make sure that the Requires header is accurate, but manually checking every time I call a new core function is tedious and error-prone.

I’m thinking a script could figure it out easily enough:

  1. Scan all the files in a plugin.
  2. Parse out all the class instantiations and function calls based on the new foo( [...] ), foo::bar( [...] ), bar( [...] ), call_user_func( [...] ), etc syntax.
  3. Parse the WP source to determine when each of those classes/functions were added to WordPress, using the @since phpDoc tag.
  4. Generate a report listing each class/function and the version it was added, along with the earliest version of WordPress that includes all of the classes/functions.

I’ve looked around but couldn’t find anything like it, and don’t have the time to write it myself. Does anyone know of an existing solution?

4

I found a solution as an automated service over at http://wpseek.com/pluginfilecheck/

It’s does exactly, what was asked for including the generation of list of used functions and giving a suggestion for the Plugin-Header comments.

Leave a Comment