Ticket #14853: wp-includes.patch
| File wp-includes.patch, 2.5 KB (added by , 11 years ago) |
|---|
-
class.wp-scripts.php
83 83 * @return bool|string|void 84 84 */ 85 85 public function print_extra_script( $handle, $echo = true ) { 86 $scripts = $this->get_data( $handle, 'after' ); 87 if($scripts){ 88 foreach($scripts as $script){ 89 echo "<script type='text/javascript'>\n"; // CDATA and type='text/javascript' is not needed for HTML 5 90 echo "$script\n"; 91 echo "</script>\n"; 92 } 93 } 94 86 95 if ( !$output = $this->get_data( $handle, 'data' ) ) 87 96 return; 88 97 … … 203 212 return true; 204 213 } 205 214 215 public function add_inline_script( $handle, $code ) { 216 if ( ! $code ) { 217 return false; 218 } 219 220 $after = $this->get_data( $handle, 'after' ); 221 if ( ! $after ) { 222 $after = array(); 223 } 224 225 $after[] = $code; 226 227 return $this->add_data( $handle, 'after', $after ); 228 } 229 206 230 /** 207 231 * Localizes a script, only if the script has already been added 208 232 * -
functions.wp-scripts.php
86 86 } 87 87 88 88 /** 89 * Add extra code to a registered Script. 90 * 91 * Code will only be added if the script in already in the queue. 92 * Accepts a string $data containing the Code. If two or more code blocks 93 * are added to the same script $handle, they will be printed in the order 94 * they were added, i.e. the latter added code can redeclare the previous. 95 * 96 */ 97 function wp_add_inline_script( $handle, $data ) { 98 global $wp_scripts; 99 if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) { 100 if ( ! did_action( 'init' ) ) 101 _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ), 102 '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' ); 103 $wp_scripts = new WP_Scripts(); 104 } 105 106 if ( false !== stripos( $data, '</script>' ) ) { 107 _doing_it_wrong( __FUNCTION__, __( 'Do not pass script tags to wp_add_inline_script().' ), '4.1.3' ); 108 $data = trim( preg_replace( '#<script[^>]*>(.*)</script>#is', '$1', $data ) ); 109 } 110 111 return $wp_scripts->add_inline_script( $handle, $data ); 112 } 113 114 115 /** 89 116 * Register a new script. 90 117 * 91 118 * Registers a script to be linked later using the wp_enqueue_script() function.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)