On Mon, 14 Jun 2010 17:48:52 +1000, Kim Parsell <[email protected]>
wrote:
I'm reworking my plugin, and need to use version_compare() in order to
serve up the correct code to users of either 2.9 or 3.0.
A sample of the code I'm using is:
if (version_compare($wp_version, '2.9', '=')) {
// do something here
} else if (version_compare($wp_version, '3.0', '=')) {
// do something else
}
In testing on my 3.0 dev install (single user mode), the code to be
served to the 3.0 users wasn't executing unless I changed the last part
from '=' to '<='.
I did a search through Trac and came upon a comment in a ticket
(http://core.trac.wordpress.org/ticket/13566#comment:12) where someone
else was having the same issue with the new importers.
My understanding of comment 13 from mdawaffe is that api.wordpress.org
should now be using everything before the first "-" when comparing
version strings, so the code I have above *should* work; however, it
isn't.
Is the change to the API only available for checking if a new version of
a plugin is available for download, or should it also work in a plugin
when doing version_compare(), such as what I'm trying to do?
It wont affect version_compare() since thats a PHP function, The code that
mdawaffe has changed is only affecting the result from the WordPress API
service.
The reason its affecting you, is because, obviously, 3.0-alpha is NOT 3.0
stable. doing 2.9 + = is also bad, as it wont affect 2.9.1, 2.9.2 etc.
Instead of doing version_compare() you should be checking to see if a
function exists, for example:
if ( function_exists('some_WordPress3_functionality') ) {
some_WordPress3_functionality(array(...));
} else {
// Fall back to doing it the 2.9 way
register_something();
add_rewrite_rule(..)
}
Cheers
Dion Hulse / dd32
Contact:
e: [email protected]
Web: http://dd32.id.au/
_______________________________________________
wp-testers mailing list
[email protected]
http://lists.automattic.com/mailman/listinfo/wp-testers