Changeset 42343 for trunk/src/wp-includes/class.wp-scripts.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class.wp-scripts.php
r41686 r42343 146 146 * @param WP_Scripts $this WP_Scripts instance (passed by reference). 147 147 */ 148 do_action_ref_array( 'wp_default_scripts', array( &$this) );148 do_action_ref_array( 'wp_default_scripts', array( &$this ) ); 149 149 } 150 150 … … 197 197 */ 198 198 public function print_extra_script( $handle, $echo = true ) { 199 if ( ! $output = $this->get_data( $handle, 'data' ) )199 if ( ! $output = $this->get_data( $handle, 'data' ) ) { 200 200 return; 201 202 if ( !$echo ) 201 } 202 203 if ( ! $echo ) { 203 204 return $output; 205 } 204 206 205 207 echo "<script type='text/javascript'>\n"; // CDATA and type='text/javascript' is not needed for HTML 5 … … 225 227 */ 226 228 public function do_item( $handle, $group = false ) { 227 if ( ! parent::do_item($handle) )229 if ( ! parent::do_item( $handle ) ) { 228 230 return false; 229 230 if ( 0 === $group && $this->groups[$handle] > 0 ) { 231 } 232 233 if ( 0 === $group && $this->groups[ $handle ] > 0 ) { 231 234 $this->in_footer[] = $handle; 232 235 return false; 233 236 } 234 237 235 if ( false === $group && in_array( $handle, $this->in_footer, true) )238 if ( false === $group && in_array( $handle, $this->in_footer, true ) ) { 236 239 $this->in_footer = array_diff( $this->in_footer, (array) $handle ); 237 238 $obj = $this->registered[$handle]; 240 } 241 242 $obj = $this->registered[ $handle ]; 239 243 240 244 if ( null === $obj->ver ) { … … 244 248 } 245 249 246 if ( isset($this->args[$handle]) ) 247 $ver = $ver ? $ver . '&' . $this->args[$handle] : $this->args[$handle]; 248 249 $src = $obj->src; 250 if ( isset( $this->args[ $handle ] ) ) { 251 $ver = $ver ? $ver . '&' . $this->args[ $handle ] : $this->args[ $handle ]; 252 } 253 254 $src = $obj->src; 250 255 $cond_before = $cond_after = ''; 251 256 $conditional = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : ''; … … 253 258 if ( $conditional ) { 254 259 $cond_before = "<!--[if {$conditional}]>\n"; 255 $cond_after = "<![endif]-->\n";260 $cond_after = "<![endif]-->\n"; 256 261 } 257 262 258 263 $before_handle = $this->print_inline_script( $handle, 'before', false ); 259 $after_handle = $this->print_inline_script( $handle, 'after', false );264 $after_handle = $this->print_inline_script( $handle, 'after', false ); 260 265 261 266 if ( $before_handle ) { … … 285 290 $this->reset(); 286 291 } elseif ( $this->in_default_dir( $srce ) && ! $conditional ) { 287 $this->print_code .= $this->print_extra_script( $handle, false );288 $this->concat .= "$handle,";292 $this->print_code .= $this->print_extra_script( $handle, false ); 293 $this->concat .= "$handle,"; 289 294 $this->concat_version .= "$handle$ver"; 290 295 return true; … … 316 321 } 317 322 318 if ( ! empty( $ver ) ) 323 if ( ! empty( $ver ) ) { 319 324 $src = add_query_arg( 'ver', $ver, $src ); 325 } 320 326 321 327 /** This filter is documented in wp-includes/class.wp-scripts.php */ 322 328 $src = esc_url( apply_filters( 'script_loader_src', $src, $handle ) ); 323 329 324 if ( ! $src ) 330 if ( ! $src ) { 325 331 return true; 332 } 326 333 327 334 $tag = "{$cond_before}{$before_handle}<script type='text/javascript' src='$src'></script>\n{$after_handle}{$cond_after}"; … … 412 419 */ 413 420 public function localize( $handle, $object_name, $l10n ) { 414 if ( $handle === 'jquery' ) 421 if ( $handle === 'jquery' ) { 415 422 $handle = 'jquery-core'; 416 417 if ( is_array($l10n) && isset($l10n['l10n_print_after']) ) { // back compat, preserve the code in 'l10n_print_after' if present 423 } 424 425 if ( is_array( $l10n ) && isset( $l10n['l10n_print_after'] ) ) { // back compat, preserve the code in 'l10n_print_after' if present 418 426 $after = $l10n['l10n_print_after']; 419 unset( $l10n['l10n_print_after']);427 unset( $l10n['l10n_print_after'] ); 420 428 } 421 429 422 430 foreach ( (array) $l10n as $key => $value ) { 423 if ( ! is_scalar($value) )431 if ( ! is_scalar( $value ) ) { 424 432 continue; 425 426 $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8'); 433 } 434 435 $l10n[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' ); 427 436 } 428 437 429 438 $script = "var $object_name = " . wp_json_encode( $l10n ) . ';'; 430 439 431 if ( ! empty($after) )440 if ( ! empty( $after ) ) { 432 441 $script .= "\n$after;"; 442 } 433 443 434 444 $data = $this->get_data( $handle, 'data' ); 435 445 436 if ( ! empty( $data ) )446 if ( ! empty( $data ) ) { 437 447 $script = "$data\n$script"; 448 } 438 449 439 450 return $this->add_data( $handle, 'data', $script ); … … 453 464 */ 454 465 public function set_group( $handle, $recursion, $group = false ) { 455 if ( isset( $this->registered[ $handle]->args ) && $this->registered[$handle]->args === 1 )466 if ( isset( $this->registered[ $handle ]->args ) && $this->registered[ $handle ]->args === 1 ) { 456 467 $grp = 1; 457 else468 } else { 458 469 $grp = (int) $this->get_data( $handle, 'group' ); 459 460 if ( false !== $group && $grp > $group ) 470 } 471 472 if ( false !== $group && $grp > $group ) { 461 473 $grp = $group; 474 } 462 475 463 476 return parent::set_group( $handle, $recursion, $grp ); … … 466 479 /** 467 480 * Determines script dependencies. 468 481 * 469 482 * @since 2.1.0 470 483 * … … 501 514 */ 502 515 public function do_head_items() { 503 $this->do_items( false, 0);516 $this->do_items( false, 0 ); 504 517 return $this->done; 505 518 } … … 515 528 */ 516 529 public function do_footer_items() { 517 $this->do_items( false, 1);530 $this->do_items( false, 1 ); 518 531 return $this->done; 519 532 } … … 550 563 */ 551 564 public function reset() { 552 $this->do_concat = false;553 $this->print_code = '';554 $this->concat = '';565 $this->do_concat = false; 566 $this->print_code = ''; 567 $this->concat = ''; 555 568 $this->concat_version = ''; 556 $this->print_html = '';557 $this->ext_version = '';558 $this->ext_handles = '';569 $this->print_html = ''; 570 $this->ext_version = ''; 571 $this->ext_handles = ''; 559 572 } 560 573 }
Note: See TracChangeset
for help on using the changeset viewer.