Ticket #11526: 11526.2.patch
File 11526.2.patch, 5.8 KB (added by , 12 years ago) |
---|
-
wp-includes/functions.wp-scripts.php
47 47 */ 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') ) 50 if ( !is_a($wp_scripts, 'WP_Scripts') ) { 51 _doing_it_wrong( __FUNCTION__, __( '$wp_scripts should not be accessed before init hook.' ), '3.3' ); 51 52 $wp_scripts = new WP_Scripts(); 53 } 52 54 53 55 $wp_scripts->add( $handle, $src, $deps, $ver ); 54 56 if ( $in_footer ) … … 75 77 */ 76 78 function wp_localize_script( $handle, $name, $data ) { 77 79 global $wp_scripts; 78 if ( !is_a($wp_scripts, 'WP_Scripts') ) 80 if ( !is_a($wp_scripts, 'WP_Scripts') ) { 81 _doing_it_wrong( __FUNCTION__, __( '$wp_scripts should not be accessed before init hook.' ), '3.3' ); 79 82 return false; 83 } 80 84 81 85 return $wp_scripts->add_script_data( $handle, $name, $data ); 82 86 } … … 89 93 */ 90 94 function wp_deregister_script( $handle ) { 91 95 global $wp_scripts; 92 if ( !is_a($wp_scripts, 'WP_Scripts') ) 96 if ( !is_a($wp_scripts, 'WP_Scripts') ) { 97 _doing_it_wrong( __FUNCTION__, __( '$wp_scripts should not be accessed before init hook.' ), '3.3' ); 93 98 $wp_scripts = new WP_Scripts(); 99 } 94 100 95 101 $wp_scripts->remove( $handle ); 96 102 } … … 105 111 */ 106 112 function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) { 107 113 global $wp_scripts; 108 if ( !is_a($wp_scripts, 'WP_Scripts') ) 114 if ( !is_a($wp_scripts, 'WP_Scripts') ) { 115 _doing_it_wrong( __FUNCTION__, __( '$wp_scripts should not be accessed before init hook.' ), '3.3' ); 109 116 $wp_scripts = new WP_Scripts(); 117 } 110 118 111 119 if ( $src ) { 112 120 $_handle = explode('?', $handle); … … 125 133 */ 126 134 function wp_dequeue_script( $handle ) { 127 135 global $wp_scripts; 128 if ( !is_a($wp_scripts, 'WP_Scripts') ) 136 if ( !is_a($wp_scripts, 'WP_Scripts') ) { 137 _doing_it_wrong( __FUNCTION__, __( '$wp_scripts should not be accessed before init hook.' ), '3.3' ); 129 138 $wp_scripts = new WP_Scripts(); 139 } 130 140 131 141 $wp_scripts->dequeue( $handle ); 132 142 } … … 145 155 */ 146 156 function wp_script_is( $handle, $list = 'queue' ) { 147 157 global $wp_scripts; 148 if ( !is_a($wp_scripts, 'WP_Scripts') ) 158 if ( !is_a($wp_scripts, 'WP_Scripts') ) { 159 _doing_it_wrong( __FUNCTION__, __( '$wp_scripts should not be accessed before init hook.' ), '3.3' ); 149 160 $wp_scripts = new WP_Scripts(); 161 } 150 162 151 163 $query = $wp_scripts->query( $handle, $list ); 152 164 -
wp-includes/functions.wp-styles.php
70 70 */ 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') ) 73 if ( !is_a($wp_styles, 'WP_Styles') ) { 74 _doing_it_wrong( __FUNCTION__, __( '$wp_styles should not be accessed before init hook.' ), '3.3' ); 74 75 $wp_styles = new WP_Styles(); 76 } 75 77 76 78 $wp_styles->add( $handle, $src, $deps, $ver, $media ); 77 79 } … … 87 89 */ 88 90 function wp_deregister_style( $handle ) { 89 91 global $wp_styles; 90 if ( !is_a($wp_styles, 'WP_Styles') ) 92 if ( !is_a($wp_styles, 'WP_Styles') ) { 91 93 $wp_styles = new WP_Styles(); 94 _doing_it_wrong( __FUNCTION__, __( '$wp_styles should not be accessed before init hook.' ), '3.3' ); 95 } 92 96 93 97 $wp_styles->remove( $handle ); 94 98 } … … 114 118 */ 115 119 function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' ) { 116 120 global $wp_styles; 117 if ( !is_a($wp_styles, 'WP_Styles') ) 121 if ( !is_a($wp_styles, 'WP_Styles') ) { 118 122 $wp_styles = new WP_Styles(); 123 _doing_it_wrong( __FUNCTION__, __( '$wp_styles should not be accessed before init hook.' ), '3.3' ); 124 } 119 125 120 126 if ( $src ) { 121 127 $_handle = explode('?', $handle); … … 132 138 */ 133 139 function wp_dequeue_style( $handle ) { 134 140 global $wp_styles; 135 if ( !is_a($wp_styles, 'WP_Styles') ) 141 if ( !is_a($wp_styles, 'WP_Styles') ) { 136 142 $wp_styles = new WP_Styles(); 143 _doing_it_wrong( __FUNCTION__, __( '$wp_styles should not be accessed before init hook.' ), '3.3' ); 144 } 137 145 138 146 $wp_styles->dequeue( $handle ); 139 147 } … … 152 160 */ 153 161 function wp_style_is( $handle, $list = 'queue' ) { 154 162 global $wp_styles; 155 if ( !is_a($wp_styles, 'WP_Styles') ) 163 if ( !is_a($wp_styles, 'WP_Styles') ) { 156 164 $wp_styles = new WP_Styles(); 165 _doing_it_wrong( __FUNCTION__, __( '$wp_styles should not be accessed before init hook.' ), '3.3' ); 166 } 157 167 158 168 $query = $wp_styles->query( $handle, $list ); 159 169 -
wp-includes/script-loader.php
765 765 } 766 766 } 767 767 768 /** 769 * Initializes $wp_scripts global (if it hasn't already been initialized by a faulty plugin or theme). 770 * 771 * @since 3.3 772 */ 773 function wp_scripts_init() { 774 global $wp_scripts; 775 776 if ( !is_a($wp_scripts, 'WP_Scripts') ) 777 $wp_scripts = new WP_Scripts(); 778 } 779 780 /** 781 * Initializes $wp_styles global (if it hasn't already been initialized by a faulty plugin or theme). 782 * 783 * @since 3.3 784 */ 785 function wp_styles_init() { 786 global $wp_styles; 787 788 if ( !is_a($wp_styles, 'WP_Styles') ) 789 $wp_styles = new WP_Styles(); 790 } 791 792 add_action( 'init', 'wp_scripts_init', 0 ); // highest priority 768 793 add_action( 'wp_default_scripts', 'wp_default_scripts' ); 769 794 add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); 770 795 add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' ); 771 796 797 add_action( 'init', 'wp_styles_init', 0 ); // highest priority 772 798 add_action( 'wp_default_styles', 'wp_default_styles' ); 773 799 add_filter( 'style_loader_src', 'wp_style_loader_src', 10, 2 );