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);
}



Wordpress feature image page?
24 comments on page 1065

Addsettingsfield?
3 comments on page 793

Shorter link?
4 comments on page 1190

Shorter link?
4 comments on page 1190

Cssimageforlogin?
no comment on page 128

Cssimageforlogin?
no comment on page 128

Get featured image url wordpress?
24 comments on page 1065

How to clear wpcache?
9 comments on page 1310

Photo gallry code html5?
6 comments on page 1305

Wordpress get image size?
24 comments on page 1065

Sitecouk wptheme?
2 comments on page 1376

Wordpress chat disqus?
no comment on page 1308

Howtocreategoodsizelayout?
4 comments on page 1026

Friend connect profile?
6 comments on page 1364

Get medium image from post?
24 comments on page 1065

Tabbed widgets wp?
no comment on page 333

Wordpress pictue cache lschen?
9 comments on page 1310

Wordpress plugin post separator?
no comment on page 1371

Display photos html 5?
6 comments on page 1305

Fun wordpress themes?
2 comments on page 1376

Wp featured image without size?
24 comments on page 1065

Wordpress get url global?
4 comments on page 1190

Wp unlimited?
3 comments on page 1141

Html5 image gallery?
6 comments on page 1305

Wordpress exif plugin?
12 comments on page 230

Css login screen?
no comment on page 128

Htlm 5 photo gallery?
6 comments on page 1305

Css login screen?
no comment on page 128

Comments by intensedebate?
7 comments on page 1175

Image gallery html 5?
6 comments on page 1305

Wordpress andrew rickmann?
2 comments on page 1376

Wordpress medium large?
24 comments on page 1065

Fun with uninstallation wordpress?
53 comments on page 100

How to clear wp cache?
9 comments on page 1310

Photoshop frameworks?
3 comments on page 296

Html5 gallery?
6 comments on page 1305

Html 5 photo gallery?
6 comments on page 1305

Login screen css template?
no comment on page 128

Html5 photo gallery code?
6 comments on page 1305

Wordpress post multiple images?
24 comments on page 1065
  every 1995s, 1s ago, in 0.03s.
 __
(__)
   `
 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 :(


0s