Version Description
- No longer disable script concatenation when using WordPress 3.0 or greater
- Attempt to detect when another plugin or theme has called 'wp_register_script' and/or 'wp_enque_script' before 'init' and work around it.
- Limited debugging output when WP_DEBUG is enabled.
Download this release
Release Info
Developer | jczorkmid |
Plugin | Use Google Libraries |
Version | 1.1 |
Comparing to | |
See all releases |
Code changes from version 1.0.9.2 to 1.1
- README.txt +22 -17
- use-google-libraries.php +41 -8
README.txt
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
=== Use Google Libraries ===
|
2 |
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.9.1
|
6 |
-
Tested up to:
|
7 |
-
Stable tag: 1.
|
8 |
|
9 |
Allows your site to use common javascript libraries from Google's AJAX
|
10 |
-
Libraries CDN, rather than from
|
11 |
|
12 |
== Description ==
|
13 |
|
@@ -60,22 +60,17 @@ of the way when things are not as expected. While not, perhaps,
|
|
60 |
giving you the greatest benefit it helps ensure you site doesn't just
|
61 |
flat out stop working.
|
62 |
|
63 |
-
In general, anything that calls
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
|
|
|
|
|
69 |
|
70 |
== Incompatible Plugins ==
|
71 |
|
72 |
-
|
73 |
-
= Popularity Contest =
|
74 |
-
|
75 |
-
As of version 2.0b2 enabling this plugin prevents UGL from loading due
|
76 |
-
to it enqueing jQuery before 'init'.
|
77 |
-
|
78 |
-
|
79 |
== Incompatible Themes ==
|
80 |
|
81 |
= K2 =
|
@@ -85,6 +80,15 @@ using K2.
|
|
85 |
|
86 |
== Changelog ==
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
= 1.0.9.2 =
|
89 |
|
90 |
+ Hopefully fix issue with plugin loading for some users
|
@@ -164,7 +168,8 @@ improves the chances of the given URL already being cached, and prevents
|
|
164 |
|
165 |
== References ==
|
166 |
|
167 |
-
Parts of this plugin (specificly, the dropping of the micro number
|
|
|
168 |
inspired by John Blackbourn's
|
169 |
**[Google AJAX Libraries](http://lud.icro.us/wordpress-plugin-google-ajax-libraries/)**,
|
170 |
which has very similar goals to this plugin.
|
1 |
=== Use Google Libraries ===
|
2 |
Contributors: jczorkmid
|
3 |
Donate link: http://jasonpenney.net/donate
|
4 |
+
Tags: javascript, performance, CDN, Google, jQuery, Prototype, MooTools, Dojo, Google AJAX Libraries API, YSlow, Page Speed
|
5 |
Requires at least: 2.9.1
|
6 |
+
Tested up to: 3.0
|
7 |
+
Stable tag: 1.1
|
8 |
|
9 |
Allows your site to use common javascript libraries from Google's AJAX
|
10 |
+
Libraries CDN, rather than from WordPress's own copies.
|
11 |
|
12 |
== Description ==
|
13 |
|
60 |
giving you the greatest benefit it helps ensure you site doesn't just
|
61 |
flat out stop working.
|
62 |
|
63 |
+
In general, anything that calls wp_register_script and/or
|
64 |
+
wp_eneque_script before 'init' causes trouble for **Use Google
|
65 |
+
Libraries**. I've made an effort to force it to try and run anyhow,
|
66 |
+
so please report any issues with this. If you have 'WP_DEBUG'
|
67 |
+
enabled, a message will be logged letting you know this is happening.
|
68 |
|
69 |
+
Please see the section on **Incompatible Plugins** and
|
70 |
+
**Incompatible Themes** for specific information.
|
71 |
|
72 |
== Incompatible Plugins ==
|
73 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
== Incompatible Themes ==
|
75 |
|
76 |
= K2 =
|
80 |
|
81 |
== Changelog ==
|
82 |
|
83 |
+
= 1.1 =
|
84 |
+
|
85 |
+
+ No longer disable script concatenation when using WordPress 3.0 or
|
86 |
+
greater
|
87 |
+
+ Attempt to detect when another plugin or theme has called
|
88 |
+
'wp_register_script' and/or 'wp_enque_script' before 'init' and work
|
89 |
+
around it.
|
90 |
+
+ Limited debugging output when WP_DEBUG is enabled.
|
91 |
+
|
92 |
= 1.0.9.2 =
|
93 |
|
94 |
+ Hopefully fix issue with plugin loading for some users
|
168 |
|
169 |
== References ==
|
170 |
|
171 |
+
Parts of this plugin (specificly, the dropping of the micro number,
|
172 |
+
which has since been removed for better caching performance) were
|
173 |
inspired by John Blackbourn's
|
174 |
**[Google AJAX Libraries](http://lud.icro.us/wordpress-plugin-google-ajax-libraries/)**,
|
175 |
which has very similar goals to this plugin.
|
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.
|
7 |
Author: Jason Penney
|
8 |
Author URI: http://jasonpenney.net/
|
9 |
*/
|
@@ -53,6 +53,9 @@ if (!class_exists('JCP_UseGoogleLibraries')) {
|
|
53 |
protected $noconflict_url;
|
54 |
protected $noconflict_next;
|
55 |
protected $is_ssl;
|
|
|
|
|
|
|
56 |
/**
|
57 |
* PHP 4 Compatible Constructor
|
58 |
*/
|
@@ -107,6 +110,7 @@ if (!class_exists('JCP_UseGoogleLibraries')) {
|
|
107 |
}
|
108 |
|
109 |
static function configure_plugin() {
|
|
|
110 |
add_action( 'wp_default_scripts',
|
111 |
array( 'JCP_UseGoogleLibraries',
|
112 |
'replace_default_scripts_action'),
|
@@ -114,24 +118,52 @@ if (!class_exists('JCP_UseGoogleLibraries')) {
|
|
114 |
add_filter( 'script_loader_src',
|
115 |
array( "JCP_UseGoogleLibraries", "remove_ver_query_filter" ),
|
116 |
1000);
|
117 |
-
add_filter( 'init',array( "JCP_UseGoogleLibraries", "setup_filter" ));
|
118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
120 |
|
121 |
|
|
|
|
|
|
|
|
|
122 |
static function setup_filter() {
|
123 |
$ugl = self::get_instance();
|
124 |
$ugl->setup();
|
125 |
}
|
126 |
|
127 |
-
|
128 |
/**
|
129 |
* Disables script concatination, which breaks when dependencies are not
|
130 |
-
* all loaded locally
|
|
|
|
|
|
|
|
|
131 |
*/
|
132 |
function setup() {
|
133 |
-
global $concatenate_scripts;
|
134 |
-
$
|
|
|
|
|
135 |
}
|
136 |
|
137 |
|
@@ -239,5 +271,6 @@ if (!class_exists('JCP_UseGoogleLibraries')) {
|
|
239 |
|
240 |
//instantiate the class
|
241 |
if (class_exists('JCP_UseGoogleLibraries')){
|
242 |
-
|
243 |
}
|
|
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.1
|
7 |
Author: Jason Penney
|
8 |
Author URI: http://jasonpenney.net/
|
9 |
*/
|
53 |
protected $noconflict_url;
|
54 |
protected $noconflict_next;
|
55 |
protected $is_ssl;
|
56 |
+
protected static $script_before_init_notice =
|
57 |
+
'<strong>Use Google Libraries</strong>: Another plugin has registered or enqued a script before the "init" action. Attempting to work around it.';
|
58 |
+
|
59 |
/**
|
60 |
* PHP 4 Compatible Constructor
|
61 |
*/
|
110 |
}
|
111 |
|
112 |
static function configure_plugin() {
|
113 |
+
|
114 |
add_action( 'wp_default_scripts',
|
115 |
array( 'JCP_UseGoogleLibraries',
|
116 |
'replace_default_scripts_action'),
|
118 |
add_filter( 'script_loader_src',
|
119 |
array( "JCP_UseGoogleLibraries", "remove_ver_query_filter" ),
|
120 |
1000);
|
121 |
+
add_filter( 'init',array( "JCP_UseGoogleLibraries", "setup_filter" ) );
|
122 |
+
|
123 |
+
// There's a chance some plugin has called wp_enqueue_script outside
|
124 |
+
// of any hooks, which means that this plugin's 'wp_default_scripts'
|
125 |
+
// hook will never get a chance to fire. This tries to work around
|
126 |
+
// that.
|
127 |
+
global $wp_scripts;
|
128 |
+
if ( is_a($wp_scripts, 'WP_Scripts') ) {
|
129 |
+
if( WP_DEBUG !== false ) {
|
130 |
+
error_log(self::$script_before_init_notice);
|
131 |
+
}
|
132 |
+
/*
|
133 |
+
if ( is_admin() ) {
|
134 |
+
add_action('admin_notices',
|
135 |
+
array("JCP_UseGoogleLibraries",
|
136 |
+
'script_before_init_admin_notice'));
|
137 |
+
}
|
138 |
+
*/
|
139 |
+
$ugl = self::get_instance();
|
140 |
+
$ugl->replace_default_scripts( $wp_scripts );
|
141 |
+
}
|
142 |
}
|
143 |
|
144 |
|
145 |
+
static function script_before_init_admin_notice() {
|
146 |
+
echo '<div class="error fade"><p>' . self::$script_before_init_notice . '</p></div>';
|
147 |
+
}
|
148 |
+
|
149 |
static function setup_filter() {
|
150 |
$ugl = self::get_instance();
|
151 |
$ugl->setup();
|
152 |
}
|
153 |
|
|
|
154 |
/**
|
155 |
* Disables script concatination, which breaks when dependencies are not
|
156 |
+
* all loaded locally.
|
157 |
+
*
|
158 |
+
* I retested this in version 3.0 and it seems to be working fine when
|
159 |
+
* concatenation is enabled, so for now I'm only disabling in older
|
160 |
+
* versions.
|
161 |
*/
|
162 |
function setup() {
|
163 |
+
global $concatenate_scripts, $wp_version;
|
164 |
+
if (version_compare($wp_version, '3.0') < 0) {
|
165 |
+
$concatenate_scripts = false;
|
166 |
+
}
|
167 |
}
|
168 |
|
169 |
|
271 |
|
272 |
//instantiate the class
|
273 |
if (class_exists('JCP_UseGoogleLibraries')){
|
274 |
+
JCP_UseGoogleLibraries::configure_plugin();
|
275 |
}
|
276 |
+
|