Ticket #11526: 11526.doing_it_wrong.patch
File 11526.doing_it_wrong.patch, 3.3 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(); 52 53 } 53 54 $wp_scripts->add( $handle, $src, $deps, $ver ); 54 55 if ( $in_footer ) 55 56 $wp_scripts->add_data( $handle, 'group', 1 ); … … 65 66 */ 66 67 function wp_localize_script( $handle, $object_name, $l10n ) { 67 68 global $wp_scripts; 68 if ( !is_a($wp_scripts, 'WP_Scripts') ) 69 if ( !is_a($wp_scripts, 'WP_Scripts') ) { 70 _doing_it_wrong(__FUNCTION__, __( '$wp_scripts should not be accessed before init hook.' ), '3.3' ); 69 71 return false; 72 } 70 73 71 74 return $wp_scripts->localize( $handle, $object_name, $l10n ); 72 75 } … … 79 82 */ 80 83 function wp_deregister_script( $handle ) { 81 84 global $wp_scripts; 82 if ( !is_a($wp_scripts, 'WP_Scripts') ) 85 if ( !is_a($wp_scripts, 'WP_Scripts') ) { 86 _doing_it_wrong(__FUNCTION__, __( '$wp_scripts should not be accessed before init hook.' ), '3.3' ); 83 87 $wp_scripts = new WP_Scripts(); 88 } 84 89 85 90 $wp_scripts->remove( $handle ); 86 91 } … … 95 100 */ 96 101 function wp_enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) { 97 102 global $wp_scripts; 98 if ( !is_a($wp_scripts, 'WP_Scripts') ) 103 if ( !is_a($wp_scripts, 'WP_Scripts') ) { 104 _doing_it_wrong(__FUNCTION__, __( '$wp_scripts should not be accessed before init hook.' ), '3.3' ); 99 105 $wp_scripts = new WP_Scripts(); 106 } 100 107 101 108 if ( $src ) { 102 109 $_handle = explode('?', $handle); … … 115 122 */ 116 123 function wp_dequeue_script( $handle ) { 117 124 global $wp_scripts; 118 if ( !is_a($wp_scripts, 'WP_Scripts') ) 125 if ( !is_a($wp_scripts, 'WP_Scripts') ) { 126 _doing_it_wrong(__FUNCTION__, __( '$wp_scripts should not be accessed before init hook.' ), '3.3' ); 119 127 $wp_scripts = new WP_Scripts(); 128 } 120 129 121 130 $wp_scripts->dequeue( $handle ); 122 131 } … … 135 144 */ 136 145 function wp_script_is( $handle, $list = 'queue' ) { 137 146 global $wp_scripts; 138 if ( !is_a($wp_scripts, 'WP_Scripts') ) 147 if ( !is_a($wp_scripts, 'WP_Scripts') ) { 148 _doing_it_wrong(__FUNCTION__, __( '$wp_scripts should not be accessed before init hook.' ), '3.3' ); 139 149 $wp_scripts = new WP_Scripts(); 150 } 140 151 141 152 $query = $wp_scripts->query( $handle, $list ); 142 153 -
wp-includes/script-loader.php
793 793 } 794 794 } 795 795 796 /** 797 * Initializes $wp_scripts global (if it hasn't already been initialized by a faulty plugin or theme). 798 * 799 * @since 3.3 800 */ 801 function wp_scripts_init() { 802 global $wp_scripts; 803 if ( !is_a($wp_scripts, 'WP_Scripts') ) { 804 $wp_scripts = new WP_Scripts(); 805 } 806 } 807 808 add_action( 'init', 'wp_scripts_init', 0 ); // highest priority 796 809 add_action( 'wp_default_scripts', 'wp_default_scripts' ); 797 810 add_filter( 'wp_print_scripts', 'wp_just_in_time_script_localization' ); 798 811 add_filter( 'print_scripts_array', 'wp_prototype_before_jquery' );