Version Description
- Disables script concatenation in WordPress 2.8, since it seems to have issues when some of the dependencies are outside of the concatenation.
- Persists flag to load scripts in the footer in WordPress 2.8
Download this release
Release Info
Developer | jczorkmid |
Plugin | Use Google Libraries |
Version | 1.0.6 |
Comparing to | |
See all releases |
Code changes from version 1.0.5 to 1.0.6
- README.txt +10 -4
- use-google-libraries.php +39 -3
README.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: jczorkmid
|
|
3 |
Donate link: http://jasonpenney.net/donate
|
4 |
Tags: javascript, performance, CDN, Google, jQuery, Prototype, MooTools, Dojo, Google AJAX Libraries API
|
5 |
Requires at least: 2.6
|
6 |
-
Tested up to: 2.
|
7 |
-
Stable tag: 1.0.
|
8 |
|
9 |
Allows your site to use common javascript libraries from Google's AJAX
|
10 |
Libraries CDN, rather than from Wordpress's own copies.
|
@@ -14,7 +14,7 @@ Libraries CDN, rather than from Wordpress's own copies.
|
|
14 |
A number of the javascript libraries distributed with Wordpress are also
|
15 |
hosted on Google's [AJAX Libraries API](http://code.google.com/apis/ajaxlibs/).
|
16 |
This plugin allows your Wordpress site to use the content distribution
|
17 |
-
network side of Google's AJAX Library API, rather than serving these files from your
|
18 |
|
19 |
This provides numerous potential performance benefits:
|
20 |
|
@@ -86,9 +86,15 @@ which has very similar goals to this plugin.
|
|
86 |
|
87 |
== Changelog ==
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
= 1.0.5 =
|
90 |
|
91 |
-
|
92 |
[suggestions](http://jasonpenney.net/wordpress-plugins/use-google-libraries/comment-page-1/#comment-32427)
|
93 |
from [Peter Wilson](http://peterwilson.cc/).
|
94 |
|
3 |
Donate link: http://jasonpenney.net/donate
|
4 |
Tags: javascript, performance, CDN, Google, jQuery, Prototype, MooTools, Dojo, Google AJAX Libraries API
|
5 |
Requires at least: 2.6
|
6 |
+
Tested up to: 2.8
|
7 |
+
Stable tag: 1.0.6
|
8 |
|
9 |
Allows your site to use common javascript libraries from Google's AJAX
|
10 |
Libraries CDN, rather than from Wordpress's own copies.
|
14 |
A number of the javascript libraries distributed with Wordpress are also
|
15 |
hosted on Google's [AJAX Libraries API](http://code.google.com/apis/ajaxlibs/).
|
16 |
This plugin allows your Wordpress site to use the content distribution
|
17 |
+
network side of Google's AJAX Library API, rather than serving these files from your WordPress install directly.
|
18 |
|
19 |
This provides numerous potential performance benefits:
|
20 |
|
86 |
|
87 |
== Changelog ==
|
88 |
|
89 |
+
= 1.0.6 =
|
90 |
+
|
91 |
+
+ Disables script concatenation in WordPress 2.8, since it seems to have
|
92 |
+
issues when some of the dependencies are outside of the concatenation.
|
93 |
+
+ Persists flag to load scripts in the footer in WordPress 2.8
|
94 |
+
|
95 |
= 1.0.5 =
|
96 |
|
97 |
+
Implemented a pair of
|
98 |
[suggestions](http://jasonpenney.net/wordpress-plugins/use-google-libraries/comment-page-1/#comment-32427)
|
99 |
from [Peter Wilson](http://peterwilson.cc/).
|
100 |
|
use-google-libraries.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Use Google Libraries
|
4 |
Plugin URI: http://jasonpenney.net/wordpress-plugins/use-google-libraries/
|
5 |
Description:Allows your site to use common javascript libraries from Google's AJAX Libraries CDN, rather than from Wordpress's own copies.
|
6 |
-
Version: 1.0.
|
7 |
Author: Jason Penney
|
8 |
Author URI: http://jasonpenney.net/
|
9 |
*/
|
@@ -67,13 +67,26 @@ if (!class_exists('JCP_UseGoogleLibraries')) {
|
|
67 |
'scriptaculous-slider' => array('',''),
|
68 |
'scriptaculous-sound' => array('',''),
|
69 |
'mootools' => array('mootools','mootools-yui-compressed'),
|
70 |
-
'dojo' => array('dojo','dojo.xd')
|
|
|
|
|
|
|
71 |
);
|
72 |
add_action( 'wp_default_scripts', array(&$this,"replace_default_scripts"),1000);
|
73 |
add_filter( 'print_scripts_array',array(&$this,"jquery_noconflict"),1000);
|
74 |
add_filter( 'script_loader_src', array(&$this,"remove_ver_query"),1000);
|
|
|
75 |
}
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
/**
|
78 |
* Replace as many of the wordpress default script registrations as possible
|
79 |
* with ones from google
|
@@ -110,11 +123,20 @@ if (!class_exists('JCP_UseGoogleLibraries')) {
|
|
110 |
}
|
111 |
|
112 |
foreach ($newscripts as $script) {
|
|
|
113 |
$scripts->remove( $script->handle );
|
114 |
// re-register with original ver
|
115 |
$scripts->add($script->handle, $script->src, $script->deps, $script->ver);
|
|
|
|
|
|
|
|
|
116 |
}
|
117 |
$scripts->add( 'jquery-noconflict', WP_PLUGIN_URL . '/use-google-libraries/js/jQnc.js', array('jquery-core'));
|
|
|
|
|
|
|
|
|
118 |
}
|
119 |
|
120 |
|
@@ -132,6 +154,20 @@ if (!class_exists('JCP_UseGoogleLibraries')) {
|
|
132 |
return $js_array;
|
133 |
}
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
/**
|
136 |
* Remove 'ver' from query string for scripts loaded from Google's
|
137 |
* CDN
|
3 |
Plugin Name: Use Google Libraries
|
4 |
Plugin URI: http://jasonpenney.net/wordpress-plugins/use-google-libraries/
|
5 |
Description:Allows your site to use common javascript libraries from Google's AJAX Libraries CDN, rather than from Wordpress's own copies.
|
6 |
+
Version: 1.0.6
|
7 |
Author: Jason Penney
|
8 |
Author URI: http://jasonpenney.net/
|
9 |
*/
|
67 |
'scriptaculous-slider' => array('',''),
|
68 |
'scriptaculous-sound' => array('',''),
|
69 |
'mootools' => array('mootools','mootools-yui-compressed'),
|
70 |
+
'dojo' => array('dojo','dojo.xd'),
|
71 |
+
'swfobject' => array('swfobject','swfobject'),
|
72 |
+
'yui' => array('yui','build/yuiloader/yuiloader-min'),
|
73 |
+
'ext-core' => array('ext-core','ext-core')
|
74 |
);
|
75 |
add_action( 'wp_default_scripts', array(&$this,"replace_default_scripts"),1000);
|
76 |
add_filter( 'print_scripts_array',array(&$this,"jquery_noconflict"),1000);
|
77 |
add_filter( 'script_loader_src', array(&$this,"remove_ver_query"),1000);
|
78 |
+
add_filter( 'init', array(&$this,"setup"));
|
79 |
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* Disables script concatination, which breaks when dependencies are not
|
83 |
+
* all loaded locally
|
84 |
+
*/
|
85 |
+
function setup() {
|
86 |
+
global $concatenate_scripts;
|
87 |
+
$concatenate_scripts = false;
|
88 |
+
}
|
89 |
+
|
90 |
/**
|
91 |
* Replace as many of the wordpress default script registrations as possible
|
92 |
* with ones from google
|
123 |
}
|
124 |
|
125 |
foreach ($newscripts as $script) {
|
126 |
+
$olddata = $this->WP_Dependency_get_data($scripts, $script->handle);
|
127 |
$scripts->remove( $script->handle );
|
128 |
// re-register with original ver
|
129 |
$scripts->add($script->handle, $script->src, $script->deps, $script->ver);
|
130 |
+
if ($olddata)
|
131 |
+
foreach ($olddata as $data_name => $data) {
|
132 |
+
$scripts->add_data($script->handle,$data_name,$data);
|
133 |
+
}
|
134 |
}
|
135 |
$scripts->add( 'jquery-noconflict', WP_PLUGIN_URL . '/use-google-libraries/js/jQnc.js', array('jquery-core'));
|
136 |
+
$jqueryGroup = $this->WP_Dependency_get_data($scripts,'jquery','group');
|
137 |
+
if ($jqueryGroup) {
|
138 |
+
$scripts->add_data('jquery-noconflict','group',$jqueryGroup);;
|
139 |
+
}
|
140 |
}
|
141 |
|
142 |
|
154 |
return $js_array;
|
155 |
}
|
156 |
|
157 |
+
function WP_Dependency_get_data( $dep_obj, $handle, $data_name = false) {
|
158 |
+
|
159 |
+
if ( !method_exists($dep_obj,'add_data') )
|
160 |
+
return false;
|
161 |
+
|
162 |
+
if ( !isset($dep_obj->registered[$handle]) )
|
163 |
+
return false;
|
164 |
+
|
165 |
+
if (!$data_name)
|
166 |
+
return $dep_obj->registered[$handle]->extra;
|
167 |
+
|
168 |
+
return $dep_obj->registered[$handle]->extra[$data_name];
|
169 |
+
}
|
170 |
+
|
171 |
/**
|
172 |
* Remove 'ver' from query string for scripts loaded from Google's
|
173 |
* CDN
|