4518 Commits

Author SHA1 Message Date
Dominik Schilling
fcd5d3b495 Script Loader: Prevent normalizing data URIs in _wp_normalize_relative_css_links().
This prevents making data URIs as in `mask-image:url('data:image/svg+xml;utf8,<svg...` relative to the WordPress installation.

Props staatic.
See #54243.
Fixes #55177.

git-svn-id: https://develop.svn.wordpress.org/trunk@52754 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-17 14:45:53 +00:00
Marius L. J
d7745c656d Filesystem API: Use a temp folder for Content-Disposition files.
#38231 added support for files fetched remotely to have their filename defined by the host using the `Content-Disposition` header. This would then take priority over the existing temporary file name created with `wp_tempnam()` earlier in the process.

The change unintentionally omitted the temporary directory path used during uploads, since the `wp_tempnam()` function would have added it previously, so that files with this header ended up being stored in the WordPress root folder, or wp-admin folder, when triggered by WP_Cron or user interactions respectively.

This change makes sure the file path includes the temporary directory location when the header is used.

Follow-up to [51939].

Props antonynz, azouamauriac.
Fixes #55109.

git-svn-id: https://develop.svn.wordpress.org/trunk@52734 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-15 17:47:39 +00:00
Jb Audras
27a9de78ab Widgets: Missing markup from Widgets Group block.
This change fixes an issue in the Widgets editor: widgets group was missing a `.wp-widget-group__inner-blocks` container.

Props noisysocks, ironprogrammer.
Fixes #55072.


git-svn-id: https://develop.svn.wordpress.org/trunk@52730 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-15 09:56:02 +00:00
Sergey Biryukov
5d7297d031 Cache API: Reorder object cache functions and methods for consistency.
The original order was alphabetical, which became less obvious as newer functions got added, resulting in a somewhat random order.

This commits aims to organize the functions and related `WP_Object_Cache` methods in a more predictable order:

* `wp_cache_init()`
* `wp_cache_add()`
* `wp_cache_add_multiple()`
* `wp_cache_replace()`
* `wp_cache_set()`
* `wp_cache_set_multiple()`
* `wp_cache_get()`
* `wp_cache_get_multiple()`
* `wp_cache_delete()`
* `wp_cache_delete_multiple()`
* `wp_cache_incr()`
* `wp_cache_decr()`
* `wp_cache_flush()`
* `wp_cache_close()`
* `wp_cache_add_global_groups()`
* `wp_cache_add_non_persistent_groups()`
* `wp_cache_switch_to_blog()`
* `wp_cache_reset()`

Follow-up to [3011], [6543], [7986], [13066], [18580], [21403], [47938], [52700], [52703-52705].

See #54728, #54574.

git-svn-id: https://develop.svn.wordpress.org/trunk@52706 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-11 18:47:38 +00:00
Sergey Biryukov
65f52bf921 Tests: Remove some extra wp_cache_set() calls from wp_cache_set_multiple() test.
These appear to be a copy/paste from the `wp_cache_get_multiple()` test and are not required here.

Follow-up to [47938], [52700].

See #54574.

git-svn-id: https://develop.svn.wordpress.org/trunk@52702 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-11 17:39:48 +00:00
Jonny Harris
4689322d44 Cache: Add wp_cache_*_multiple functions.
Add new caching functions named `wp_cache_add_multiple`, `wp_cache_set_multiple` and `wp_cache_delete_multiple`. All of these functions allow for an array of data to be passed, so that multiple cache objects can be created / edited / deleted in a single function call. This follows on from [47938] where the `wp_cache_get_multiple` function was introduced and allowed for multiple cache objects to be received in one call. 

Props: spacedmonkey, tillkruess, adamsilverstein, flixos90, mitogh, pbearne. 
Fixes: #54574.


git-svn-id: https://develop.svn.wordpress.org/trunk@52700 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-11 12:50:54 +00:00
Greg Ziółkowski
af07f6af4b I18n: Standardize the script paths for blocks
When providing file paths to scripts (editorScript, script or viewScript), when there is a trailing ./ included then there was a different md5 generated for the file that didn't match the one used with the file generated in the translations folder.

Props Rahe.
See #54797.



git-svn-id: https://develop.svn.wordpress.org/trunk@52699 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-11 12:12:56 +00:00
Jb Audras
96a1687b91 Query: Check if the theme supports block-templates before calling locate_block_template() in get_query_template().
This change improves performance for classic themes by removing an unnecessary query and fixes an issue where a classic theme would show "Empty template: Index" on the frontend when an empty `(block-)templates/index.html` file exists.

Props johnbillion, ianatkins, Mamaduka, costdev, manfcarlo, dolphingg, audrasjb, madeinua, kapilpaul, rafiahmedd, SergeyBiryukov.
Fixes #54844.


git-svn-id: https://develop.svn.wordpress.org/trunk@52697 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-09 13:20:49 +00:00
Jb Audras
b8f97013df Script Loader: Prevent normalizing HTML IDs in _wp_normalize_relative_css_links().
This change fixes an issue where `_wp_normalize_relative_css_links()` was not only matching urls, but also HTML IDs.

Follow-up to [52036].

Props mahype, costdev, audrasjb, SergeyBiryukov.
Fixes #54922.


git-svn-id: https://develop.svn.wordpress.org/trunk@52695 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-08 23:39:32 +00:00
Sergey Biryukov
371966a187 Tests: Rename the test file and class for wp_get_global_stylesheet() tests.
This matches the name of the function being tested.

Follow-up to [52675-52677].

See #54782.

git-svn-id: https://develop.svn.wordpress.org/trunk@52682 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-05 13:19:53 +00:00
Sergey Biryukov
38b5c686a1 Tests: Use more appropriate assertions in wp_get_global_stylesheet() tests.
This replaces instances of `assertTrue( str_contains( ... ) )` with `assertStringContainsString()` to use native PHPUnit functionality.

Follow-up to [52675], [52676].

See #54782.

git-svn-id: https://develop.svn.wordpress.org/trunk@52677 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-04 14:33:33 +00:00
Jorge Costa
b7aa3a09bc Fix: Classic themes using default presets are not working.
This commit makes the presets provided by the theme via add_theme_support always create CSS Custom Properties, whether or not the theme has a theme.json file. This way, if the overwrites a core preset, the core CSS variables are also overwritten and use the theme value.

Props oandregal, hellofromTonya, desrosj, costdev, pbearne, johnstonphilip, webmandesign.
Fixes #54782.

git-svn-id: https://develop.svn.wordpress.org/trunk@52675 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-04 13:50:34 +00:00
John Blackbourn
24b83dd431 Build/Test Tools: Switch to some more appropriate assertions.
See #54725


git-svn-id: https://develop.svn.wordpress.org/trunk@52654 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-30 19:40:57 +00:00
Sergey Biryukov
0fd2e294be Users: Return a WP_Error from wp_insert_user() if the user_url field is too long.
The `user_url` database field only allows up to 100 characters, and if the value is longer than that, the function should return a proper error message instead of silently failing.

This complements similar checks for `user_login` and `user_nicename` fields.

Follow-up to [45], [1575], [32299], [34218], [34626].

Props mkox, sabernhardt, tszming, SergeyBiryukov.
Fixes #44107.

git-svn-id: https://develop.svn.wordpress.org/trunk@52650 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-29 14:23:59 +00:00
Sergey Biryukov
f09c56bfd3 Date/Time: Add a unit test for the return type of current_datetime().
Follow-up to [45883].

Props pbearne.
Fixes #53484.

git-svn-id: https://develop.svn.wordpress.org/trunk@52611 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-21 05:58:13 +00:00
Sergey Biryukov
cc1b2515d7 Docs: Further update the send_retrieve_password_email filter documentation for consistency.
Follow-up to [52604], [52605].

See #54690.

git-svn-id: https://develop.svn.wordpress.org/trunk@52606 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-19 13:16:44 +00:00
Jb Audras
2db35e5674 Docs: Docblocks consistency fixes after [52604].
Follow-up to [52604].

Fixes #54690.


git-svn-id: https://develop.svn.wordpress.org/trunk@52605 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-19 12:40:57 +00:00
Jb Audras
f53f2960f8 Users: Add new hooks to filter retrieve password emails.
This change introduces two new hooks to help developers to filter retrieve password emails:

- `send_retrieve_password_email` can be used to filter whether to send the retrieve password email;
- `retrieve_password_notification_email` can be used to filter the contents of the reset password notification email sent to the user.

This changesets also adds unit tests for these new filters.

Props connapptivity, costdev, audrasjb, johnbillion.
Fixes #54690.


git-svn-id: https://develop.svn.wordpress.org/trunk@52604 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-19 12:15:13 +00:00
Sergey Biryukov
e70b0f7c3d Tests: Avoid duplicate queries in some WP_Query tests.
When passing args to the `WP_Query::__construct()` method, it internally executes the `WP_Query::get_posts()` method and stores the result in the `WP_Query::posts` property.

When calling `WP_Query::get_posts()` again, the same SQL query gets executed, and the result is again stored in the `WP_Query::posts` property.

Thus, the correct usage is to read the posts already stored in the `WP_Query::posts` property.

Follow-up to [1062/tests], [1065/tests], [1066/tests], [1070/tests], [29805], [31286], [49900], [51144].

Props david.binda.
Fixes #54822.

git-svn-id: https://develop.svn.wordpress.org/trunk@52577 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-14 17:50:52 +00:00
Jb Audras
aaf689a48f Tests: Trac ticket number correction after changeset [52569].
Follow-up to [52569].

See #54798.


git-svn-id: https://develop.svn.wordpress.org/trunk@52570 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-12 23:29:03 +00:00
Jb Audras
3685f95eb6 Administration: Ensure an integer is used for menu priority in add_menu_page().
This change adds a verification of the `$position` parameter in `add_menu_page()` to ensure an integer is used. If not, the function informs developers of the wrong parameter type via a `_doing_it_wrong` message. This brings consistency with a similar check used in `add_submenu_page()`.

This change also typecasts any floating number to string to ensure that in case a float value was passed, at least it doesn't override existing menus.

Follow-up to [46570].

Props kirtan95.
Fixes #54798. See #48249.


git-svn-id: https://develop.svn.wordpress.org/trunk@52569 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-12 23:23:41 +00:00
Jb Audras
482936752a Tests: Update qUnit test fixtures after [52535].
See #54745.


git-svn-id: https://develop.svn.wordpress.org/trunk@52536 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-06 23:23:23 +00:00
Tonya Mork
ba7d3a52b1 Themes: Make block themes support HTML5 by default.
For block themes, [52369] added HTML5 support for `'comment-list'`, `'comment-form'`, `'style'`, and `'script'`. However, when sites upgrade to 5.9 with non-block content such as a gallery and caption, the markup was not HTML5. 

This commit adds full HTML5 theme feature support for block themes. Non-block content such as a `[gallery]` and `[caption]` shortcodes will natively be in HMTL5 markup without block themes needing to specifically add `add_theme_support( 'html5, .. )` to the theme. 

Follow-up to [24417], [27302], [34261], [52369], [52383], [52386].

Props @joyously, costdev, hellofromTonya, audrasjb, Mamaduka, ocean90.
Fixes #54731. See #54597.

git-svn-id: https://develop.svn.wordpress.org/trunk@52439 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-04 18:38:52 +00:00
Jb Audras
107050f7a3 Embeds: Fix oEmbed host script enqueueing on block-based themes.
This change fixes oEmbed host script enqueueing on front-end when using block themes.

It deprecates `wp_oembed_add_host_js` in favor of `wp_maybe_enqueue_oembed_host_js`. The action is still triggered in `default-filters.php` to ensure backward compatibility for websites that are removing the action. There is now a `has_action()` check in `wp_maybe_enqueue_oembed_host_js()` to see if `wp_oembed_add_host_js()` has not been unhooked from running at the `wp_head` action.

Follow-up to [52132], [52151], [52153], [52325].

Props swissspidy, westonruter, flixos90, kafleg.
Fixes #44632.


git-svn-id: https://develop.svn.wordpress.org/trunk@52437 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-04 15:22:40 +00:00
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