6

Wordpress 3.3 has deprecated the add_contextual_help() functions and it's filters, so in order to continue supporting 3.0 - 3.2.1 and also comply with 3.3, I have done the following:

global $wp_version;
if ($wp_version >= '3.3') {
    // New method
    add_action("load-$admin_page", 'CrayonSettingsWP::help_screen');
} else {
    // Depreciated method
    add_filter('contextual_help', 'CrayonSettingsWP::cont_help', 10, 3);
}

Is there a better approach?

1
  • 1
    If they have a codex entry, then you'll find their newer version or an alternate function. If not a codex entry, then simply check their source files (I use Netbeans on Windows, hence ctrl+click opens up the source file), you'll see an alternative method in the comments. Dec 11, 2011 at 7:28

2 Answers 2

6

I don't see anything wrong with your approach. But I'm going to take a different track: don't support older versions of WP.

The general impression I've gotten from the WP community is one of progress. By supporting the current version and forward you're helping to push the community towards using the most up to date version of WordPress.

Excerpted from WordPress Plugin Development (which is a great book!):

In the WordPress development community, backward compatibility may sometimes be even looked down upon. Users are expected to stay updated with the latest version of the software.

1
  • This is probably the best way to go, eventually, once 3.3 is released I'll probably let everyone know that they will have to update or use the older version of my plugin. Dec 11, 2011 at 22:59
3

Better for your version check is that you use the default functions of PHP for this requirement; see the example.

if ( version_compare( $GLOBALS['wp_version'], '3.3alpha', '>=' ) ) {

The version in PHP is more as the 3 strings, liek 3.3! that it is important to check for versions smaller the stable release.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.