4594 Commits

Author SHA1 Message Date
Jb Audras
18aa343ec2 REST API: Add unit tests for the 404 template slug handler.
Props ockham, SergeyBiryukov, hellofromTonya, rachelbaker.
Fixes #54680.


git-svn-id: https://develop.svn.wordpress.org/trunk@52436 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-04 14:23:56 +00:00
Robert Anderson
bd08b22127 Update @wordpress packages
Update packages to include these bug fixes from Gutenberg:

- Site Logo: Add option to set site icon from Site Logo block
- Navigation: Enable even more compact setup state.
- Remove template parts from post content inserter an __unstable filter
- Template Editor Mode: Hide editor mode switcher
- Avoid using CSS variables for block gap styles
- Try to fix auto resizing in template part focus mode
- Lower the specificity of font size CSS Custom Properties in the editor
- Site icon: Fix site icon styling to display non-square site icons within a square button
- [Site Editor]: Register block editor shortcuts
- Update regex to handle 404 template slug
- Site Editor: Remove dead code
- [Block Editor]: Restrict delete multi selected blocks shortcut
- Fix: Gradients are not being applied by class
- Update: Make the global styles subtitles font smaller
- Post Content/Title: Reflect changes when previewing post
- ServerSideRender: Fix loading state
- [Block Library]: Fix editable post blocks in Query Loop with zero queryId
- Post Excerpt: Fix previews
- WP59: Contextualize "Export" string to differentiate it from other occurrences in WP Core
- Tools Panel: Fix race conditions caused by conditionally displayed ToolsPanelItems
- ToolsPanel: Allow items to register when panelId is null
- Font Size Picker: Allow non-integers as simple CSS values and in hints
- [Components - FontSizePicker]: Use incremental sequence of numbers as labels for the available font-sizes at the segmented control (conditionally)

See #54487.


git-svn-id: https://develop.svn.wordpress.org/trunk@52434 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-04 05:37:25 +00:00
Sergey Biryukov
c1b78cc2dd Tests: Add a unit test for the recommended MariaDB version in readme.html.
Per the [https://mariadb.org/about/#maintenance-policy MariaDB maintenance policy], MariaDB releases are supported for 5 years from the first stable (GA) release.

The test ensures that the recommended MariaDB version in `readme.html` is not older than 5 years.

Follow-up to [31291], [35759], [52319], [52358], [52418], [meta11407], [52420], [52421].

Fixes #41490.

git-svn-id: https://develop.svn.wordpress.org/trunk@52424 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-30 16:27:48 +00:00
Sergey Biryukov
5450faf3ec Tests: Correct the check for the recommended MySQL version in readme.html.
This updates the regular expression in the test to retrieve the date of the first, instead of the last, GA release for the recommended MySQL branch, in order to properly track the EOL date.

Additionally, as the currently recommended MySQL 5.7 branch moved from active support to extended support on 2020-10-21, and WordPress core is not fully compatible with MySQL 8.0 at this time, this commit increases the “supported” period from 5 to 8 years to include extended support.

Follow-up to [31291], [35759], [meta11407], [52420].

See #41490.

git-svn-id: https://develop.svn.wordpress.org/trunk@52421 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-29 16:34:12 +00:00
Sergey Biryukov
5b9406e3a7 Tests: Separate the tests for recommended PHP and MySQL versions in readme.html
This aims to simplify the individual tests and reduce duplication using a helper function.

Follow-up to [52260], [52319], [52358].

See #41490.

git-svn-id: https://develop.svn.wordpress.org/trunk@52418 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-26 23:40:50 +00:00
Isabel Brison
16aca51d8b Update @wordpress packages for Beta 4
Update packages with these bug fixes from Gutenberg:

Navigation: Remove hardcoded typography units
Handle parsed request
Navigation: Refactor modal padding to be simpler and more flexible
Show notice on save in site editor
Add aria-pressed true/false to Toggle navigation button based on state
Components FontSizePicker: Use incremental sequence of numbers
Custom keys from theme.json: fix kebabCase conversion
Template Part: Fix 'isMissing' condition check
Multi-Entity Saving: Decode HTML entities in item titles
Font sizes: update default values
Query Loop: Add useBlockPreview, fix Query Loop wide alignment
Only add dialog role to navigation when modal is open
Fix navigation appender
Show a UI warning when user does not have permission to update/edit a Navigation block
Block editor: Fix Enter handling for nested blocks
Update: Use subtitle styles for the palette names
Allow publishing a post while not saving changes to non-post entities
Update: Block top level useSetting paths
Fix Site Logo block alignment issues
Editor: when Toggle navigation receives state false, focus
ToolsPanel: Allow items to register when panelId is null
Block Support Panels - Make block support tools panels compatible
Gallery: Fix block registration hook priority
Navigation: Fix page list issues in overlay
Ensure the overlay menu works when inserting navigation block pattern
Restrict Navigation permissions and show UI warning if cannot create
Add block gap support for group blocks
Try cascading nav styles through classnames
Fix: Impossible to edit theme and default colors
Fix: Color editor discards colors with default name
Site Editor: Fix template author avatar check
Template Editing Mode: Fix options dropdown
Avoid undo issues when reset parent blocks for controlled blocks
Add comment-form and comment-list to html5 theme support and fix comment layout

Props hellofromtonya.
See #54487.


git-svn-id: https://develop.svn.wordpress.org/trunk@52402 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-21 07:00:16 +00:00
Tonya Mork
57129a6078 Editor: Add support for nameless font sizes in WP_Theme_JSON.
With nameless font sizes support, themes use the defaults by not declaring the `"name"` setting for their `fontSizes` in `theme.json`.

Backport from Gutenberg https://github.com/WordPress/gutenberg/pull/37410.

Follow-up to [50973], [52049], [52275], [52320].

Props ntsekouras, costdev, hellofromTonya.
Fixes #54640. See #54487.

git-svn-id: https://develop.svn.wordpress.org/trunk@52401 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-21 06:00:34 +00:00
Tonya Mork
e1f5600c15 REST API: Support . in theme directory names in WP_REST_Global_Styles_Controller, WP_REST_Templates_Controller, and WP_REST_Themes_Controller.
Regex changes from [52376] are reverted to restore the original regex patterns. Why? [52376] used an include characters pattern, which was too limiting. It did not account for localized characters, such as `é`, or other valid directory name characters.

The original theme directory regex pattern, i.e. `[^.\/]+(?:\/[^.\/]+)?` excluded the period `.` character. Removing the `.` character resolves the reported issue by allowing matching for `themes/theme-dirname-1.0/` or `themes/<subdirname>/theme-dirname-1.0/`.

As the pattern used an exclude approach, all characters are valid for matching except for `/`. However, not all characters are cross-platform valid for directory names. For example, the characters `/:<>*?"|` are not valid on Windows OS. The pattern now excludes those characters.

The theme's directory (or subdirectory) name pattern matching is now used in `WP_REST_Global_Styles_Controller`, `WP_REST_Templates_Controller`, and `WP_REST_Themes_Controller`.

Follow-up to [51003], [52051], [52275], [52376].

Props costdev, hellofromTonya, spacedmonkey, TimothyBlynJacobs, bijayyadav, kafleg.
Fixes #54596.

git-svn-id: https://develop.svn.wordpress.org/trunk@52399 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-21 04:12:06 +00:00
Tonya Mork
b161cfc1ff Application Passwords: Show HTTPS required message without filtering when not enabled or not in local environment.
When `add_filter( 'wp_is_application_passwords_available', '__return_false' )` exists, HTTPS requirement message is shown even if HTTPS is enabled on the site. This happens because `wp_is_application_passwords_available_for_user()` first invokes `wp_is_application_passwords_available()` which is filterable. The situation could happen if the `'wp_is_application_passwords_available_for_user'` filter returns `false`.

To fix this, the check for HTTPS (or if in a 'local' environment) is moved to a new function called `wp_is_application_passwords_supported()`. Then the return from this function is used as an OR condition for the Application Passwords section and for displaying the HTTPS required message.

Tests are included for both `wp_is_application_passwords_supported()` and `wp_is_application_passwords_available()`.

Follow-up to [51980], [51988].

Props davidbinda, SergeyBiryukov, ocean90, felipeelia, costdev, hellofromTonya.
Fixes #53658.

git-svn-id: https://develop.svn.wordpress.org/trunk@52398 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-21 02:43:18 +00:00
Tonya Mork
3ce5c4c5a8 General: Fix 'rel' argument in Tests_Functions_wpListBookmarks test datasets.
`wp_list_bookmarks()` arguments include `'link_rel'`, but not `'rel'`. This commit fixes this argument in the test datasets. It also adds an expected `'rel=""'` result check, i.e. instead of only checking for `'noopener'`.

Follow-up to [52395].

Props davidbinda.
Fixes #53839.

git-svn-id: https://develop.svn.wordpress.org/trunk@52396 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-21 00:10:26 +00:00
Sergey Biryukov
ef404e2599 Tests: Use shared fixtures in block theme tests.
This removes duplicate test data and aims to avoid future confusion about which themes to use in which tests.

Follow-up to [52049], [52246], [52247], [52279].

See #53363.

git-svn-id: https://develop.svn.wordpress.org/trunk@52391 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-19 16:23:38 +00:00
John Blackbourn
7c0f7cbbda Build/Test Tools: Remove the assertion in filter_rest_url_for_leading_slash().
This assertion can mask the fact that some other tests don't perform an assertion.

Fixes #54661


git-svn-id: https://develop.svn.wordpress.org/trunk@52390 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-19 14:27:22 +00:00
John Blackbourn
029bea45b0 Build/Test Tools: Reduce the use of unnecessary randomness in tests.
This increases the overall reliability of the tests.

Props johnillo

Fixes #37371


git-svn-id: https://develop.svn.wordpress.org/trunk@52389 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-19 13:42:37 +00:00
Sergey Biryukov
77757441a4 Tests: Fix typo in a data provider name.
Follow-up to [52261], [52387].

See #53363.

git-svn-id: https://develop.svn.wordpress.org/trunk@52388 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-18 21:44:57 +00:00
Sergey Biryukov
a3fd024eba Tests: Fix typo in a test method name.
Follow-up to [52261].

See #53363.

git-svn-id: https://develop.svn.wordpress.org/trunk@52387 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-18 21:16:37 +00:00
SergeyBiryukov
b932a57806 Tests: Move the tests for theme features that block themes should support by default to a more appropriate place.
As these tests are intended for the `_add_default_theme_supports()` function rather than `WP_Theme` class methods, the `tests/theme.php` file is a more logical place for them than `tests/theme/wpTheme.php`.

Follow-up to [52369], [52383].

See #54597.

git-svn-id: https://develop.svn.wordpress.org/trunk@52386 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-18 21:08:02 +00:00
Sergey Biryukov
954e9c153f Tests: Add unit tests for theme features that block themes should support by default.
By default, block themes should have a few theme supports enabled:
* `post-thumbnails`
* `responsive-embeds`
* `editor-styles`
* `html5` for `comment-form`, `comment-list`, `style`, `script`
* `automatic-feed-links`

They should also load core block assets only when the blocks are rendered. This commit adds the associated tests.

Follow-up to [52369].

Props costdev.
See #54597.

git-svn-id: https://develop.svn.wordpress.org/trunk@52383 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-16 14:45:32 +00:00
Sergey Biryukov
5cb75a136d Tests: Mock the HTTP request response in download_url() tests.
This aims to speed up the tests and minimize unrelated failures by avoiding an unnecessary external HTTP request, while still performing the intended functionality checks.

Update similar helpers in some other tests to use more consistent terminology.

Follow-up to [37907], [46175], [51626].

See #54420, #53363.

git-svn-id: https://develop.svn.wordpress.org/trunk@52382 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-15 19:59:32 +00:00
Sergey Biryukov
2cd907dd63 Tests: Add an assertion to test the WP_REST_Server::add_site_logo_to_index() method.
Additionally:
* Move the test for `WP_REST_Server::add_active_theme_link_to_index()` to a more logical place.
* Replace `assertEquals()` with `assertSame()` in site icon test to also check the type of the value.
* Use a more consistent pattern for the tests.

Follow-up to [51241], [52080].

Props ignatggeorgiev, desrosj, SergeyBiryukov.
Fixes #53516. See #53363.

git-svn-id: https://develop.svn.wordpress.org/trunk@52381 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-15 18:06:15 +00:00
Tonya Mork
08b7927ef8 REST API: Add block theme support for valid non-alphanumeric characters in theme's directory name.
Themes whose `wp-content/themes/<dirname>` include valid non-alphanumeric (cross-platform) characters work for non-block themes, but did not previously resolve for block themes. For example, a block theme in `wp-content/themes/twentytwentytwo-0.4.0/` directory resulted a 404 "No route was found matching the URL and request method" response when attempting to customize it in the Site Editor.

This commit adds support for the following characters in a theme's root directory: `_`, `.`, `@`, `[`, `]`, `(`, and `)`. Subdirectory themes and `-` are already supported.

Follow-up to [51003], [52051], [52275].

Props mkaz, costdev, hellofromTonya, jffng, justinahinon, peterwilsoncc, spacedmonkey, TimothyBlynJacobs.
Fixes #54596.

git-svn-id: https://develop.svn.wordpress.org/trunk@52376 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-14 18:22:07 +00:00
Jonny Harris
8770f5c652 REST API: Ensure that the get_theme_item method should respect fields param.
Fix the `get_theme_item` method in the `WP_REST_Global_Styles_Controller` class to respect the fields param context filtering and to return links. 

Props spacedmonkey, hellofromtonya, peterwilsoncc, costdev.
Fixes #54595.



git-svn-id: https://develop.svn.wordpress.org/trunk@52374 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-14 16:29:03 +00:00
Tonya Mork
26c6b33b87 Themes: Rename public static functions in WP_Theme_JSON_Resolver to remove custom_post_type references.
WordPress Core is not really custom and does not reference "custom post type" in its function naming. This commit renames 2 public static methods:

* `WP_Theme_JSON_Resolver::get_user_custom_post_type_id()` renamed to `WP_Theme_JSON_Resolver::get_user_global_styles_post_id()`.
* `WP_Theme_JSON_Resolver::get_user_data_from_custom_post_type()` renamed to `WP_Theme_JSON_Resolver:: get_user_data_from_wp_global_styles()`.

Follow-up to [52049], [52051], [52069], [52232], [52275], [52364].

Props antonvlasenko, bernhard-reiter, costdev, desrosj, hellofromTonya, noisysocks, oandregal, SergeyBiryukov.
Fixes #54517.

git-svn-id: https://develop.svn.wordpress.org/trunk@52372 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-14 16:12:57 +00:00
Tonya Mork
4b35425d7b Customize: Overlay incompatible banner for block themes.
Starting in 5.9, block themes are not compatible with (do not support) Customizer; rather, they use the Site Editor. Viewing installed themes in Customizer, this commit adds an overlay message to alert users and give them a way to activate the block theme. Clicking on the "Activate" button activates the block theme and redirects back to the Appearance > Themes interface, where the user can then enter the Site Editor for customization.

Non-block themes are not affected by this change and continue to work in Customizer.

Follow-up to [41648], [41893], [52279].

Props antonvlasenko, costdev, hellofromTonya, jffng, joyously, noisysocks, poena, shaunandrews.
Fixes #54549.

git-svn-id: https://develop.svn.wordpress.org/trunk@52371 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-14 15:31:14 +00:00
Tonya Mork
d3a851d0d1 Formatting: Use is_scalar() in sanitize_key().
This is a follow-up to [52292] which introduced `is_string()` to check the given key is a string to be sanitized, else the key is set to an empty string. 

`sanitize_key()` is clearly identified (in the documentation) to only work with ''string'' keys. However, it had a bug in it that allowed non-strings to pass through it:
* A non-scalar "key" would throw a PHP Warning (which was resolved in [52292]. 
* A non-string scalar "key" was handled by the PHP native `strtolower()` which converted it into a string.

While `is_string()` is valid, non-string scalar types passed as the key to be sanitized were being set to an empty string. Given that `strtolower()` handles these without error or deprecation as of PHP 8.1, `is_scalar()` protects the website from issues while retaining the past behavior of converting integer keys (for example) into a string.

Changes include:
* Using `is_scalar()` instead of `is_string()`
* Refactor for readability and less code
* More tests

Please note, this does not change the behavior of the function, nor redefine it to now accept non-string scalars.

References:
* https://developer.wordpress.org/reference/functions/sanitize_key/
* https://www.php.net/manual/en/function.strtolower.php

Follow-up [52292].

Props wppunk, hellofromTonya, costdev, jrf.
Fixes #54160.

git-svn-id: https://develop.svn.wordpress.org/trunk@52370 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-14 14:59:33 +00:00
Robert Anderson
667fb94b79 Update @wordpress packages
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.


git-svn-id: https://develop.svn.wordpress.org/trunk@52364 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-14 01:55:28 +00:00
Sergey Biryukov
0a346a22ba Build/Test Tools: Disable WP Cron when installing PHPUnit tests.
During the WordPress installation process when running the test suite, an HTTP request was always fired by a cron task and failed, because tests are run in CLI mode only.

To avoid that, the `DISABLE_WP_CRON` constant was previously added to the `bootstrap.php` file. However, the constant is not passed to the `install.php` script. This commit makes a similar change to `install.php`.

Follow-up to [760/tests], [872/tests].

Props Chouby.
Fixes #54612.

git-svn-id: https://develop.svn.wordpress.org/trunk@52359 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-12 15:46:46 +00:00
Sergey Biryukov
882687a54a Docs: Correct the format of some comments per the documentation standards.
Follow-up to [10357], [10939], [43309], [51003], [51266], [51653], [51738], [52110].

See #53399.

git-svn-id: https://develop.svn.wordpress.org/trunk@52352 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-10 20:28:27 +00:00
Sergey Biryukov
56741a3047 Editor: Add an editor settings flag to enable the new gallery for mobile apps for 5.9.
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.

git-svn-id: https://develop.svn.wordpress.org/trunk@52349 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-09 15:23:23 +00:00
Jonny Harris
9f0d8fdf01 REST API: Improve permission handling in global style endpoint.
The new wp_global_styles post type is registered to use edit_theme_options in the capability settings. The WP_REST_Global_Styles_Controller class's permission checks methods use the capability in a hard coded form rather than looking up the capability via the post type object. Changing the permission callbacks to lookup capabilities via the post type object, allows theme and plugin developers to modify the capability used for editing global styles via a filter and these values to be respected via the Global Styles REST API.

Props Spacedmonkey, peterwilsoncc, hellofromTonya , antonvlasenko, TimothyBlynJacobs, costdev, zieladam.
Fixes #54516.



git-svn-id: https://develop.svn.wordpress.org/trunk@52342 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-07 20:56:18 +00:00
Jonny Harris
8697aee5f9 REST API: Ensure that the export template endpoint returns a valid WP_Error object.
Ensure that the export template endpoint returns a WP_Error object, including code and message, so that the site editor can display an error message. 
Add some basic unit tests to ensure that permission checks are working as expected. 

Follow-up to [52286].

Props Spacedmonkey, dlh, hellofromTonya , Mamaduka, TimothyBlynJacobs.
Fixes #54448.



git-svn-id: https://develop.svn.wordpress.org/trunk@52340 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-07 18:36:29 +00:00
Jb Audras
6f546a023c Script Loader: Allow for wp_register_script() to be called after wp_enqueue_script().
When a plugin registers styles/scripts on `wp_enqueue_scripts` (as plugin authors are encouraged to do), and conditionally enqueues their script/style on `the_content` filter, things "just work". In block themes, `the_content` is run prior to the header being processed, which results in the above scenario failing.

This change makes a `wp_enqueue_script( 'example' ); wp_register_script( 'example' );` work, where as currently the enqueue silently fails (no "doing it wrong" message) and the following register has no impact. Scripts can therefore be enqueued and dequeued (by "handle") before they are registered.

Fixes #54529.


git-svn-id: https://develop.svn.wordpress.org/trunk@52338 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-07 17:44:46 +00:00
Riad Benguella
bccb23ca03 Site Editor: Update the block template descriptions.
Align the template descriptions with the latest changes from the Gutenberg plugin.

Props jameskoster, SergeyBiryukov.
See #54335.


git-svn-id: https://develop.svn.wordpress.org/trunk@52331 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-07 12:10:36 +00:00
Tonya Mork
9cc20468ef Themes: Better names for WP_Theme::is_block_theme() and wp_is_block_theme() and make wp_is_block_theme() a wrapper.
This commit renames the following method and function to better represent block theme terminology:

* `WP_Theme::is_block_based()` to `WP_Theme::is_block_theme()`
* `wp_is_block_template_theme()` to `wp_is_block_theme()`

It also changes `wp_is_block_theme()` to be a helper wrapper (sugar syntax) for `wp_get_theme()->is_block_theme();`. Why? To ensure both the method and function behave the same, to help Gutenberg maintain WordPress cross-version compatibility, and to make it less cumbersome to port changes from Gutenberg to Core.

Follow-up to [52069], [52247], [52279].

Props antonvlasenko, costdev, hellofromTonya, noisysocks.
Fixes #54550.

git-svn-id: https://develop.svn.wordpress.org/trunk@52330 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-07 00:00:45 +00:00
Tonya Mork
f322c1ef3f Editor: Allow theme.json to take precedence in setting the root level element's reset margin value.
Any margin added to the root element via `theme.json` is overwritten by a CSS reset margin value provided by the Gutenberg Plugin.

This commit makes `theme.json` setting take precedence by generating the global styles body reset prior to processing the theme.json.

Follow-up to [52049].

Props get_dave, hellofromTonya.
Fixes #54550.

git-svn-id: https://develop.svn.wordpress.org/trunk@52329 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-06 22:40:45 +00:00
Sergey Biryukov
071e80695d HTTP API: Revert changeset [52244].
Reverting Requests 2.0.0 changes and moving to WordPress 6.0 cycle. Why? The namespace and file case renaming revealed 2 issues in Core's upgrader process.

See https://core.trac.wordpress.org/ticket/54504#comment:22 for more information.

Follow-up to [52327].

See #54562, #54504.

git-svn-id: https://develop.svn.wordpress.org/trunk@52328 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-06 21:29:00 +00:00
Sergey Biryukov
5eede7436a KSES: Use the polyfilled PHP 8 string functions in _wp_kses_allow_pdf_objects():
* `str_contains()`
* `str_ends_with()`
* `str_starts_with()`

Additionally, include a test for a PDF file in an `<object>` tag with an unsupported protocol.

Follow-up to [51963], [52039], [52040], [52304], [52309].

Props TobiasBg, ramonopoly.
See #54261.

git-svn-id: https://develop.svn.wordpress.org/trunk@52326 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-06 11:06:40 +00:00
Tonya Mork
4e6823d17c Editor: Enable incomplete unit tests in Tests_Block_Template_Utils:: test_get_block_template_from_file().
At the time tests were backported from Gutenberg, a block template theme was not available in the test suite; thus, the test was marked as `markTestIncomplete()`.

Now that `block-theme` and `block-theme-child` test fixture block template themes are available, this commit removes the `markTestIncomplete()` and adjusts the test to run by switching to the `block-theme` test fixture.

Follow-up to [51003], [52062], [52247].

Props bernhard-reiter.
Fixes #54551.

git-svn-id: https://develop.svn.wordpress.org/trunk@52314 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-03 16:57:19 +00:00
Jb Audras
281142bfb4 Coding standards: Address a few coding standards issues after [52312].
Follow-up to [52312].

See #54558.


git-svn-id: https://develop.svn.wordpress.org/trunk@52313 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-03 15:34:51 +00:00
Jb Audras
108e65819a Editor: Avoid undefined index notices in the Template Parts Editor.
This changes adds a leading slash when needed in the `?context=edit` path to avoid an `undefined index` notice in the Template Parts Editor.

Follow-up to [52275].

Props kafleg, costdev, mukesh27, Boniu91.
Fixes #54558.


git-svn-id: https://develop.svn.wordpress.org/trunk@52312 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-03 15:28:21 +00:00
Jb Audras
1270c897a9 REST API: Use global transients for URL details endpoint.
Follow-up to [51973].

Props peterwilsoncc, costdev.
Fixes #54499.


git-svn-id: https://develop.svn.wordpress.org/trunk@52311 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-03 11:34:55 +00:00
Sergey Biryukov
9484989819 Tests: Fix typo in a WP_Test_REST_Posts_Controller test method name.
Follow-up to [42423].

See #53363.

git-svn-id: https://develop.svn.wordpress.org/trunk@52310 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-03 05:57:04 +00:00
Peter Wilson
cbea717875 KSES: Accept port number in PDF upload paths.
Improves the URL validation in `_wp_kses_allow_pdf_objects()` to account for sites using an upload path that contains a port, for example wp.org:8080.

Follow up to [51963], [52304].

Props ocean90, ramonopoly, talldanwp.
See #54261.



git-svn-id: https://develop.svn.wordpress.org/trunk@52309 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-03 02:42:17 +00:00
Jb Audras
d2b043b468 Editor: Allow child theme PHP templates to take precedence over parent theme block templates.
This change fixes template resolution to give precedence to child theme PHP templates over parent theme block templates with equal specificity.

Before this change, when a theme was using a PHP template of a certain specificity (e.g. `page-home.php`), and it happened to be a child theme of another theme which had a block template for the same specificity (e.g. `page-home.html`), WordPress was picking the parent theme’s block template over the child theme’s PHP template to render the page. If the PHP and block template have equal specificity, the child theme's template should be used.

The issue was fixed before in Gutenberg so the fix now needs to happen in Core.

This change also re-enables the preexisting template resolution unit tests.

Follow-up to [51003].

Props bernhard-reiter, youknowriad.
Fixes #54515.


git-svn-id: https://develop.svn.wordpress.org/trunk@52308 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-02 23:35:20 +00:00
Sergey Biryukov
8bd1509ea8 Docs: Fix typo in some get_edit_term_link() test DocBlocks.
Follow-up to [52180], [52255].

See #50225, #53399.

git-svn-id: https://develop.svn.wordpress.org/trunk@52305 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-02 05:39:57 +00:00
Peter Wilson
5fa8d73b1b KSES: Allow attributes to be restricted via callbacks.
Add callback validation to HTML tag attributes for increased flexibility over an array of values only.

In `object` tags, validate the `data` attribute via a callback to ensure it is a PDF and matches the `type` attribute. This prevents mime type mismatches in browsers.

Follow up to [51963].

Props Pento, dd32, swissspidy, xknown, peterwilsoncc.
Fixes #54261.



git-svn-id: https://develop.svn.wordpress.org/trunk@52304 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-02 00:54:03 +00:00
Sergey Biryukov
1b92a6db07 Options, Meta APIs: Improve error handling in sanitize_option().
To prevent potential false negatives, set `$error` to `null` initially, so we can better tell if it was ever changed during the sanitization and be able to better react if an empty string is added to it.

Additionally, and mainly for the sake of the Settings API at this point, add error messages to some `WP_Error` objects returned from `wpdb` methods that were previously causing the issues here.

Follow-up to [32791].

Props iCaleb, audrasjb, hellofromTonya, SergeyBiryukov.
Fixes #53986.

git-svn-id: https://develop.svn.wordpress.org/trunk@52294 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-30 21:00:32 +00:00
Tonya Mork
1db73227b6 Formatting: Handle non-scalar types passed to sanitize_key().
`sanitize_key()` expects a string type for the given `key`. Passing any other data type to `strtolower()` can result in `E_WARNING: strtolower() expects parameter 1 to be string, array given`.

A check is added that if the key is not a string, the key is set to an empty string. For performance, the additional string processing is skipped if the key is an empty string.

This change maintains backwards-compatibility for valid string keys while fixing the bug of non-string keys.

Props costdev, dd32. 
Fixes #54160.

git-svn-id: https://develop.svn.wordpress.org/trunk@52292 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-30 20:09:56 +00:00
Jonny Harris
e0e5eb53d4 Site Editor: Add site export REST API endpoint.
Add a REST API to export site templates and template part as html files. When the REST API is requested, it responds by downloading a single ZIP file and exits early, without completing full request.  To create the exported zip, the ZipArchive class is required. If this class is not present then the export will gracefully fail, returning a `WP_Error` object and 500 status error code. 

Props spacedmonkey, youknowriad, Mamaduka, walbo, peterwilsoncc. 
Fixes #54448 .



git-svn-id: https://develop.svn.wordpress.org/trunk@52286 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-30 17:30:22 +00:00
Jb Audras
6e23261bbf Tests: Update WP_REST_Global_Styles_Controller_Test "Custom Styles" string after [52280].
Follow-up to [52280].

See #54518.


git-svn-id: https://develop.svn.wordpress.org/trunk@52282 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-30 15:53:48 +00:00
Tonya Mork
4fd0db227d Administration: For block themes, link to Site Editor interface instead of Customizer in Dashboard's welcome panel and Themes interface.
For block themes (like Twenty Twenty-Two), Customizer menu item is removed and replaced with the Site Editor menu item. However, other links exist in the Dashboard's welcome panel "Customize Your Site" button and the "Customize" button in each theme listed in the Appearance > Themes interface.

This commit changes each of those remaining links to link to the Site Editor interface instead of the Customizer.

To help identify block vs non-block themes, two method methods are introduced in `WP_Theme`:

* `WP_Theme:: is_block_based()` which identifies if the theme is a block theme or not.
* `WP_Theme::get_file_path()` which is similar to `get_theme_file_path()` but uses the directories within the theme object.

Both of these new methods include test coverage including the addition of a parent and child block theme in test data.

Follow-up to [18749], [35483], [42013], [42169].

Props antonvlasenko, jameskoster, hellofromTonya, matveb, noisysocks, poena, sergeybiryukov.
Fixes #54460.

git-svn-id: https://develop.svn.wordpress.org/trunk@52279 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-30 14:25:34 +00:00