This changeset introduces functions `wp_get_global_styles_custom_css()` and `wp_enqueue_global_styles_custom_css()`, which allow accessing and enqueuing custom CSS added via global styles.
Custom CSS via global styles is handled separately from custom CSS via the Customizer. If a site uses both features, the custom CSS from both sources will be loaded. The global styles custom CSS is then loaded after the Customizer custom CSS, so if there are any conflicts between the rules, the global styles take precedence.
Similarly to e.g. [55185], the result is cached in a non-persistent cache, except when `WP_DEBUG` is on to avoid interrupting the theme developer's workflow.
Props glendaviesnz, oandregal, ntsekouras, mamaduka, davidbaumwald, hellofromtonya, flixos90.
Fixes#57536.
Built from https://develop.svn.wordpress.org/trunk@55192
git-svn-id: http://core.svn.wordpress.org/trunk@54725 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Adds the polyfill script to the iframe to make the `inert` attribute work correctly in Firefox. This solves the problem that the site editor can operate on the block editor in Firefox even in browse mode.
Why?
The inert attribute is intended to render the element and its sub-tree elements `inert`, but Firefox doesn't support this attribute. For the `inert` attribute to work as intended in Firefox, even within an iframe, the script needs to be injected into the iframe as well as the global document.
References:
* [https://github.com/WordPress/gutenberg/pull/47398 Gutenberg PR 47398].
Follow-up to [53160].
Props wildworks, mamaduka, youknowriad.
Fixes#57552.
Built from https://develop.svn.wordpress.org/trunk@55181
git-svn-id: http://core.svn.wordpress.org/trunk@54714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset:
* Removes the `'wp-block-editor'` and `'wp-block-library'` from the iframe's stylesheet collection (i.e. `_wp_get_iframed_editor_assets()`).
* Adds the new `'wp-block-editor-content'` for the separate stylesheet to the list of editor (`'wp-edit-blocks'`) dependencies.
Why?
These PHP changes are part of the initiative to:
* Separate the content styles contained in the block editor package into a separate stylesheet.
* Avoid loading all block editor styles into the iframe.
References:
* [https://github.com/WordPress/gutenberg/pull/44298 Gutenberg PR 44298].
Follow-up to [53160], [50761].
Props ellatrix, youknowriad.
Fixes#57550.
Built from https://develop.svn.wordpress.org/trunk@55179
git-svn-id: http://core.svn.wordpress.org/trunk@54712 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The `get_default_block_editor_settings()` function included several pieces of data that are irrelevant for the purpose that `WP_Theme_JSON_Resolver` was calling it for, yet resulted in three database queries on page load that can be avoided.
This changeset introduces a new function `get_classic_theme_supports_block_editor_settings()` to takes responsibility of only the data needed in `WP_Theme_JSON_Resolver`, which now uses that function. This leads to a reduction of database queries and accordingly a performance improvement.
Props mamaduka, spacedmonkey, oandregal, flixos90, audrasjb, mukesh27.
Fixes#57547.
Built from https://develop.svn.wordpress.org/trunk@55146
git-svn-id: http://core.svn.wordpress.org/trunk@54679 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Adds `wp_theme_has_theme_json()` for public consumption, to replace the private internal Core-only `WP_Theme_JSON_Resolver::theme_has_support()` method. This new global function checks if a theme or its parent has a `theme.json` file.
For performance, results are cached as an integer `1` or `0` in the `'theme_json'` group with `'wp_theme_has_theme_json'` key. This is a non-persistent cache. Why? To make the derived data from `theme.json` is always fresh from the potential modifications done via hooks that can use dynamic data (modify the stylesheet depending on some option, settings depending on user permissions, etc.).
Also adds a new public function `wp_clean_theme_json_cache()` to clear the cache on `'switch_theme'` and `start_previewing_theme'`.
References:
* [https://github.com/WordPress/gutenberg/pull/45168 Gutenberg PR 45168] Add `wp_theme_has_theme_json` as a public API to know whether a theme has a `theme.json`.
* [https://github.com/WordPress/gutenberg/pull/45380 Gutenberg PR 45380] Deprecate `WP_Theme_JSON_Resolver:theme_has_support()`.
* [https://github.com/WordPress/gutenberg/pull/46150 Gutenberg PR 46150] Make `theme.json` object caches non-persistent.
* [https://github.com/WordPress/gutenberg/pull/45979 Gutenberg PR 45979] Don't check if constants set by `wp_initial_constants()` are defined.
* [https://github.com/WordPress/gutenberg/pull/45950 Gutenberg PR 45950] Cleaner logic in `wp_theme_has_theme_json`.
Follow-up to [54493], [53282], [52744], [52049], [50959].
Props oandregal, afragen, alexstine, aristath, azaozz, costdev, flixos90, hellofromTonya, mamaduka, mcsf, ocean90, spacedmonkey.
Fixes#56975.
Built from https://develop.svn.wordpress.org/trunk@55086
git-svn-id: http://core.svn.wordpress.org/trunk@54619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset fixes the `$preload_paths` parameter type for `block_editor_rest_api_preload()` and related hooks. This parameter expects an array of strings OR an array where the path is the first element (index 0) of this array.
Props chouby.
Fixes#56810.
See #56792.
Built from https://develop.svn.wordpress.org/trunk@54776
git-svn-id: http://core.svn.wordpress.org/trunk@54328 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The `wp_max_upload_size()` function can be expensive to call, especially for large sites or multisites. For the frontend usage of `get_default_block_editor_settings()` knowing the allowed upload size is typically unnecessary.
This changeset adds a condition so that `wp_max_upload_size()` is only called if the current user can actually `upload_files`. It keeps the data present when it is actually needed while avoiding the execution overhead when it is not needed.
Props janthiel, Clorith, flixos90, spacedmonkey.
Fixes#56815.
Built from https://develop.svn.wordpress.org/trunk@54769
git-svn-id: http://core.svn.wordpress.org/trunk@54321 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The `get_default_block_editor_settings()` function used to repeatedly get the `default-editor-styles.css` file contents without any implementation to avoid this.
This commit utilizes a static variable to remove repetitive calls made during the same request. In tests ran on the front page of a site using Xdebug & Webgrind, the total `file_get_contents()` invocation count goes down from 181 to 93, and total self cost (the time that the function is responsible for) goes down from 160 ms to 93 ms.
Follow-up to [52042].
Props aristath, mukesh27.
Fixes#56637.
Built from https://develop.svn.wordpress.org/trunk@54291
git-svn-id: http://core.svn.wordpress.org/trunk@53850 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This changeset is part of the Gutenberg changes merged into WP 6.1. It adds spacing presets support in global style properties.
Follow-up to [54211].
Props glendaviesnz, andrewserong, costdev, audrasjb, mukesh27.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54272
git-svn-id: http://core.svn.wordpress.org/trunk@53831 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Backports the following changes from the Gutenberg repository:
* [WordPress/gutenberg/40875 gutenberg/40875] Layout: Use semantic classnames, centralize layout definitions, reduce duplication, and fix blockGap in theme.json
* [WordPress/gutenberg/42544 gutenberg/42544] Layout: Add a disable-layout-styles theme supports flag to opt out of all layout styles gutenberg/42544
* [WordPress/gutenberg/42087 gutenberg/42087] Theme.json: Add block support feature level selectors for blocks gutenberg/42087
* [WordPress/gutenberg/43792 gutenberg/43792] Global Styles: Split root layout rules into a different function gutenberg/43792
* [WordPress/gutenberg/42544 gutenberg/42544] Layout: Add a disable-layout-styles theme supports flag to opt out of all layout styles gutenberg/42544
* [WordPress/gutenberg/42665 gutenberg/42665] Layout: Reduce specificity of fallback blockGap styles gutenberg/42665
* [WordPress/gutenberg/42085 gutenberg/42085] Core CSS support for root padding and alignfull blocks gutenberg/42085
Notes:
* It doesn't entirely port over PR 40875 — the remaining PHP changes for that PR will be explored in a separate PR targeting `layout.php`.
* [54159] was reverted in [54160] due to PHPUnit test failures for tests added by the commit. Later, tests passed when applied on top of `trunk`. There were various outages today of upstream `wp-env` dependencies, which likely were the root cause of the earlier failures. For historical tracking and to make sure, recommitting [54159] but instead on top of current `trunk`. See PR 3205 for more details.
* Giving additional props for those who did a deep dive investigation into the failed tests.
Follow-up to [54160], [54159].
Props andrewserong, aaronrobertshaw, isabel_brison, bernhard-reiter, hellofromTonya.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54162
git-svn-id: http://core.svn.wordpress.org/trunk@53721 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This change backports the following changes from Gutenberg repository:
- [WordPress/gutenberg#40875 gutenberg#40875] Layout: Use semantic classnames, centralize layout definitions, reduce duplication, and fix blockGap in theme.json
- [WordPress/gutenberg#42544 gutenberg#42544] Layout: Add a disable-layout-styles theme supports flag to opt out of all layout styles gutenberg#42544
- [WordPress/gutenberg#42087 gutenberg#42087] Theme.json: Add block support feature level selectors for blocks gutenberg#42087
- [WordPress/gutenberg#43792 gutenberg#43792] Global Styles: Split root layout rules into a different function gutenberg#43792
- [WordPress/gutenberg#42544 gutenberg#42544] Layout: Add a disable-layout-styles theme supports flag to opt out of all layout styles gutenberg#42544
- [WordPress/gutenberg#42665 gutenberg#42665] Layout: Reduce specificity of fallback blockGap styles gutenberg#42665
- [WordPress/gutenberg#42085 gutenberg#42085] Core CSS support for root padding and alignfull blocks gutenberg#42085
Note that it doesn't entirely port over PR40875 — the remaining PHP changes for that PR will be explored in a separate PR targeting `layout.php`.
Props andrewserong, aaronrobertshaw, isabel_brison.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54159
git-svn-id: http://core.svn.wordpress.org/trunk@53718 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Follow-up #54337, [52069]. Part of https://github.com/WordPress/gutenberg/issues/41236. More details in https://github.com/WordPress/gutenberg/issues/33542.
Allow passing more than one script per block for `editorScript`, `script`, and `viewScript` fields in the `block.json` metadata file. This aligns with the previously added changes for `style` and `editorStyle` fields.
This change impacts the `WP_Block_Type` class and the REST API endpoint for block types. To ensure backward compatibiliy old names were soft deprecated in favor of new fields that work with array values and have `_handles` suffix.
Props zieladam, dlh, timothyblynjacobs, aristath, bernhard-reiter.
Fixes#56408.
Built from https://develop.svn.wordpress.org/trunk@54155
git-svn-id: http://core.svn.wordpress.org/trunk@53714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The site editor, unlike other editors, generates the styles coming from global styles (presets, styles) dynamically in the client. This is because the user can modify any value that we need to consolidate (merge core, theme, and user style preferences). We don't want to have the global styles twice, as it introduces subtle bugs.
Props oandregal, youknowriad.
See #55567.
Built from https://develop.svn.wordpress.org/trunk@53208
git-svn-id: http://core.svn.wordpress.org/trunk@52797 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Backports changes from Gutenberg to add functions required by Comment Query Loop and related blocks. Related unit tests depends on the new blocks and they will get added seperately.
Props darerodz, timothyblynjacobs.
See #55505.
Built from https://develop.svn.wordpress.org/trunk@53138
git-svn-id: http://core.svn.wordpress.org/trunk@52727 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Since WordPress 5.9 you can set a view script for a block which is supposed to be only loaded on the front end. Unfortunately it's currently also loaded in the editor which can cause unexpected behaviour and also performance issues depending on the size of the scripts.
This is caused by the preloading of REST API routes via `block_editor_rest_api_preload()` which doesn't happen in an encapsulated process and so does pollute any global state like the one for scripts and styles.
Similar to the global `$post`, core now backups the globals `$wp_scripts` and `$wp_styles` and restores the backup after the preloading.
Props gziolo, ocean90.
Fixes#55151.
Built from https://develop.svn.wordpress.org/trunk@52733
git-svn-id: http://core.svn.wordpress.org/trunk@52322 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Update packages to include these bug fixes from Gutenberg:
- Image block: Set image display to grid when no alignment sent to properly align caption on resize
- Update and align template descriptions
- Site Editor - prevent loading state from showing the admin menu.
- Add client side routing for Site Editor
- Navigation: Add clearance for appender in submenus.
- Fix CSS Custom Properties for presets in the site editor
- Add/navigation blocks post processing after migration from menu items
- Allow selector ordering to ensure theme.json root selector margin takes precedence
- Do not remove theme presets if defaults are hidden
- Format library: fix unsetting highlight color
- FSE: Fix template resolution to give precedence to child theme PHP templates over parent theme block templates with equal specificity
- ColorPalette: Improving accessibility and visibility
- Update: Make the color popover on the gradient picker appear as expected
- Site Editor: Display a notice if export fails
- Fix docs and function naming for gallery block registration in PHP
- Switch to addEventListener for load event in the navigation block view script
- Fix mistake in _remove_theme_attribute_in_block_template_content
- Better synchronisation between Gutenberg and Core code
- Move the block page templates hook into compat/5.9 folder
- Moves to the template loader hooks and functions into lib/compat folder
- Refactor the gutenberg_is_fse_theme function to use wp_is_block_theme
- Site Editor: Update support doc URL in Welcome Guide
- Global Styles: Add Welcome Guide toggle
- Hide remove control point when removing would break gradient control
- Don't request the deprecated navigation areas endpoint outside of the Gutenberg plugin
- Image: Fix resizer controls being hidden in Safari when switching between alignments
- Remove Navigation Menus from WP Admin sidebar
- Site Editor: Hide the block appender in the Template Part editor
- Site Editor: Use server definition for the Template Areas
- Synchronize wp_is_block_theme and block-templates block support with Core
- E2E: Retry login again after a bad nonce request to prevent intermittent test failures
- Fix theme requirement validation with WP 5.8
- Fix WP 5.9 check for conditionally running code
- Fix post comment form input width
- Border Style Control: Update styling for consistency with border width control
- Fix form-submit styles by adding button classes to the submit-button in post-comments block
- Site Editor: Fix edit template part link in header dropdown
- Move duotone palette to the bottom of global styles gradients
- Fix how appearanceTools works
- Move WP 5.9 wp-admin menus compatibility code to lib/compat folder
- Revert "Site Editor: Set the <title> on the list page to be same as the CPT name"
- Site Editor: Document Actions: add SR text to heading 1
- Do not register global styles CPT in WordPress 5.9
- Global Styles: Move the 'Edit colors' button to a standard menu item
- Fix styles for previews and patterns
- Site Editor: Fix failing E2E test
- Templates: Search for old template names in the parent theme too
- Remove 4 instances of 'gutenberg' text domain from WordPress core
- Fix content loss when ungrouping template parts or reusable blocks
- Simplify the RESET_BLOCK action to fix template part focus mode content loss
- [Global Styles]: Make Blocks section more distinguishable
- Only use block markup for comment form button when using a block theme
- Navigation: Fix vertical alignment of page list in modal.
- Fix: ToggleGroupControl active state
- Remove gutenberg_ prefix from @wordpress/block-library
Props ocean90, oandregal, hellofromtonya, youknowriad.
See #54487.
Built from https://develop.svn.wordpress.org/trunk@52364
git-svn-id: http://core.svn.wordpress.org/trunk@51956 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Currently the WordPress mobile apps rely on the `__unstableGalleryWithImageBlocks` flag being set in order to enable the new gallery block format.
This commit includes the value in the `get_default_block_editor_settings()` function in order to ensure that versions of the mobile app >= 18.2 will be able to add and edit gallery blocks in the new format.
Props glendaviesnz, ocean90, hellofromTonya, noisysocks.
Fixes#54583.
Built from https://develop.svn.wordpress.org/trunk@52349
git-svn-id: http://core.svn.wordpress.org/trunk@51941 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Update packages to include these bug fixes from Gutenberg:
- Update Pattern block category and add documentation
- Fix non existent menu handling in nav block
- Make Reusable blocks available in the Site Editor
- Add caching to WP_Theme_JSON_Resolver_Gutenberg::get_user_data_from_custom_post_type()
- theme.json: add appearanceTools flag to opt-in into appearance UI controls
- Update the block theme folders to templates and parts
- Remove reference to gutenberg_, swap with wp_
- Use table layout in templates list screen
- Update featured image placeholder graphic.
- [Inserter]: Adjust order of theme blocks and reorder inserter items
- Implement suitable fallback for Nav block on front end of site when no menu selected
- Toggle Group Control: add tooltip
- Use first non-empty Nav post as primary fallback for Nav block
- Change .nvmrc and documentation for Node.js version (LTS to 14.18.1)
- Update: Migrate global styles user database data on the rest endpoint
- Update global styles public API
- Update: Rename user preset origin to custom
- Try always generating navigation post title
- Show all templates and template parts on the site editor list screens
- Highlight "Site" in the navigation panel
- Fix template part slug generation when creating through the block placeholder
- [Block Library - Post Title]: Fix render error when setting Page to homepage
- Add 'Clear customizations' button to template list page
- Gallery v1: Allow clicks within replace media placeholder state
- Site Editor: Set the <title> on the list page to be same as the CPT name
- Gallery: Fix stuck image size options loader
- Cover: Fix undo trap
- Add success and error snackbars to the templates list page
- Fix: theme colors cannot override defaults
- Fix: Color palette is not being stored
- Add elements support to the typography panel in global styles
- Make links plural in global styles
- Add: Gradient palette editor
- Update some small style regressions in the template list
- Add: Transparency support on global styles colors
- Fix: apply by slug on all origins
- Render empty Nav block if no fallback block can be utilised
- Allow filtering of Nav block fallback
- Fix Nav block fallback DB query to match on full block grammar start tag
- Remove unstable max pages attribute from Nav block
- DateTimePicker: set PM hours correctly
- Update delete template button
- Site Editor: Template list add rename action
- Fix Nav block editing wrong entity on creation of new Menu
- [REST] Restore the missing double slash in the ID received by /templates
- Add icons to navigation sidebar items
- Update function names for the public global styles API functions
- Templates Controller: Add missing 'is_custom' prop
- Rename gutenberg_ to wp_ for some functions that land in WordPress 5.9
- [Block Library - Template Part]:Remove support for conversion to Reusable block
- Global Styles: Call "palettes" and not "color palettes" on panel label
- Add button text when no colors found
- Update: Global Styes: Count all color palette origins on the palette counter
- Rename navigationMenuId to ref
- Offset the parent iframe when computing Popover position
- Fix: Failing PHPUnit test
- Show theme, plugin or author in Added By column with appropriate icon or avatar
- Add origin and author to template rest api
See #54487.
Props talldanwp, mamaduka, oandregal.
Built from https://develop.svn.wordpress.org/trunk@52275
git-svn-id: http://core.svn.wordpress.org/trunk@51867 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Update packages to include these bug fixes from Gutenberg:
- FSE: Add welcome guide
- Update theme styles for the code block
- Add feature flag to toggle the new site editor sidebar
- Add templates list page for site editor
- Cover Block: Fix default background dim
- E2E: Add more Cover block tests
- Cover Block: Fix regressions
- Post Comments Form: ensure typography styles are applied to child elements
- Navigation: Fix space-between
- Fix background colours in nested submenus.
- Fix duplicate custom classnames in navigation submenu block
- Fix colour rendering in Navigation overlay
- Fix: Add ability to opt out of Core color palette V2
- Change @package to WordPress in block-library
- Make the core color palette opt-in for themes with not theme.json
- Remove textdomain from calendar block
- Page List block: fix space before href attribute
- Try: Let Featured Image block inherit dimensions, look like a placeholder
- [Global Styles]: Add block icon next to blocks list
- Page List: Use core entities instead of direct apiFetch
- Site Editor: Stabilize export endpoint
- Fix mobile horizontal scrollbar.
- Multi-entity save: Only set site entity to pending if really saving
- Add page list to navigation direct insert conditions
- Implement "Add New" for templates list in Site Editor
- Post Featured Image: Remove withNotices HOC
- Fix page list missing button styles when set to open on click.
- Make appender fixed position to avoid jumps in the UI
- Color UI component: reorder palettes and update names (core by defaults, user by custom)
- Remove the Styles link in Site Editor
- GlobalStyles sidebar: do not show default palette if theme opts-out
- Only render the site editor canvas when the global styles are ready.
- Global Styles: rename core origin key to default for presets
- Clarify i18n context for PostTemplateActions's "New" label
- Revert erroneous native editor package version bumps
- Try: Hide the columns inserter in pattern previews.
- Fix site editor region navigation
- Update navigation sidebar responsiveness
- Add _wp_array_set and _wp_to_kebab_case to 5.8 compat
- Make user able to change all color palette origins
- Site Editor: Update hrefs to not specifically refer to themes.php?page=gutenberg-edit-site
- Site Editor: Validate the postType query argument
- Navigation: Scale submenu icon.
- Move the theme editor under tools for FSE themes
- Deprecate navigation areas
See #54487.
Built from https://develop.svn.wordpress.org/trunk@52232
git-svn-id: http://core.svn.wordpress.org/trunk@51824 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This brings the JS packages up to date and is the first step that will allow us
to include the other block editor updates for WordPress 5.9:
FSE infrastrucutre, site editor and global styles.
Props noisysocks.
See #54337.
Built from https://develop.svn.wordpress.org/trunk@52042
git-svn-id: http://core.svn.wordpress.org/trunk@51634 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This matches the behavior that has been in place in the gutenberg plugin.
The idea is that this makes the editor match the frontend by default for these themes.
If they use a custom font, they'll have to provide it for the editor as editor styles.
Props nosolosw.
Built from https://develop.svn.wordpress.org/trunk@51240
git-svn-id: http://core.svn.wordpress.org/trunk@50849 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This updates the widgets screen to load the editor styles in the same way as the post editor. This combined with the package updates in [51198] and [51199] ensures that the blocks added to sidebars more accurately reflect what will be displayed on the front end of the site.
Props isabel_brison, noisysocks, andraganescu, audrasjb, jorbin, caseymilne, desrosj.
Fixes#53344. See #53388.
Built from https://develop.svn.wordpress.org/trunk@51200
git-svn-id: http://core.svn.wordpress.org/trunk@50809 1a063a9b-81f0-0310-95a4-ce76da25c4cd
The logic to enable or disabled colors, gradients, and font sizes missed a negative operator, so when things should be enabled they weren't and they should be disabled they were enabled. This commit fixes the logic.
Props ntsekouras.
See #53175.
Built from https://develop.svn.wordpress.org/trunk@51031
git-svn-id: http://core.svn.wordpress.org/trunk@50640 1a063a9b-81f0-0310-95a4-ce76da25c4cd