Changeset 43738
- Timestamp:
- 10/17/2018 03:28:33 PM (6 years ago)
- Location:
- branches/5.0
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.0/src/wp-includes/class-wp-editor.php
r43482 r43738 310 310 if ( is_admin() ) { 311 311 add_action( 'admin_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 ); 312 add_action( 'admin_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 ); 312 313 add_action( 'admin_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 ); 313 314 } else { 314 315 add_action( 'wp_print_footer_scripts', array( __CLASS__, 'editor_js' ), 50 ); 316 add_action( 'wp_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 ); 315 317 add_action( 'wp_print_footer_scripts', array( __CLASS__, 'enqueue_scripts' ), 1 ); 316 318 } … … 744 746 * 745 747 * @static 746 * 748 * 747 749 * @param bool $default_scripts Optional. Whether default scripts should be enqueued. Default false. 748 750 */ … … 806 808 807 809 if ( is_admin() ) { 810 add_action( 'admin_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 ); 808 811 add_action( 'admin_print_footer_scripts', array( __CLASS__, 'print_default_editor_scripts' ), 45 ); 809 812 } else { 813 add_action( 'wp_print_footer_scripts', array( __CLASS__, 'force_uncompressed_tinymce' ), 1 ); 810 814 add_action( 'wp_print_footer_scripts', array( __CLASS__, 'print_default_editor_scripts' ), 45 ); 811 815 } … … 1374 1378 1375 1379 /** 1380 * Force uncompressed TinyMCE when a custom theme has been defined. 1381 * 1382 * The compressed TinyMCE file cannot deal with custom themes, so this makes 1383 * sure that we use the uncompressed TinyMCE file if a theme is defined. 1384 * Even if we are on a production environment. 1385 */ 1386 public static function force_uncompressed_tinymce() { 1387 $has_custom_theme = false; 1388 foreach ( self::$mce_settings as $init ) { 1389 if ( ! empty( $init['theme_url'] ) ) { 1390 $has_custom_theme = true; 1391 break; 1392 } 1393 } 1394 1395 if ( ! $has_custom_theme ) { 1396 return; 1397 } 1398 1399 $wp_scripts = wp_scripts(); 1400 1401 $wp_scripts->remove( 'wp-tinymce' ); 1402 wp_register_tinymce_scripts( $wp_scripts, true ); 1403 } 1404 1405 /** 1376 1406 * Print (output) the main TinyMCE scripts. 1377 1407 * … … 1384 1414 */ 1385 1415 public static function print_tinymce_scripts() { 1386 global $ tinymce_version, $concatenate_scripts, $compress_scripts;1416 global $concatenate_scripts; 1387 1417 1388 1418 if ( self::$tinymce_scripts_printed ) { … … 1394 1424 if ( ! isset( $concatenate_scripts ) ) { 1395 1425 script_concat_settings(); 1396 }1397 1398 $suffix = SCRIPT_DEBUG ? '' : '.min';1399 $version = 'ver=' . $tinymce_version;1400 $baseurl = self::get_baseurl();1401 1402 $has_custom_theme = false;1403 foreach ( self::$mce_settings as $init ) {1404 if ( ! empty( $init['theme_url'] ) ) {1405 $has_custom_theme = true;1406 break;1407 }1408 }1409 1410 $compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] )1411 && false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $has_custom_theme;1412 1413 // Load tinymce.js when running from /src, else load wp-tinymce.js.gz (production) or tinymce.min.js (SCRIPT_DEBUG)1414 $mce_suffix = false !== strpos( get_bloginfo( 'version' ), '-src' ) ? '' : '.min';1415 1416 if ( $compressed ) {1417 echo "<script type='text/javascript' src='{$baseurl}/wp-tinymce.php?c=1&$version'></script>\n";1418 } else {1419 echo "<script type='text/javascript' src='{$baseurl}/tinymce{$mce_suffix}.js?$version'></script>\n";1420 echo "<script type='text/javascript' src='{$baseurl}/plugins/compat3x/plugin{$suffix}.js?$version'></script>\n";1421 1426 } 1422 1427 -
branches/5.0/src/wp-includes/default-filters.php
r43732 r43738 492 492 // Script Loader 493 493 add_action( 'wp_default_scripts', 'wp_default_scripts' ); 494 add_action( 'wp_default_scripts', 'wp_default_packages' ); 495 494 496 add_action( 'wp_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 ); 495 497 add_action( 'admin_enqueue_scripts', 'wp_localize_jquery_ui_datepicker', 1000 ); -
branches/5.0/src/wp-includes/script-loader.php
r43723 r43738 42 42 * @param WP_Scripts $scripts WP_Scripts object. 43 43 */ 44 function wp_register_tinymce_scripts( &$scripts ) {44 function wp_register_tinymce_scripts( &$scripts, $force_uncompressed = false ) { 45 45 global $tinymce_version, $concatenate_scripts, $compress_scripts; 46 46 $suffix = SCRIPT_DEBUG ? '' : '.min'; 47 48 script_concat_settings(); 49 47 50 $compressed = $compress_scripts && $concatenate_scripts && isset( $_SERVER['HTTP_ACCEPT_ENCODING'] ) 48 && false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ); 51 && false !== stripos( $_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip' ) && ! $force_uncompressed; 52 49 53 // Load tinymce.js when running from /src, otherwise load wp-tinymce.js.gz (in production) or 50 54 // tinymce.min.js (when SCRIPT_DEBUG is true). … … 53 57 $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.php', array(), $tinymce_version ); 54 58 } else { 55 $scripts->add( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce {$mce_suffix}.js", array(), $tinymce_version );56 $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . "plugins/compat3x/plugin {$suffix}.js", array( 'wp-tinymce-root' ), $tinymce_version );57 } 58 59 $scripts->add( 'wp-tinymce-lists', includes_url( 'js/tinymce/plugins/lists/index' . $suffix . '.js', array( 'wp-tinymce' ), $tinymce_version ) );59 $scripts->add( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce$mce_suffix.js", array(), $tinymce_version ); 60 $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . "plugins/compat3x/plugin$suffix.js", array( 'wp-tinymce-root' ), $tinymce_version ); 61 } 62 63 $scripts->add( 'wp-tinymce-lists', includes_url( "js/tinymce/plugins/lists/plugin$suffix.js", array( 'wp-tinymce' ), $tinymce_version ) ); 60 64 } 61 65 … … 70 74 * @param WP_Scripts $scripts WP_Scripts object. 71 75 */ 72 function wp_default_packages_vendor( &$scripts , $dev_suffix) {76 function wp_default_packages_vendor( &$scripts ) { 73 77 wp_register_tinymce_scripts( $scripts ); 78 79 $dev_suffix = wp_scripts_get_suffix( 'dev' ); 74 80 75 81 $vendor_scripts = array( … … 91 97 } 92 98 93 $path = '/js/dist/vendor/' . $handle . $dev_suffix . '.js';99 $path = "/js/dist/vendor/$handle$dev_suffix.js"; 94 100 95 101 $scripts->add( $handle, $path, $dependencies, false, 1 ); … … 125 131 * @return string Conditional polyfill inline script. 126 132 */ 127 function wp_get_script_polyfill( $scripts, $tests ) {133 function wp_get_script_polyfill( &$scripts, $tests ) { 128 134 $polyfill = ''; 129 135 foreach ( $tests as $test => $handle ) { … … 148 154 149 155 /** 150 * Register all the WordPress packages scripts that are in the standardized156 * Registers all the WordPress packages scripts that are in the standardized 151 157 * `js/dist/` location. 152 158 * … … 156 162 * 157 163 * @param WP_Scripts $scripts WP_Scripts object. 158 * @param string $suffix The suffix to use before `.js`. 159 */ 160 function wp_default_packages_scripts( &$scripts, $suffix ) { 164 */ 165 function wp_default_packages_scripts( &$scripts ) { 166 $suffix = wp_scripts_get_suffix(); 167 161 168 $packages_dependencies = array( 162 169 'api-fetch' => array( 'wp-polyfill', 'wp-hooks', 'wp-i18n' ), … … 331 338 foreach ( $packages_dependencies as $package => $dependencies ) { 332 339 $handle = 'wp-' . $package; 333 $path = '/js/dist/' . $package . $suffix . '.js';340 $path = "/js/dist/$package$suffix.js"; 334 341 335 342 $scripts->add( $handle, $path, $dependencies, false, 1 ); … … 423 430 ); 424 431 432 /* This filter is documented in wp-includes/class-wp-editor.php */ 425 433 $tinymce_settings = apply_filters( 426 434 'tiny_mce_before_init', … … 429 437 ',', 430 438 array_unique( 439 /* This filter is documented in wp-includes/class-wp-editor.php */ 431 440 apply_filters( 432 441 'tiny_mce_plugins', … … 457 466 ',', 458 467 array_merge( 468 /* This filter is documented in wp-includes/class-wp-editor.php */ 459 469 apply_filters( 460 470 'mce_buttons', … … 482 492 'toolbar2' => implode( 483 493 ',', 494 /* This filter is documented in wp-includes/class-wp-editor.php */ 484 495 apply_filters( 485 496 'mce_buttons_2', … … 500 511 ) 501 512 ), 513 /* This filter is documented in wp-includes/class-wp-editor.php */ 502 514 'toolbar3' => implode( ',', apply_filters( 'mce_buttons_3', array(), 'editor' ) ), 515 /* This filter is documented in wp-includes/class-wp-editor.php */ 503 516 'toolbar4' => implode( ',', apply_filters( 'mce_buttons_4', array(), 'editor' ) ), 517 /* This filter is documented in wp-includes/class-wp-editor.php */ 504 518 'external_plugins' => apply_filters( 'mce_external_plugins', array() ), 505 519 ), … … 526 540 527 541 /** 542 * Registers all the WordPress packages scripts. 543 * 544 * @since 5.0.0 545 * 546 * @param WP_Scripts $scripts WP_Scripts object. 547 */ 548 function wp_default_packages( &$scripts ) { 549 wp_default_packages_vendor( $scripts ); 550 wp_register_tinymce_scripts( $scripts ); 551 wp_default_packages_scripts( $scripts ); 552 553 if ( did_action( 'init' ) ) { 554 wp_default_packages_inline_scripts( $scripts ); 555 } 556 } 557 558 /** 559 * Returns the suffix that can be used for the scripts. 560 * 561 * There are two suffix types, the normal one and the dev suffix. 562 * 563 * @since 5.0.0 564 * 565 * @param string $type The type of suffix to retrieve. 566 * @return string The script suffix. 567 */ 568 function wp_scripts_get_suffix( $type = '' ) { 569 static $suffixes; 570 571 if ( $suffixes === null ) { 572 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 573 574 $develop_src = false !== strpos( $wp_version, '-src' ); 575 576 if ( ! defined( 'SCRIPT_DEBUG' ) ) { 577 define( 'SCRIPT_DEBUG', $develop_src ); 578 } 579 $suffix = SCRIPT_DEBUG ? '' : '.min'; 580 $dev_suffix = $develop_src ? '' : '.min'; 581 582 $suffixes = array( 'suffix' => $suffix, 'dev_suffix' => $dev_suffix ); 583 } 584 585 if ( $type === 'dev' ) { 586 return $suffixes['dev_suffix']; 587 } 588 589 return $suffixes['suffix']; 590 } 591 592 /** 528 593 * Register all WordPress scripts. 529 594 * … … 537 602 */ 538 603 function wp_default_scripts( &$scripts ) { 539 include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version 540 541 $develop_src = false !== strpos( $wp_version, '-src' ); 542 543 if ( ! defined( 'SCRIPT_DEBUG' ) ) { 544 define( 'SCRIPT_DEBUG', $develop_src ); 545 } 604 $suffix = wp_scripts_get_suffix(); 605 $dev_suffix = wp_scripts_get_suffix( 'dev' ); 546 606 547 607 if ( ! $guessurl = site_url() ) { … … 555 615 $scripts->default_dirs = array('/wp-admin/js/', '/wp-includes/js/'); 556 616 557 $suffix = SCRIPT_DEBUG ? '' : '.min';558 $dev_suffix = $develop_src ? '' : '.min';559 617 560 618 $scripts->add( 'utils', "/wp-includes/js/utils$suffix.js" ); … … 613 671 $scripts->add( 'colorpicker', "/wp-includes/js/colorpicker$suffix.js", array('prototype'), '3517m' ); 614 672 615 $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array(' utils','jquery'), false, 1 );673 $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array('wp-tinymce','utils','jquery'), false, 1 ); 616 674 617 675 // Back-compat for old DFW. To-do: remove at the end of 2016. … … 1129 1187 $scripts->add( 'wp-api', "/wp-includes/js/wp-api$suffix.js", array( 'jquery', 'backbone', 'underscore', 'wp-api-request' ), false, 1 ); 1130 1188 1131 wp_default_packages_vendor( $scripts, $dev_suffix );1132 wp_default_packages_scripts( $scripts, $suffix );1133 if ( did_action( 'init' ) ) {1134 wp_default_packages_inline_scripts( $scripts );1135 }1136 1137 1189 if ( is_admin() ) { 1138 1190 $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 ); -
branches/5.0/tests/phpunit/tests/dependencies/scripts.php
r41994 r43738 11 11 $this->old_wp_scripts = isset( $GLOBALS['wp_scripts'] ) ? $GLOBALS['wp_scripts'] : null; 12 12 remove_action( 'wp_default_scripts', 'wp_default_scripts' ); 13 remove_action( 'wp_default_scripts', 'wp_default_packages' ); 13 14 $GLOBALS['wp_scripts'] = new WP_Scripts(); 14 15 $GLOBALS['wp_scripts']->default_version = get_bloginfo( 'version' ); -
branches/5.0/tools/webpack/media.js
r43719 r43738 12 12 13 13 module.exports = function( env = { environment: 'production', watch: false } ) { 14 const mode = env.environment;15 14 16 15 const mediaConfig = { 17 mode ,16 mode: "production", 18 17 cache: true, 19 18 entry: mediaEntries,
Note: See TracChangeset
for help on using the changeset viewer.