Changeset 64320
- Timestamp:
- 10/13/2026 04:12:29 AM (6 days ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
src/wp-includes/class-wp-editor.php (modified) (1 diff)
-
src/wp-includes/script-loader.php (modified) (5 diffs)
-
tests/phpunit/tests/dependencies/scripts.php (modified) (5 diffs)
-
tests/phpunit/tests/dependencies/wpShouldConcatenateAdminScripts.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-editor.php
r64304 r64320 1542 1542 1543 1543 $wp_scripts->remove( 'wp-tinymce' ); 1544 wp_register_tinymce_scripts( $wp_scripts , true);1544 wp_register_tinymce_scripts( $wp_scripts ); 1545 1545 } 1546 1546 -
trunk/src/wp-includes/script-loader.php
r64235 r64320 5 5 * Several constants are used to manage the loading, concatenating and compression of scripts and CSS: 6 6 * define('SCRIPT_DEBUG', true); loads the development (non-minified) versions of all scripts and CSS, and disables compression and concatenation, 7 * define('CONCATENATE_SCRIPTS', false); disables compression and concatenation of scripts and CSS,7 * define('CONCATENATE_SCRIPTS', true); enables concatenation of scripts and CSS in the admin and on the login screen (disabled by default), 8 8 * define('COMPRESS_SCRIPTS', false); disables compression of scripts, 9 9 * define('COMPRESS_CSS', false); disables compression of CSS, … … 38 38 * Registers TinyMCE scripts. 39 39 * 40 * TinyMCE core and the compat3x plugin are registered as separate files. TinyMCE loads its theme 41 * and any other plugins itself when an editor is initialized. The `wp-tinymce.js` bundle of all of 42 * them is no longer registered, but it can still be registered in their place under the 43 * `wp-tinymce` handle. 44 * 40 45 * @since 5.0.0 46 * @since 7.2.0 The `wp-tinymce.js` bundle is no longer registered, regardless of whether scripts 47 * are concatenated or compressed. 48 * @since 7.2.0 The `$force_uncompressed` parameter was deprecated and renamed to `$deprecated`. 41 49 * 42 50 * @global string $tinymce_version 43 * @global bool $concatenate_scripts 44 * @global bool $compress_scripts 45 * 46 * @param WP_Scripts $scripts WP_Scripts object. 47 * @param bool $force_uncompressed Whether to forcibly prevent gzip compression. Default false. 48 */ 49 function wp_register_tinymce_scripts( $scripts, $force_uncompressed = false ) { 50 global $tinymce_version, $concatenate_scripts, $compress_scripts; 51 * 52 * @param WP_Scripts $scripts WP_Scripts object. 53 * @param bool $deprecated Not used. 54 * 55 * @phpstan-param false $deprecated 56 */ 57 function wp_register_tinymce_scripts( $scripts, $deprecated = false ): void { 58 global $tinymce_version; 59 60 if ( false !== $deprecated ) { 61 _deprecated_argument( __FUNCTION__, '7.2.0' ); 62 } 51 63 52 64 $suffix = wp_scripts_get_suffix(); 53 65 $dev_suffix = wp_scripts_get_suffix( 'dev' ); 54 66 67 /* 68 * This no longer depends on the concatenation settings, but it is where an admin screen has 69 * settled them until now, which the 'wp_should_concatenate_admin_scripts' filter documents. 70 */ 55 71 script_concat_settings(); 56 72 57 $compressed = $compress_scripts && $concatenate_scripts && ! $force_uncompressed; 58 59 /* 60 * Load tinymce.js when running from /src, otherwise load wp-tinymce.js (in production) 61 * or tinymce.min.js (when SCRIPT_DEBUG is true). 62 */ 63 if ( $compressed ) { 64 $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . 'wp-tinymce.js', array(), $tinymce_version ); 65 } else { 66 $scripts->add( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce$dev_suffix.js", array(), $tinymce_version ); 67 $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . "plugins/compat3x/plugin$dev_suffix.js", array( 'wp-tinymce-root' ), $tinymce_version ); 68 } 73 // Load tinymce.js when running from /src, otherwise tinymce.min.js. 74 $scripts->add( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce$dev_suffix.js", array(), $tinymce_version ); 75 $scripts->add( 'wp-tinymce', includes_url( 'js/tinymce/' ) . "plugins/compat3x/plugin$dev_suffix.js", array( 'wp-tinymce-root' ), $tinymce_version ); 69 76 70 77 $scripts->add( 'wp-tinymce-lists', includes_url( "js/tinymce/plugins/lists/plugin$suffix.js" ), array( 'wp-tinymce' ), $tinymce_version ); … … 2499 2506 * Determines whether scripts and styles are concatenated on admin screens and the login screen. 2500 2507 * 2501 * Concatenation is o n unless the `CONCATENATE_SCRIPTS` constant turns it off, and `SCRIPT_DEBUG`2508 * Concatenation is off unless the `CONCATENATE_SCRIPTS` constant turns it on, and `SCRIPT_DEBUG` 2502 2509 * turns it off regardless. Scripts and styles are never concatenated elsewhere. 2503 2510 * … … 2516 2523 */ 2517 2524 function wp_should_concatenate_admin_scripts(): bool { 2518 $concatenate = ( defined( 'CONCATENATE_SCRIPTS' ) ? (bool) CONCATENATE_SCRIPTS : true )2525 $concatenate = ( defined( 'CONCATENATE_SCRIPTS' ) ? (bool) CONCATENATE_SCRIPTS : false ) 2519 2526 && ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ); 2520 2527 … … 2533 2540 * @since 7.2.0 2534 2541 * 2535 * @param bool $concatenate Whether scripts and styles are concatenated. Default true, unless the2536 * `CONCATENATE_SCRIPTS` constant is false or `SCRIPT_DEBUG` is true.2542 * @param bool $concatenate Whether scripts and styles are concatenated. Default false, unless the 2543 * `CONCATENATE_SCRIPTS` constant is true and `SCRIPT_DEBUG` is not. 2537 2544 */ 2538 2545 return (bool) apply_filters( 'wp_should_concatenate_admin_scripts', $concatenate ); -
trunk/tests/phpunit/tests/dependencies/scripts.php
r64120 r64320 37 37 38 38 /** 39 * @var mixed 40 */ 41 protected $old_compress_scripts; 42 43 /** 39 44 * @var WP_Styles 40 45 */ … … 55 60 $this->old_wp_styles = $GLOBALS['wp_styles'] ?? null; 56 61 $this->old_concatenate_scripts = $GLOBALS['concatenate_scripts'] ?? null; 62 $this->old_compress_scripts = $GLOBALS['compress_scripts'] ?? null; 57 63 remove_action( 'wp_default_scripts', 'wp_default_scripts' ); 58 64 remove_action( 'wp_default_scripts', 'wp_default_packages' ); … … 78 84 $GLOBALS['wp_styles'] = $this->old_wp_styles; 79 85 $GLOBALS['concatenate_scripts'] = $this->old_concatenate_scripts; 86 $GLOBALS['compress_scripts'] = $this->old_compress_scripts; 80 87 add_action( 'wp_default_scripts', 'wp_default_scripts' ); 81 88 parent::tear_down(); … … 3831 3838 */ 3832 3839 public function test_printing_tinymce_scripts() { 3833 global $wp_scripts; 3834 3835 wp_register_tinymce_scripts( $wp_scripts, true ); 3840 wp_register_tinymce_scripts( wp_scripts() ); 3836 3841 3837 3842 $actual = get_echo( 'wp_print_scripts', array( array( 'wp-tinymce' ) ) ); … … 3839 3844 $this->assertStringNotContainsString( 'async', $actual, 'TinyMCE should not have an async attribute.' ); 3840 3845 $this->assertStringNotContainsString( 'defer', $actual, 'TinyMCE should not have a defer attribute.' ); 3846 } 3847 3848 /** 3849 * Tests that TinyMCE is registered as separate files, never as the `wp-tinymce.js` bundle. 3850 * 3851 * @ticket 57548 3852 * 3853 * @covers ::wp_register_tinymce_scripts 3854 * 3855 * @dataProvider data_register_tinymce_scripts_unbundled 3856 * 3857 * @param bool $concatenate Value of the `$concatenate_scripts` global. 3858 * @param bool $compress Value of the `$compress_scripts` global. 3859 */ 3860 public function test_register_tinymce_scripts_unbundled( bool $concatenate, bool $compress ): void { 3861 global $concatenate_scripts, $compress_scripts; 3862 3863 $concatenate_scripts = $concatenate; 3864 $compress_scripts = $compress; 3865 3866 $wp_scripts = wp_scripts(); 3867 wp_register_tinymce_scripts( $wp_scripts ); 3868 3869 $root = $wp_scripts->query( 'wp-tinymce-root' ); 3870 $this->assertInstanceOf( _WP_Dependency::class, $root, 'Expected TinyMCE core to be registered.' ); 3871 $this->assertIsString( $root->src ); 3872 $this->assertMatchesRegularExpression( '#/js/tinymce/tinymce(\.min)?\.js$#', $root->src ); 3873 3874 $tinymce = $wp_scripts->query( 'wp-tinymce' ); 3875 $this->assertInstanceOf( _WP_Dependency::class, $tinymce, 'Expected the wp-tinymce handle to be registered.' ); 3876 $this->assertIsString( $tinymce->src ); 3877 $this->assertMatchesRegularExpression( '#/js/tinymce/plugins/compat3x/plugin(\.min)?\.js$#', $tinymce->src ); 3878 $this->assertSame( array( 'wp-tinymce-root' ), $tinymce->deps ); 3879 } 3880 3881 /** 3882 * Data provider for test_register_tinymce_scripts_unbundled(). 3883 * 3884 * @return array<non-falsy-string, array{ concatenate: bool, compress: bool }> 3885 */ 3886 public function data_register_tinymce_scripts_unbundled(): array { 3887 return array( 3888 'concatenated and compressed' => array( 3889 'concatenate' => true, 3890 'compress' => true, 3891 ), 3892 'concatenated only' => array( 3893 'concatenate' => true, 3894 'compress' => false, 3895 ), 3896 'compressed only' => array( 3897 'concatenate' => false, 3898 'compress' => true, 3899 ), 3900 'neither' => array( 3901 'concatenate' => false, 3902 'compress' => false, 3903 ), 3904 ); 3841 3905 } 3842 3906 -
trunk/tests/phpunit/tests/dependencies/wpShouldConcatenateAdminScripts.php
r64120 r64320 75 75 76 76 /** 77 * Tests the default when `CONCATENATE_SCRIPTS` is not defined, which is to concatenate unless 78 * `SCRIPT_DEBUG` is on. 77 * Tests the default when `CONCATENATE_SCRIPTS` is not defined, which is not to concatenate. 79 78 * 80 79 * @ticket 57548 … … 85 84 } 86 85 87 $this->assert Same( ! SCRIPT_DEBUG,wp_should_concatenate_admin_scripts() );86 $this->assertFalse( wp_should_concatenate_admin_scripts() ); 88 87 } 89 88 … … 97 96 add_filter( 'wp_should_concatenate_admin_scripts', array( $filter, 'filter' ) ); 98 97 99 $this->assertSame( ! SCRIPT_DEBUG && ( ! defined( 'CONCATENATE_SCRIPTS' ) || CONCATENATE_SCRIPTS ), wp_should_concatenate_admin_scripts() );98 $this->assertSame( ! SCRIPT_DEBUG && defined( 'CONCATENATE_SCRIPTS' ) && CONCATENATE_SCRIPTS, wp_should_concatenate_admin_scripts() ); 100 99 $this->assertSame( 1, $filter->get_call_count() ); 101 100
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)