Changeset 18556
- Timestamp:
- 08/17/2011 05:48:13 AM (12 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 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 -
trunk/wp-includes/functions.wp-styles.php
r18480 r18556 71 71 function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) { 72 72 global $wp_styles; 73 if ( !is_a($wp_styles, 'WP_Styles') ) 74 $wp_styles = new WP_Styles();73 74 wp_styles_init(); 75 75 76 76 $wp_styles->add( $handle, $src, $deps, $ver, $media ); … … 88 88 function wp_deregister_style( $handle ) { 89 89 global $wp_styles; 90 if ( !is_a($wp_styles, 'WP_Styles') ) 91 $wp_styles = new WP_Styles();90 91 wp_styles_init(); 92 92 93 93 $wp_styles->remove( $handle ); … … 115 115 function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' ) { 116 116 global $wp_styles; 117 if ( !is_a($wp_styles, 'WP_Styles') ) 118 $wp_styles = new WP_Styles();117 118 wp_styles_init(); 119 119 120 120 if ( $src ) { … … 133 133 function wp_dequeue_style( $handle ) { 134 134 global $wp_styles; 135 if ( !is_a($wp_styles, 'WP_Styles') ) 136 $wp_styles = new WP_Styles();135 136 wp_styles_init(); 137 137 138 138 $wp_styles->dequeue( $handle ); … … 153 153 function wp_style_is( $handle, $list = 'queue' ) { 154 154 global $wp_styles; 155 if ( !is_a($wp_styles, 'WP_Styles') ) 156 $wp_styles = new WP_Styles();155 156 wp_styles_init(); 157 157 158 158 $query = $wp_styles->query( $handle, $list ); … … 163 163 return $query; 164 164 } 165 166 /** 167 * Initializes $wp_styles global (if it hasn't already been initialized by a faulty plugin or theme). 168 * 169 * @since 3.3 170 */ 171 function wp_styles_init() { 172 global $wp_styles; 173 static $done = false; 174 175 if ( !$done && !is_a($wp_styles, 'WP_Styles') ) { 176 if ( !did_action('after_setup_theme') ) { 177 $func = debug_backtrace(); 178 $trace = !empty($func[1]['function']) ? $func[1]['function'] : __FUNCTION__; 179 180 _doing_it_wrong( $trace, __( '$wp_styles should not be accessed before the "init" hook.' ), '3.3' ); 181 } 182 183 $wp_styles = new WP_Styles(); 184 $done = true; 185 } 186 } 187
Note: See TracChangeset
for help on using the changeset viewer.