Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
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. –  Rutwick Gangurde Dec 11 '11 at 7:28
add comment

2 Answers

up vote 5 down vote accepted

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.

share|improve this answer
    
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. –  Aram Kocharyan Dec 11 '11 at 22:59
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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