This ensures the filters to opt in to loading separate block styles on demand are added at the moment `WP_Styles` is constructed. This accounts for styles being registered at the `init` action before `register_core_block_style_handles()` runs at priority 9. Without this, the `wp-block-library` stylesheet may get registered with the full combined block styles as `style.css` instead of just `common.css`, due to `wp_should_load_block_assets_on_demand()` still returning false. The `wp_default_styles` action still runs during `init`.
Developed in https://github.com/WordPress/wordpress-develop/pull/11232
Follow-up to r61008.
Props westonruter, adamsilverstein.
See #64099.
Fixes#64846.
Built from https://develop.svn.wordpress.org/trunk@61981
git-svn-id: http://core.svn.wordpress.org/trunk@61263 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This introduces placeholder inline `STYLE` tags in the `HEAD` which are used to accurately locate hoisted styles which were printed in the footer. This improves the robustness of the hoisting logic. A style placeholder had been used previously in the inline style for `wp-block-library` for placing core block styles, and new placeholders are added for global styles and non-core block styles.
Furthermore, this fixes the cascade for inline styles added to `wp-block-library`. When separate block styles are not used, these styles would have appeared after the single combined `wp-block-library`. However, in 6.9 the order changed so that separate block styles would appear after. To preserve the original cascade, this splits the `wp-block-library` inline style: the first half (likely just the inlined `block-library/common.css`) appears before the block styles, and the remainder appears in a new `STYLE#wp-block-library-inline-css-extra` element.
Developed in https://github.com/WordPress/wordpress-develop/pull/10875
Follow-up to r61554, r61174, r61122, r61076, r61008.
Props westonruter, joefusco, adamsilverstein, ocean90, mmorris8, ozgursar, vanonsopensource, xwolf, immeet94, george9, joezappie, jorbin, sajib1223, sabernhardt.
See #64099, #64354, #64150, #43258.
Fixes#64389.
Built from https://develop.svn.wordpress.org/trunk@61945
git-svn-id: http://core.svn.wordpress.org/trunk@61227 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Bring over the changes required to implement client side media in core. This feature recently graduated from experiments and is ready for testing in beta.
Props adamsilverstein, westonruter, mamaduka, mukesh27, swissspidy, andrewserong, ellatrix, ramonjd.
Fixes#62243.
Built from https://develop.svn.wordpress.org/trunk@61703
git-svn-id: http://core.svn.wordpress.org/trunk@61011 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Adds the admin-scheme styles as a dependency for the login and install styles. This is to ensure the CSS variables are available to the login, installation, database repair and upgrade screens.
Modifies the display of notices in the login styles to match those in the new default scheme, "modern".
Props peterwilsoncc, wildworks, westonruter, mukesh27, fabiankaegy, audrasjb, huzaifaalmesbah, sabernhardt, presskopp, SirLouen, ellatrix, nendeb55, neo2k23, jsmansart, joedolson.
Fixes#64640, #64548. See #64308.
Built from https://develop.svn.wordpress.org/trunk@61681
git-svn-id: http://core.svn.wordpress.org/trunk@60989 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Rename the 'Modern' color scheme to 'Default' and the previous 'Default' scheme to 'Fresh'. Update all fallback references from 'fresh' to 'modern' across admin headers, the Customizer, the color scheme picker, the script loader, and user functions.
Add an upgrade routine in `upgrade_700()` to migrate existing users with the 'fresh' admin color to 'modern'.
Props fabiankaegy, audrasjb, mukesh27, westonruter, peterwilsoncc, jorbin, sabernhardt, joedolson, phpbits.
Fixes#64546.
Built from https://develop.svn.wordpress.org/trunk@61644
git-svn-id: http://core.svn.wordpress.org/trunk@60955 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Esprima is no longer maintained, and it does not support the latest JavaScript features in ES11, as Espree does.
- **New Linter Integration:** Introduces `src/js/_enqueues/vendor/codemirror/javascript-lint.js` using `espree` for parsing and error reporting, replacing the dependency on `jshint` and `esprima` scripts.
- **Script Modules:** Registers `espree` as a script module and leverages the `module_dependencies` argument in `wp_register_script()` to ensure `espree` is available as a dynamic import.
- **Editor Settings:** Updates `wp_get_code_editor_settings()` to use ES11 (ECMAScript 2020) defaults and synchronizes JSHint settings from `.jshintrc` for compatibility.
- **Editable Extensions:** Adds `.mjs` to the list of editable file extensions for plugins and themes.
- **Deprecations:** Marks `esprima` and `jshint` script handles as deprecated.
- **Build Tools:** Updates Webpack configuration to bundle `espree` as a module and use the new local `javascript-lint.js`.
Developed in https://github.com/WordPress/wordpress-develop/pull/10806
Follow-up to [61587], [61544], [61539], [42547].
Props westonruter, jonsurrell.
See #64562, #61500, #48456, #42850.
Fixes#64558.
Built from https://develop.svn.wordpress.org/trunk@61611
git-svn-id: http://core.svn.wordpress.org/trunk@60922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This refactors `wp_hoist_late_printed_styles()` to strictly preserve the classic theme CSS cascade when moving styles from `wp_footer` to the `HEAD`. Previously, hoisted styles were appended in an order closer to the CSS cascade for block themes, potentially causing specificity issues for CSS selectors written for the previous cascade. This is intended to eliminate the need for sites which upgraded to 6.9 to apply a hotfix involving `add_filter( 'should_load_separate_core_block_assets', '__return_false' )` to disable the optimization.
Key changes:
* Identifies styles enqueued during `enqueue_block_assets`.
* Separates core block styles from third-party block styles.
* Inserts core block styles immediately after `wp-block-library`.
* Inserts third-party block styles after `classic-theme-styles`.
* Inserts `global-styles` after all `enqueue_block_assets` styles.
This ensures the following order is maintained:
1. Core block library.
2. Core block styles.
3. Classic theme styles.
4. Third-party block styles.
5. Global styles.
Developed in https://github.com/WordPress/wordpress-develop/pull/10601
Follow-up to [61174], [61122], [61076], [61008].
Props westonruter, wildworks, jorbin, peterwilsoncc, sabernhardt, audrasjb, pmbs, threadi, madhavishah01, raftaar1191, noruzzaman, ozgursar.
See #64099, #64150, #43258.
Fixes#64354.
Built from https://develop.svn.wordpress.org/trunk@61554
git-svn-id: http://core.svn.wordpress.org/trunk@60865 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This installs npm packages for `codemirror`, `csslint`, `esprima`, `htmlhint`, and `jsonlint` to replace the libraries which had been copied into SVN. A new `grunt build:codemirror` task is responsible for building CodeMirror as part of the build process. This finally revisits the original CodeMirror integration which was originally developed in the [https://github.com/WordPress/better-code-editing/ Better Code Editing] feature plugin in 2017.
||= Package =||= Old Version =||= New Version =||
|| codemirror || 5.29.1-alpha-ee20357 || 5.65.20 ||
|| esprima || 4.0.0 || 4.0.1 ||
|| jsonlint || 1.6.2 || 1.6.3 ||
|| htmlhint || 0.9.14-xwp || 1.8.0 ||
Follow-up to [41376].
Props westonruter, jonsurrell, tobiasbg, desrosj, adamsilverstein, WraithKenny, rafa8626, netweb.
See #12423.
Fixes#48456, #41870.
Built from https://develop.svn.wordpress.org/trunk@61539
git-svn-id: http://core.svn.wordpress.org/trunk@60850 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Introduce the `wp-base-styles` stylesheet handle to provide admin color scheme CSS custom properties across WordPress. This stylesheet is added as a dependency for:
- The `wp-admin` styles bundle
- The block editor content iframe styles
This is the Core-side implementation of the changes from Gutenberg PRs #69128 and #69130, which consolidate the admin color scheme CSS custom properties into a single reusable stylesheet instead of duplicating them across multiple packages.
See #64308.
Props fabiankaegy, wildworks.
Built from https://develop.svn.wordpress.org/trunk@61517
git-svn-id: http://core.svn.wordpress.org/trunk@60828 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset improves the Gutenberg build integration to simplify the developer workflow and reinstore a flow similar to how package dependencies worked before the Gutenberg checkout-and-build approach was introduced.
Key improvements:
* Automatic rebuild on ref change: Adds a new `gutenberg:sync` script that stores a hash of the built ref in `.gutenberg-hash` and only rebuilds when the ref changes.
* Full integration on `npm install`: Running `npm install` now produces a fully working development environment with Gutenberg assets in `src/`.
* Clean Gutenberg checkout: Restores Gutenberg's `package.json` after the build completes.
* Stops copying `.js.map` files to `wp-includes/js/dist` since they reference non-existent paths.
* Remove package.json files from the build folder.
* Avoid closures and use prefixed functions.
* Updates build checks to use `jquery.js` instead of `edit-post.js` as the build indicator.
Props youknowriad, ellatrix, mcsf, dmsnell, ntsekouras, jorgefilipecosta, tobiasbg, peterwilsoncc.
Fixes#64393.
Built from https://develop.svn.wordpress.org/trunk@61492
git-svn-id: http://core.svn.wordpress.org/trunk@60803 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset enables smooth transitions between the different admin screens. For the admin menu items, distinct view transition names are used to facilitate a simple visual slide effect when the active submenu changes between screens.
Props westonruter, mukesh27, joedolson.
Fixes#64470.
Built from https://develop.svn.wordpress.org/trunk@61491
git-svn-id: http://core.svn.wordpress.org/trunk@60802 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Script tags have complicated and unintuitive parsing rules that make them difficult to author correctly. The HTML API automatically escapes script tag contents as necessary and will set attributes correctly. Using the HTML API to generate SCRIPT tags improves safety when working with SCRIPT tags, resolving a class of issues that have manifested repeatedly.
Changeset [61418] applied the HTML API to generate style tags in a similar way.
Developed in https://github.com/WordPress/wordpress-develop/pull/10639.
Props jonsurrell, dmsnell, westonruter.
Fixes#64500. See #64419, #40737, #62797, #63851, #51159.
Built from https://develop.svn.wordpress.org/trunk@61485
git-svn-id: http://core.svn.wordpress.org/trunk@60797 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Restores the `$is_block_theme` check that was inadvertently removed in [61473]. This ensures that for classic themes, the Customizer's Additional CSS continues to be printed separately via `wp_custom_css_cb()` at priority 101 in `wp_head`, preserving its position at the end of the `<head>` for highest CSS specificity.
Follow-up to [61473].
Props westonruter.
Fixes#64408.
Built from https://develop.svn.wordpress.org/trunk@61479
git-svn-id: http://core.svn.wordpress.org/trunk@60791 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Enable Global Styles functionality in classic WordPress themes, allowing features like the Font Library to work without requiring a theme.json file.
This change:
- Removes restrictions that prevented classic themes from accessing Global Styles features.
- Enables font functionality in classic themes through the Font Library.
- Fixes Fonts menu not appearing in classic themes by changing its submenu index to avoid collision with Widgets.
Props youknowriad, isabel_brison, ramonopoly.
Fixes#64408.
Built from https://develop.svn.wordpress.org/trunk@61473
git-svn-id: http://core.svn.wordpress.org/trunk@60785 1a063a9b-81f0-0310-95a4-ce76da25c4cd
* The skip link now works when JavaScript is turned off.
* By removing the script, the amount of JavaScript sent to the client is reduced for a very marginal performance improvement.
* A new `wp-block-template-skip-link` stylesheet is registered, with minification and `path` data for inlining.
* The CSS for the skip link now has an RTL version generated, although it is not yet served when the styles are inlined. See #61625.
* The `wp_enqueue_block_template_skip_link()` function now exclusively enqueues the stylesheet since the script is removed.
* For backwards-compatibility, the skip link will continue to be omitted if `the_block_template_skip_link()` is unhooked from the `wp_footer` action or `wp_enqueue_block_template_skip_link()` is unhooked from `wp_enqueue_scripts`.
Developed in https://github.com/WordPress/wordpress-develop/pull/10676
Follow-up to [56932], [51003].
Props rutviksavsani, westonruter, dmsnell, whiteshadow01, Slieptsov.
See #59505, #53176.
Fixes#64361.
Built from https://develop.svn.wordpress.org/trunk@61469
git-svn-id: http://core.svn.wordpress.org/trunk@60781 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changes WordPress Core's Gutenberg integration from npm packages to checking out and building Gutenberg directly. Instead of syncing individual npm packages, Core now checks out the Gutenberg repository, builds it, and copies the build artifacts.
This enables Core to use Gutenberg's advanced features like route-based navigation, full-page rendering, and the Font Library, while also streamlining future updates.
New commands:
* `npm run gutenberg:checkout` - Clones Gutenberg at a specified ref
* `npm run gutenberg:build` - Runs Gutenberg's build process
* `npm run gutenberg:copy` - Copies and transforms build output to Core
* `npm run gutenberg:integrate` - Runs all three steps
Main changes:
* Removes webpack configs replaced by Gutenberg's build (blocks.js, packages.js, script-modules.js, development.js, vendors.js)
* Adds Font Library page (`/wp-admin/font-library.php`)
* Adds copy scripts to transform Gutenberg plugin paths to Core paths
* Moves vendor copy step from webpack to Gruntfile
New year, new process. Happy New Year!
Props youknowriad, ellatrix, sirreal, westonruter, desrosj, tellthemachines.
Fixes#64393.
Built from https://develop.svn.wordpress.org/trunk@61438
git-svn-id: http://core.svn.wordpress.org/trunk@60750 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The HTML API escapes `<style>` tag contents to ensure the correct HTML structure. Common HTML escaping is unsuitable for `<style>` tags because they contain "raw text." The additional safety allows other restrictions, such as rejecting content with `<>`, to be relaxed or removed because the resulting tag will be well-formed.
Developed in https://github.com/WordPress/wordpress-develop/pull/10656.
Props jonsurrell, westonruter, dmsnell, ramonopoly, soyebsalar01, drw158, sabernhardt.
See #64418.
Built from https://develop.svn.wordpress.org/trunk@61418
git-svn-id: http://core.svn.wordpress.org/trunk@60730 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This aims to avoid PHP warnings if the `colors` dependency is loaded or the `style_loader_src` filter is used in a context where the `$_wp_admin_css_colors` global does not exist.
Follow-up to [7976].
Props crstauf, petitphp, SergeyBiryukov.
Fixes#61302.
Built from https://develop.svn.wordpress.org/trunk@61388
git-svn-id: http://core.svn.wordpress.org/trunk@60700 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Replace regex-based HTML parsing with WP_HTML_Tag_Processor to properly extract text nodes from menu labels. This ensures only root-level text nodes are
collected.
Additionally, replace html_entity_decode() with WP_HTML_Decoder::decode_attribute() with the menu URL for consistent attribute decoding.
Follow-up to [61124], [61126], [61127], [61142].
Props: dmsnell, madhavishah01, peterwilsoncc, wildworks.
Fixes#64233.
Built from https://develop.svn.wordpress.org/trunk@61310
git-svn-id: http://core.svn.wordpress.org/trunk@60622 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This ensures that on-demand block styles are inserted right after the `wp-block-library` inline style whereas other stylesheets not related to blocks are appended to the end of the `HEAD`. This helps ensure the expected cascade is preserved. If no `wp-block-library` inline style is present, then all styles get appended to the `HEAD` regardless.
The handling of the CSS placeholder comment added to the `wp-block-library` inline style is also improved. It is now inserted later to ensure the inline style is printed. Additionally, when the CSS placeholder comment is removed from the `wp-block-library` inline style, the entire `STYLE` tag is now removed if there are no styles left (aside from the `sourceURL` comment).
Lastly, the use of the HTML Tag Processor is significantly improved to leverage `WP_HTML_Text_Replacement`.
Developed in https://github.com/WordPress/wordpress-develop/pull/10436
Follow-up to [61008].
Props westonruter, peterwilsoncc, dmsnell.
Fixes#64099.
Built from https://develop.svn.wordpress.org/trunk@61174
git-svn-id: http://core.svn.wordpress.org/trunk@60510 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Reverts [61126] and [61127], which introduced a bug where the command palette is not stripping numbers. `HTML_Tag_Processor` cannot replace the REGEX yet.
Unprops cbravobernal.
Follow-up to [61126], [61127].
Props wildworks, tusharaddweb.
See #64196.
Built from https://develop.svn.wordpress.org/trunk@61142
git-svn-id: http://core.svn.wordpress.org/trunk@60478 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This reverts part of [61076] which made `wp-block-styles` theme support a precondition for opting in to `should_load_separate_core_block_assets` and `should_load_block_assets_on_demand`. This meant that the Twenty Twenty theme (and other themes without this support declared) would not benefit from on-demand block style loading. Nevertheless, even though such themes were not getting block styles loaded on demand, the `wp_load_classic_theme_block_styles_on_demand()` function was proceeding to opt in to the output buffer for hoisting late-printed styles, even though it was unlikely there would then be any. This meant the template enhancement output buffer was being opened for no reason.
Enabling on-demand block style loading is measured to improve FCP and LCP in Twenty Twenty, for example a ~13% improvement over a Fast 4G connection when loading the Sample Page.
Developed in https://github.com/WordPress/wordpress-develop/pull/10457
Follow-up to [61008], [61076], [60936].
Props westonruter.
See #64099, #64150, #64166, #43258.
Built from https://develop.svn.wordpress.org/trunk@61122
git-svn-id: http://core.svn.wordpress.org/trunk@60458 1a063a9b-81f0-0310-95a4-ce76da25c4cd
To prevent the registration of commands that would cause a 404 error in the network admin screen, pass the result of the `is_network_admin()` check to the command palette initialization function.
Follow-up to [61022].
Props jorbin, ntsekouras, soean, tobiasbg
Fixes#64125.
Built from https://develop.svn.wordpress.org/trunk@61121
git-svn-id: http://core.svn.wordpress.org/trunk@60457 1a063a9b-81f0-0310-95a4-ce76da25c4cd
In [61013] the CSS inline limit was increased from 20K to 50K. However, based on benchmarking the performance improvements of increasing the limit, the relative improvement from 40K to 50K is not as great as from 30K to 40K. The performance improvements start to flatten out beginning at 40K. This 40K is still double the previous limit of 20K. Being more conservative will allow for a more gradual impact to be observed before considering a larger increase. Furthermore, the 50K limit of inline CSS can cause the oEmbed discovery links to be positioned after the first 150K bytes which prevents them from being discovered. See #64178.
Follow-up to [61013].
Props westonruter, mukesh27, szepeviktor.
See #64178.
Fixes#63018.
Built from https://develop.svn.wordpress.org/trunk@61117
git-svn-id: http://core.svn.wordpress.org/trunk@60453 1a063a9b-81f0-0310-95a4-ce76da25c4cd
When the `wp-block-library` stylesheet is not enqueued, there will be no associated inline style present. This inline style normally contains the placeholder CSS comment for the HTML Tag Processor to identify the token after which the late-printed styles should be inserted. However, when the `wp-block-library` stylesheet is not enqueued (such as in themes which do not use blocks), or else the inline style is not printed for whatever reason, this adds a fallback to insert the late-printed styles immediately before `</head>`. This ensures that late-printed styles will always get hoisted.
Developed in https://github.com/WordPress/wordpress-develop/pull/10417
Follow-up to [61008].
Props westonruter, peterwilsoncc, Soean.
See #64099, #43258.
Fixes#64150.
Built from https://develop.svn.wordpress.org/trunk@61076
git-svn-id: http://core.svn.wordpress.org/trunk@60412 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Benchmarking of initial page loads versus repeat page loads shows there is a greater performance improvement to increase inlining versus the benefits of relying on browser cache.
This new limit is expected to be further refined during beta based on additional testing.
Props westonruter, sabernhardt, poena, aristath, spacedmonkey, adamsilverstein, jonoaldersonwp, peterwilsoncc.
See #63007.
Fixes#63018.
Built from https://develop.svn.wordpress.org/trunk@61013
git-svn-id: http://core.svn.wordpress.org/trunk@60349 1a063a9b-81f0-0310-95a4-ce76da25c4cd
* This applies in classic themes when a site has not opted out of the template enhancement buffer by filtering `wp_should_output_buffer_template_for_enhancement` off.
* Both `should_load_separate_core_block_assets` and `should_load_block_assets_on_demand` are filtered on, as otherwise they are only enabled by default in block themes.
* Any style enqueued after `wp_head` and printed via `print_late_styles()` will get hoisted up to be inserted right after the `wp-block-library` inline style in the `HEAD`.
* The result is a >10% benchmarked improvement in LCP for core classic themes due to a ~100KB reduction in the amount of CSS unconditionally being served with every page load.
Developed in https://github.com/WordPress/wordpress-develop/pull/10288
Follow-up to [60936].
Props sjapaget, westonruter, peterwilsoncc, dmsnell, mindctrl.
See #43258.
Fixes#64099.
Built from https://develop.svn.wordpress.org/trunk@61008
git-svn-id: http://core.svn.wordpress.org/trunk@60344 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This patch introduces two new functions: `wp_js_dataset_name()` and `wp_html_custom_data_attribute_name()`. Together, these provide reliable mapping between the HTML attribute names for custom data attributes, and the properties found in JavaScript for a given `HTMLElement`’s `.dataset` property.
These are to be used where matching names is important, such as in the Interactivity API and when WordPress is deciding whether or not to allow an attribute as a custom data attribute.
Developed in https://github.com/WordPress/wordpress-develop/pull/9953
Discussed in https://core.trac.wordpress.org/ticket/61501
Props dmsnell, westonruter.
See #61501.
Built from https://develop.svn.wordpress.org/trunk@61007
git-svn-id: http://core.svn.wordpress.org/trunk@60343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Remove the ability to enqueue scripts and styles wrapped in IE conditional comment tags. Conditional comment support was removed from IE in version 10 in 2012, and no core supported browser renders them in any way. IE9 has global usage approaching zero. WordPress dropped support for IE10 and below in version 4.8.
Patch adds a deprecation notice if the conditional data argument is added. Scripts and styles are not printed, and neither are their dependencies if they are not required by other non-conditional scripts. Conditional dependencies are removed from core enqueues.
Props jonsurrell, joedolson, shailu25, siliconforks, dmsnell, sabernhardt, rollybueno.
Fixes#63821.
Built from https://develop.svn.wordpress.org/trunk@60948
git-svn-id: http://core.svn.wordpress.org/trunk@60284 1a063a9b-81f0-0310-95a4-ce76da25c4cd
For inline styles which had been inlined from registered external stylesheets via `wp_maybe_inline_styles()`, this defers to using the original stylesheet URL for the `sourceURL` as opposed to fabricating one from the stylesheet handle. This makes the `sourceURL` much more useful for debugging, as it indicates where the stylesheet is located. This allows a developer to make a change to the CSS more easily.
Developed in https://github.com/WordPress/wordpress-develop/pull/10177.
Follow-up to [50836].
Props westonruter, mukesh27, gziolo.
See #50328, #52620.
Fixes#63887.
Built from https://develop.svn.wordpress.org/trunk@60920
git-svn-id: http://core.svn.wordpress.org/trunk@60256 1a063a9b-81f0-0310-95a4-ce76da25c4cd