888888.888888.88""Yb..dP"Yb..8888b..Yb..dP.88b.88....db....8b....d8.88..dP""b8..dP"Y8
88__...88__...88__dP.dP...Yb..8I..Yb.YbdP..88Yb88...dPYb...88b..d88.88.dP...`".`Ybo."
88""...88""...88"Yb..Yb...dP..8I..dY..8P...88.Y88..dP__Yb..88YbdP88.88.Yb......o.`Y8b
88.....888888.88..Yb..YbodP..8888Y"..dP....88..Y8.dP""""Yb.88.YY.88.88..YboodP.8bodP'


88b.88.888888.888888.Yb........dP.dP"Yb..88""Yb.88..dP
88Yb88.88__.....88....Yb..db..dP.dP...Yb.88__dP.88odP.
88.Y88.88"".....88.....YbdPYbdP..Yb...dP.88"Yb..88"Yb.
88..Y8.888888...88......YP..YP....YbodP..88..Yb.88..Yb

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

Post Image The Easy Peasy Way
Wp postimages order?
26 comments
page 1065
Html 5 Gallery
Html 5 image gallery?
6 comments
page 1305
Post Image The Easy Peasy Way
Php post imagesmedium?
26 comments
page 1065
Fun With Sidebar Tabs Styling
Sidebar image interesting?
2 comments
page 336
Post Image The Easy Peasy Way
Postimagesmedium?
26 comments
page 1065
Post Image The Easy Peasy Way
Wp codex postimagesmedium?
26 comments
page 1065
Fun With Sidebar Tabs Styling
Styling tabs css?
2 comments
page 336
Post Image The Easy Peasy Way
Theimage wordpress?
26 comments
page 1065
How To Add Sidebars To A Theme
Add widgetized footer in wordpress theme?
10 comments
page 1053
Html 5 Gallery
Html5 image gallery?
6 comments
page 1305
Wordpress Vs Graffiti
Graffiti yb combined?
8 comments
page 95
Poll Daddy Reviewed
Polldaddy poll?
2 comments
page 42
Why I Ditched Disqus
Add wordpress comments to friendfeed?
5 comments
page 1175
Html 5 Gallery
Html5 gallery?
6 comments
page 1305
Html 5 Gallery
Html5 gallery?
6 comments
page 1305
Post Image The Easy Peasy Way
Wp display all post images?
26 comments
page 1065
Quick N Dirty Post Exclusion
Fitler theloop addfilter?
11 comments
page 124
Using Your Own Url Shortener
Constructor and link shortner?
4 comments
page 1190
My Experience Of Flexx
Flexx of genesis wp theme?
4 comments
page 1026
Html 5 Gallery
Html5?
6 comments
page 1305
Wordpress Chat
Tchat page wordpress?
3 comments
page 1308
Quick N Dirty Post Exclusion
Filter wordpress posts plugin?
11 comments
page 124
Post Image The Easy Peasy Way
Wp post orderby?
26 comments
page 1065
Post Image The Easy Peasy Way
Wp add attachment?
26 comments
page 1065
Html 5 Gallery
Html 5 gallery?
6 comments
page 1305
Html 5 Gallery
Pictures html5?
6 comments
page 1305
Html 5 Gallery
Pictures html5?
6 comments
page 1305
Post Image The Easy Peasy Way
Wordpress attach images to post?
26 comments
page 1065
Auto Cycle Fun With Sidebar Tabs
Wordpress make your plugin updateable?
one comment
page 1129
Using Your Own Url Shortener
How to flushrewriterules?
4 comments
page 1190
Wordpress Chat
Postimagetheeasypeasyway?
3 comments
page 1308
Custom Hooks For Admin Pages
Addaction adminpost?
one comment
page 430
Custom Hooks For Admin Pages
Addaction adminpost?
one comment
page 430
  1 query every 909 seconds, updated 1 seconds ago.
Sunday, 4am
 __
(__)
   `

 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.

Friday, 4pm
 __
(__)
   `

 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.

Friday, 3pm
 __
(__)
   `

 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 :(