December 14, 2007
In the plugin I am working on at the moment I wanted to use Prototype 1.6, but WordPress, currently at least, includes version 1.5. So I set about find out how best to do this.
I could have just included it again, but that didn’t seem like the best idea to me. To have one script overriding an other is unlikely to be efficient.
This is what I came up with. First a check to find out if the version currently included is lower than 1.6. Obviously if a newer version is included I don’t want to remove that as it may cause problems.
If it is then it is de-registered and the version included with the plugin is registered.
There may be an official way of achieving this, but I couldn’t find one.
[php]
if ( $wp_scripts->scripts['prototype']->ver < 1.6 ) {
//replace prototype with version 1.6
wp_deregister_script( 'prototype' );
wp_enqueue_script('prototype', '/wp-content/plugins/plugin-path/prototype.js', NULL , 1.6);
}
Converting Wordpress Themes To Habari
one comment
page 694
Fun With Sidebar Tabs Styling
2 comments
page 336
Using Your Own Url Shortener
4 comments
page 1190
Post Image The Easy Peasy Way
26 comments
page 1065
Using Your Own Url Shortener
4 comments
page 1190
How To Add Sidebars To A Theme
11 comments
page 1053
Html 5 Gallery
6 comments
page 1305
Dont Mess With My Toot Toot
16 comments
page 599
Quick N Dirty Replacement Text
no comment
page 122
Updating Code Snippets Here
one comment
page 1338
Html 5 Gallery
6 comments
page 1305
Post Image The Easy Peasy Way
26 comments
page 1065
Updating Code Snippets Here
one comment
page 1338
Post Image The Easy Peasy Way
26 comments
page 1065
Using Wordpress As A Php Framework
2 comments
page 335
Improve Your Typography With Plugins
one comment
page 721
Quick N Dirty Replacement Text
no comment
page 122
Post Image The Easy Peasy Way
26 comments
page 1065
Post Image The Easy Peasy Way
26 comments
page 1065
Html 5 Gallery
6 comments
page 1305
Wordpress 25 Exif Fields
12 comments
page 230
Using Your Own Url Shortener
4 comments
page 1190
Six Million Ways To Die Choose One
14 comments
page 1128
Fun With Sidebar Tabs Styling
2 comments
page 336
Wpunlimited The Ultimate Wordpress Theme
3 comments
page 1141
Quick N Dirty Admin Login Screen
no comment
page 128
My Experience Of Flexx
4 comments
page 1026
Html 5 Gallery
6 comments
page 1305
Dont Mess With My Toot Toot
16 comments
page 599
Fun With Sidebar Tabs Styling
2 comments
page 336
1 query every 1293 seconds, updated 1 seconds ago.
(__)
`
jimmy
i had one day installed higher version plugin and all my plugins manager had disappeared but when i had removed that plugin from wp-content. I was able to see my plugin window the next day.
So i would say this will be a good code to use.
(__)
`
Andrew Rickmann
Christoph,
That wouldn’t be a problem as this isn’t a permanent change. It overides the default during the init or admin_menu actions so if the plugin was deactivated, or just didn’t run for some reason, then the default version would be loaded.
(__)
`
Christoph Voigt
What happens if you disable the plugin or even worse, disable all your plugins for a WP update by renaming the plugins folder?
With some types of scripts, this could seriously bring users in trouble if there is no “register previous version” functionality in the deactivation routine. And renaming the folder – as some people are used to – will certainly break stuff I guess :(