user3230561
user3230561

Reputation: 445

Using new Js and Css scripts in Wordpress

I am developing a wordpress plugin. I want the plugin to work on as many wordpress installations as possible.

In order to use various js and css scripts in the plugin. I want to make use of wp_register_script( $handle, $src, $deps, $ver, $in_footer );

My doubt is that, for eg. I have to use plupload functionality. On referring the documentation. http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Link_Scripts_Only_on_a_Plugin_Administration_Screen. I found that plupload script is included under default script.

How do I determine, that the wordpress installation has the script as default. This could be for any wordpress version. so that I do not have to manually add the scripts as a part of my plugin.

Thanks in Advance

Upvotes: 1

Views: 64

Answers (1)

brasofilo
brasofilo

Reputation: 26065

Browsing WordPress versions, I see that /wp-includes/js/plupload/ was introduced on version 3.3. You can creat a check for versions lower than 3.3 in your register_activation_hook (and display an admin_notice or abort the installation). Or enqueue an alternative script if the version is lower.

From here, a function to check the current version

if ( ! function_exists( 'is_version' ) ) {
    function is_version( $version = '3.3' ) {
        global $wp_version;
        if ( version_compare( $wp_version, $version, '>=' ) ) {
            return false;
        }
        return true;
    }
}

And a relevant WPSE post: Code to determine WP version check

Upvotes: 0

Related Questions