[wp-hackers] Checking plugin version
david at wordshell.net
Sat Sep 22 05:37:40 UTC 2012
> From: Martin Lazarov<martin at lazarov.bg>
> Subject: [wp-hackers] Checking plugin version
> is there a way to check plugin version? Fox example API or something
> else i can use from external system (not from wordpress).
Are you talking about...
a) Finding out about current WP directory plugin versions, by querying
b) Analysing an plugin file to see what version it is?
If b), then here's the regex I use in WordShell (it's a PCRE one, so
will work from PHP or anything else that uses PCRE):
head -45 $PLUG | grep -Pi "^([ \t\*])*Version:\s?" | head -1 | cut -d:
-f2- | sed 's/[^-0-9a-z\.]//gi
That's been developed through experience with testing on a few hundred
plugins so should be fairly reliable. I've not compared it with what
WordPress does internally (since it's worked reliably I've not needed to).
If a), then unfortunately the API is not well-documented, or easy to use
from outside PHP since it uses PHP's serialisation format. There's not
much you can do that I can see, except from reverse-engineering it by
reading the WordPress source code and/or using tcpdump to do packet
capture on a WordPress site.
I've been through that a bit, and WordShell has code to parse the API
and display the description, changelog or download URL, e.g.:
# wordshell akismet --downloadurl
It would be extremely easy for me to add in a switch to dump out the
latest version, e.g.
# wordshell akismet --latestversion
Drop me a line off-list if you're interested.
WordShell - WordPress fast from the CLI - www.wordshell.net
More information about the wp-hackers