Changeset 18556 for trunk/wp-includes/functions.wp-scripts.php
- Timestamp:
- 08/17/2011 05:48:13 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.wp-scripts.php
r18490 r18556 48 48 function wp_register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false ) { 49 49 global $wp_scripts; 50 if ( !is_a($wp_scripts, 'WP_Scripts') ) 51 $wp_scripts = new WP_Scripts();50 51 wp_scripts_init(); 52 52 53 53 $wp_scripts->add( $handle, $src, $deps, $ver ); … … 76 76 function wp_localize_script( $handle, $name, $data ) { 77 77 global $wp_scripts; 78 if ( !is_a($wp_scripts, 'WP_Scripts') ) 79 return false;78 79 wp_scripts_init(); 80 80 81 81 return $wp_scripts->add_script_data( $handle, $name, $data ); … … 90 90 function wp_deregister_script( $handle ) { 91 91 global $wp_scripts; 92 if ( !is_a($wp_scripts, 'WP_Scripts') ) 93 $wp_scripts = new WP_Scripts();92 93 wp_scripts_init(); 94 94 95 95 $wp_scripts->remove( $handle ); … … 106 106 function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) { 107 107 global $wp_scripts; 108 if ( !is_a($wp_scripts, 'WP_Scripts') ) 109 $wp_scripts = new WP_Scripts();108 109 wp_scripts_init(); 110 110 111 111 if ( $src ) { … … 126 126 function wp_dequeue_script( $handle ) { 127 127 global $wp_scripts; 128 if ( !is_a($wp_scripts, 'WP_Scripts') ) 129 $wp_scripts = new WP_Scripts();128 129 wp_scripts_init(); 130 130 131 131 $wp_scripts->dequeue( $handle ); … … 146 146 function wp_script_is( $handle, $list = 'queue' ) { 147 147 global $wp_scripts; 148 if ( !is_a($wp_scripts, 'WP_Scripts') ) 149 $wp_scripts = new WP_Scripts();148 149 wp_scripts_init(); 150 150 151 151 $query = $wp_scripts->query( $handle, $list ); … … 156 156 return $query; 157 157 } 158 159 /** 160 * Initializes $wp_scripts global (if it hasn't already been initialized by a faulty plugin or theme). 161 * 162 * @since 3.3 163 */ 164 function wp_scripts_init() { 165 global $wp_scripts; 166 static $done = false; 167 168 if ( !$done && !is_a($wp_scripts, 'WP_Scripts') ) { 169 if ( !did_action('after_setup_theme') ) { // last action before init 170 $func = debug_backtrace(); 171 $trace = !empty($func[1]['function']) ? $func[1]['function'] : __FUNCTION__; 172 173 _doing_it_wrong( $trace, __( '$wp_scripts should not be accessed before the "init" hook.' ), '3.3' ); 174 } 175 176 $wp_scripts = new WP_Scripts(); 177 $done = true; 178 } 179 } 180
Note: See TracChangeset
for help on using the changeset viewer.