6237 Commits

Author SHA1 Message Date
Peter Wilson
6a07d7a814 Media: Update file size meta data when editing images.
Fixes an error in which the file size meta data retained the original upload's values follow a user editing the images in the media screen.

The original images' file sizes are now stored in the backup image data to allow for them to be restored when a user restores the original image.


Props ankit-k-gupta, antpb, audrasjb, chaion07, gauravsingh7, joedolson, oglekler, pls78, rajinsharwar, sayedulsayem, vertisoft.
Fixes .


git-svn-id: https://develop.svn.wordpress.org/trunk@59202 602fd350-edb4-49c9-b593-d223f7449a82
2024-10-09 23:30:05 +00:00
Peter Wilson
4ccb5b4af0 Editor: Remove prefix from wp_(un)register_block_template() functions.
Removes the `wp_` prefix from block template registration functions for consistency with other block related registration functions.

* `wp_register_block_template()` becomes `register_block_template()`.
* `wp_unregister_block_template()` becomes `unregister_block_template()`.

Props aljullu, aristath, youknowriad, swissspidy.
Fixes .



git-svn-id: https://develop.svn.wordpress.org/trunk@59201 602fd350-edb4-49c9-b593-d223f7449a82
2024-10-09 22:09:30 +00:00
Andrew Serong
2ae4473373 Editor: Fix writingMode support in dynamic blocks.
Adds missing handling for the `typography.writingMode` property to the style engine, so that dynamic blocks correctly render text orientation styles on the site frontend.

Props wildworks, aaronrobertshaw, poena, get_dave, ndiego.
Fixes .
See .


git-svn-id: https://develop.svn.wordpress.org/trunk@59199 602fd350-edb4-49c9-b593-d223f7449a82
2024-10-09 01:26:13 +00:00
John Blackbourn
8eec9f25be Role/Capability: Introduce the current_user_can_for_site() and user_can_for_site() functions.
The `current_user_can_for_site()` function is a replacement for `current_user_can_for_blog()` which is now deprecated. `user_can_for_site()` is a renaming of the `user_can_for_blog()` function which was introduced in [59123]. The intention of this change is to prevent the introduction of a new function which uses the old "blog" naming structure.

Props swissspidy, spacedmonkey, flixos90, johnjamesjacoby

Fixes 


git-svn-id: https://develop.svn.wordpress.org/trunk@59198 602fd350-edb4-49c9-b593-d223f7449a82
2024-10-08 22:30:57 +00:00
Peter Wilson
023d3c4b3d Tests/Build Tools: Improve tests for bundled themes.
Introduce two new tests relating to bundled themes:

1. Ensure the list of tested themes matches the list of themes defined in `WP_Theme`
2. Ensure the run time value of `WP_DEFAULT_THEME` is included in the list of themes defined in `WP_Theme`

See .



git-svn-id: https://develop.svn.wordpress.org/trunk@59186 602fd350-edb4-49c9-b593-d223f7449a82
2024-10-07 00:35:43 +00:00
Felix Arntz
c3b9b39b8d Build/Test Tools: Resolve access failure to continue sending commit performance data to Code Vitals dashboard.
This originally broke in [58165] and unfortunately went unnoticed for a while because the failing request to send the data did not cause the GitHub workflows to fail. This changeset resolves the underlying access problem, which was happening because reusable GitHub workflows do not automatically receive secrets from the calling workflow. More concretely, the relevant `CODEVITALS_PROJECT_TOKEN` was not being explicitly passed to the reusable workflow.

The changeset also includes a change so that in the future a failing request would cause the workflow to fail, which ensures a similar problem further down the road wouldn't go unnoticed.

Props joemcgill, flixos90, swissspidy, mukesh27, sergeybiryukov
Fixes .
See .


git-svn-id: https://develop.svn.wordpress.org/trunk@59170 602fd350-edb4-49c9-b593-d223f7449a82
2024-10-04 16:24:33 +00:00
Jonathan Desrosiers
2c17f65542 Build/Test Tools: Enable testing for PHP 8.4.
With PHP 8.4 due out in November later this year, contributors have been working on ensuring WordPress 6.7 is as compatible as possible. Enough progress has been made during this release cycle where PHPUnit tests now run successfully with no failures reported.

This change enables PHP 8.4 testing throughout Core’s GitHub Action workflows to ensure no new problems are introduced going forward.

There are two exceptions to this:
- The Importer plugin has some compatibility issues that produce test failures. There is an open pull request upstream, but these problematic tests have been marked skipped when running on PHP 8.4 until that PR is merged.
- Since no stable versions of xDebug with PHP 8.4 support have been published, these tests are also skipped for now.

Props jrf, desrosj.
See .

git-svn-id: https://develop.svn.wordpress.org/trunk@59168 602fd350-edb4-49c9-b593-d223f7449a82
2024-10-04 14:07:03 +00:00
Sergey Biryukov
0e69bc9413 Tests: Bring some consistency to links_add_base_url() and links_add_target() tests.
Includes:
* Correcting the test class name as per the naming conventions.
* Documenting data provider values using hash notation.
* Passing the `$attrs` parameter to the function if not `null`.

Follow-up to [26328], [55563], [59162].

See .

git-svn-id: https://develop.svn.wordpress.org/trunk@59163 602fd350-edb4-49c9-b593-d223f7449a82
2024-10-03 23:42:43 +00:00
Peter Wilson
636d748a49 Tests/Build Tools: Introduce tests for links_add_base_url().
Props pbearne, rajinsharwar, jorbin, mukesh27, aristath, desrosj, ironprogrammer.
Fixes .




git-svn-id: https://develop.svn.wordpress.org/trunk@59162 602fd350-edb4-49c9-b593-d223f7449a82
2024-10-03 23:16:21 +00:00
Pascal Birchler
d42d95856e I18N: Do not load translations directly in load_*_textdomain.
In [59127], `_doing_it_wrong` warnings were added if plugins or themes load translations too early, either through a manual function call or just-in-time loading.

Because many plugins and themes still manually call `load_plugin_textdomain()`, `load_theme_textdomain()` or `load_muplugin_textdomain()`, even though they don't have to anymore, that caused a lot of warnings.

With this new approach, these functions merely register the translations path in the existing `WP_Textdomain_Registry` and do not immediately try to load the translations anymore. The loading is all handled by the just-in-time functionality.

This way, warnings will only be emitted if triggering the just-in-time loading too early, greatly improving the developer experience and to a degree also performance.

Props swissspidy, sergeybiryukov, mukesh27.
See .



git-svn-id: https://develop.svn.wordpress.org/trunk@59157 602fd350-edb4-49c9-b593-d223f7449a82
2024-10-02 13:42:11 +00:00
Peter Wilson
03be079386 Bundled Themes: Second follow up import of Twenty Twenty-Five.
Remove TT5 from performance tests as the baseline tests run against an older version of WordPress that do not include all of the functions used in the new theme.

Follow up to [59146], [59150].

Props mukesh27.
See .


git-svn-id: https://develop.svn.wordpress.org/trunk@59151 602fd350-edb4-49c9-b593-d223f7449a82
2024-10-01 03:49:31 +00:00
Peter Wilson
79785ac94a Bundled Themes: Follow up import of Twenty Twenty-Five.
Add additional references to the new default theme required in various locations of the code base, build steps and unit tests.

Follow up to [59146].

Props afragen, dd32, desrosj, davidbaumwald, jorbin, courane01, kirasong.
See .


git-svn-id: https://develop.svn.wordpress.org/trunk@59150 602fd350-edb4-49c9-b593-d223f7449a82
2024-10-01 03:25:18 +00:00
Adam Silverstein
9ef1ff13dc Media: improve support for lossless WebP.
When uploading lossless WebP images, WordPress now correctly outputs lossless WebP with both the Imagick and GD image editors.

Props: adamsilverstein, martinkrcho.
Fixes .



git-svn-id: https://develop.svn.wordpress.org/trunk@59145 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 23:54:49 +00:00
Peter Wilson
9b6c034e2f Formatting: Improve parenthesis handling in make_clickable().
Improve the regular expression for making links clickable to account for parenthesis in links containing an extension, for example: `http://wordpress.org/my-image(2).jpg`.

Props coquardcyr, hellofromtonya, parthvataliya, rhellewellgmailcom.
Fixes .


git-svn-id: https://develop.svn.wordpress.org/trunk@59143 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 23:27:34 +00:00
Tonya Mork
1f40d422c2 Canonical: Revert redirect when front page's paginated states not found.
r59091 introduced a backward compatibility (BC) break for a static homepage that includes a shortcode's or block's with paginated content that uses the `'paged'` query var, e.g. bbPress.

In this use case, attempting to navigate the shortcode / block's pagination causes a canonical redirect, rather than navigating to the next page of content within that shortcode or block.

Follow-up to [59091].

Props davidbinda, jjj.
See , #meta5184.

git-svn-id: https://develop.svn.wordpress.org/trunk@59133 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 18:16:18 +00:00
Felix Arntz
92fdeb486b Editor: Allow registering PHP manifest file for block metadata collections for enhanced performance.
Typically, when registering a new block type, its metadata is read from the provided `block.json` file. The more block types are registered on a site, the more costly becomes this process, as it involves filesystem reads and parsing JSON.

WordPress Core's built-in blocks have in the past worked around that by having a auto-generated PHP manifest file that includes the already parsed JSON data for all blocks. This changeset effectively allows plugins to do the same, by introducing a new API function `wp_register_block_metadata_collection()`. The WordPress Core block manifest is now handled using this API as well, rather than custom logic baked into `register_block_type_from_metadata()`.

The `wp_register_block_metadata_collection()` function requires two parameters:
* `$path`: The base path in which block files for the collection reside.
* `$manifest`: The path to the manifest file for the collection.

Every `block.json` file that is supposed to be part of the collection must reside within the provided `$path`, within its own block-specific directory matching the block name (without the block namespace). For example, for a collection `$path` of `/wp-content/plugins/test-plugin` and a block `test-plugin/testimonial`, the block file could be `/wp-content/plugins/test-plugins/blocks/testimonial/block.json`.

It is recommended that plugins use the new API function for enhanced performance, especially if they register several block types. However, the use of the function is entirely optional. Not using it will not result in any difference in user-facing behavior.

Props mreishus, flixos90, gziolo, spacedmonkey, azaozz, mukesh27.
Fixes .


git-svn-id: https://develop.svn.wordpress.org/trunk@59132 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 17:05:37 +00:00
Michal Czaplinski
88df10b96a Interactivity API: Add wp_interactivity_get_element() function.
Introduces the `wp_interactivity_get_element()` function to the Interactivity API, analogous to the `getElement()` function in the `@wordpress/interactivity` JavaScript module. This function allows access to the current element being processed during directive processing.

The function returns an array containing the `attributes` property, which includes only the originally defined attributes present on the element. Attributes added or modified by directive processing are not included. This is intended for use in derived state properties inside `wp_interactivity_state()`, similar to how `wp_interactivity_get_context()` is used.

Example usage:

```php
wp_interactivity_state( 'myPlugin', array(
    'buttonText' => function() {
        $context = wp_interactivity_get_context();
        $element = wp_interactivity_get_element();
        return isset( $context['buttonText'] )
          ? $context['buttonText']
          : $element['attributes']['data-default-button-text'];
    },
) );
```

Includes unit tests to cover the new functionality.

Props darerodz, swissspidy, cbravobernal, czapla.
Fixes .

git-svn-id: https://develop.svn.wordpress.org/trunk@59131 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 17:05:24 +00:00
Michal Czaplinski
b12a1cfa4d Interactivity API: Move interactivity-router i18n strings to Script Module data.
Moves the 'loading' and 'loaded' i18n strings for the `interactivity-router` to the script module data via the `script_module_data_@wordpress/interactivity-router` filter.

Key changes:

- Add the `filter_script_module_interactivity_router_data()` method, hooked into the `script_module_data_@wordpress/interactivity-router` filter, to set the `i18n` data with the 'loading' and 'loaded' messages.
- Rename the `print_router_loading_and_screen_reader_markup()` method to `print_router_markup()` and remove the screen reader markup from it because it's no longer needed.
- Deprecate the `print_router_loading_and_screen_reader_markup()` method.
- Remove the `loading` and `loaded` strings from the `core/router` store state because they're no longer needed.
- Initialize the `core/router` store with a minimal navigation object to prevent errors in the interactivity-router script module when the store is not properly initialized.
- Update corresponding unit tests to reflect these changes.

This change ensures that the `interactivity-router` i18n messages are localized in a single place and removes the need to initialize them in the `core/router` store state.

Props jonsurrell, swissspidy, czapla, gziolo.
See .

git-svn-id: https://develop.svn.wordpress.org/trunk@59130 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 16:16:44 +00:00
Pascal Birchler
a1fae25abd I18N: Switch locale to admin locale when sending admin notifications.
If sending an email to the site administrator's email address, look up if a user with the same email exists and switch to that user's locale.
If not, falls back to the site locale as usual.

Props benniledl, swissspidy, mukesh27.
Fixes .


git-svn-id: https://develop.svn.wordpress.org/trunk@59128 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 15:50:19 +00:00
Pascal Birchler
f95e51d675 I18N: Fix script languages path for themes.
Remove hardcoded path added in [57922] which ignored the fact that themes can also use script translations.
They should not be affected even if plugins are installed outside the typical `wp-content/plugins` location. 

Props itapress, swissspidy.
Fixes .


git-svn-id: https://develop.svn.wordpress.org/trunk@59126 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 14:57:32 +00:00
bernhard-reiter
b1121f1e7d Block Hooks: Respect "multiple": false in hooked blocks.
If a prospective hooked block has its `multiple` block-supports field set to `false` (thus allowing only one instance of the block to be present), ensure that:

1. Only one instance of the block will be inserted if it's not yet present in the current context.
2. The block will not be inserted at all if an instance of it is already present in the current context.

As always in Block Hooks parlance, "context" denotes the containing template, template part, pattern, or navigation post that a hooked block is supposed to be inserted into.

The markup of a webpage that uses a Block Theme typically comprises a number of such contexts -- one template and any number of template parts, patterns, and navigation posts. Note that the limitation imposed by this changeset only applies on a per-context basis, so it's still possible that the resulting page contains more than one instance of a hooked block with `"multiple": false` set, as each context could contribute up to one such instance.

Props bernhard-reiter, jonsurrell, gziolo.
Fixes .

git-svn-id: https://develop.svn.wordpress.org/trunk@59124 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 12:21:31 +00:00
John Blackbourn
328284c086 Role/Capability: Introduce the user_can_for_blog() function.
This complements the existing user capability checking functions and enables checking a capability of any user on any site on a Multisite network.

Props tmanoilov, rajinsharwar, n8finch, johnbillion

Fixes 

git-svn-id: https://develop.svn.wordpress.org/trunk@59123 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 11:03:51 +00:00
Carlos Bravo
0780447814 Block bindings: Add canUpdateBlockBindings editor setting.
Adds a `canUpdateBlockBindings` editor setting that allows to decide if the user is able to create and modify bindings through the UI. By default, only admin users can do it, but it can be overridden with `block_editor_settings_all` filter.

Props santosguillamot, gziolo, jorbin, noisysocks, matveb, cbravobernal, youknowriad, mamaduka, timothyblynjacobs, peterwilsoncc, drivingralle.
Fixes .


git-svn-id: https://develop.svn.wordpress.org/trunk@59122 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 06:47:20 +00:00
Peter Wilson
e58c8e8259 General: Delete tests/phpunit/tests/formatting/wpTargetedLinkRel.php.
Really delete `tests/phpunit/tests/formatting/wpTargetedLinkRel.php` this time rather than leaving it hanging around as an empty file.

Follow up to [59120].

Props noisysocks.
See 



git-svn-id: https://develop.svn.wordpress.org/trunk@59121 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 05:27:06 +00:00
Peter Wilson
4aeab33dc8 General: Remove noopener from links opening in a new tab.
Removes the automatic addition of `rel="noopener noreferrer"` from links targeting a new tab or window, `target='_blank'`. Since this was introduced, supported browsers have changed their security policies and no longer allow the opened link to have JavaScript access to the previous tab.

Deprecates:

* `wp_targeted_link_rel()`
* `wp_targeted_link_rel_callback()`
* `wp_init_targeted_link_rel_filters()`: converted to a noop function
* `wp_remove_targeted_link_rel_filters()`: converted to a noop function

The deprecated functions are retained in `formatting.php` as in `SHORTINIT` mode the file is included while `deprecated.php` is not.

This also removes the `noopener` from links hard coded within the WordPress dashboard linking to documentation and other resources.

Props audrasjb, azaozz, dhruval04, dorzki, neo2k23, presskopp, sabernhardt, swissspidy, tobiasbg.
Fixes .


git-svn-id: https://develop.svn.wordpress.org/trunk@59120 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 05:17:54 +00:00
Peter Wilson
7e0d4c671c Media: Add short-circuit filter to attachment_url_to_postid().
Introduces the filter `pre_attachment_url_to_postid` to allow developers to short-circuit the function `attachment_url_to_postid()`.

The return values are expected to be an attachment ID, zero (`0`) to indicate no attachment was found or `null` to indicate the function should proceed as usual.

The function performs an expensive database query so developers making use of the function frequently may wish to use a custom table with appropriate indexes to reduce the load on their database server.

Props antpb, apermo, audrasjb, joedolson.
Fixes .


git-svn-id: https://develop.svn.wordpress.org/trunk@59118 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 03:17:31 +00:00
Peter Wilson
c1fe739334 Build/Test Tools: Re-order assertion parameters query block tests.
Corrects the order of the expected and actual values in several tests of the `build_query_vars_from_query_block()` function.

See .


git-svn-id: https://develop.svn.wordpress.org/trunk@59116 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 01:29:32 +00:00
Peter Wilson
b1db74a765 REST API/Editor: Support post formats in Query Block & Posts API.
Introduces post format support for both the Query Block with the new parameter `format`. In the `build_query_vars_from_query_block()` function, this is converted to a `post_format` taxonomy query passed to `WP_Query`.

Also introduces the `format` parameter to the REST API's Posts controller to support the feature in the Query block. The parameter type is an enumerated  string accepted the post formats supported by each post type.

Props poena, mukesh27, mamaduka, noisysocks, TimothyBlynJacobs.
Fixes .


git-svn-id: https://develop.svn.wordpress.org/trunk@59115 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-30 01:17:40 +00:00
Tonya Mork
a51f2e45c4 Code Modernization: Fix trigger_error() with E_USER_ERROR deprecation in TestXMLParser::parse().
PHP 8.4 deprecates the use of `trigger_errror()` with `E_USER_ERROR` as the error level, as there are a number of gotchas to this way of creating a `Fatal Error` (`finally` blocks not executing, destructors not executing).
The recommended replacements are either to use exceptions or to do a hard `exit`.

As this is a test-only class, do not have to take BC-breaks into account.

Also, as this is a test helper, throwing a exception is the most appropriate solution.

Reference:
* https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_e_user_error_to_trigger_error

Follow-up to [25002].

Props jrf.
See .

git-svn-id: https://develop.svn.wordpress.org/trunk@59109 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-27 19:58:49 +00:00
Tonya Mork
004379e56b Code Modernization: Fix trigger_error() with E_USER_ERROR deprecation in WP_Test_Stream::open().
PHP 8.4 deprecates the use of `trigger_errror()` with `E_USER_ERROR` as the error level, as there are a number of gotchas to this way of creating a `Fatal Error` (`finally` blocks not executing, destructors not executing).
The recommended replacements are either to use exceptions or to do a hard `exit`.

As this is a test-only class, do not have to take BC-breaks into account.

Also, as this is a test helper, throwing a exception is the most appropriate solution.

Reference:
* https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_e_user_error_to_trigger_error

Follow-up to [49230].

Props jrf.
See .

git-svn-id: https://develop.svn.wordpress.org/trunk@59108 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-27 19:51:31 +00:00
Tonya Mork
b0e35ecd28 Code Modernization: Fix trigger_error() with E_USER_ERROR deprecation in wp_trigger_error().
PHP 8.4 deprecates the use of `trigger_errror()` with `E_USER_ERROR` as the error level, as there are a number of gotchas to this way of creating a `Fatal Error` (`finally` blocks not executing, destructors not executing). The recommended replacements are either to use exceptions or to do a hard `exit`.

WP has its own `wp_trigger_error()` function, which under the hood calls `trigger_error()`. If passed `E_USER_ERROR` as the `$error_level`, this will hit the PHP 8.4 deprecation.

Now, there were basically three options:
* Silence the deprecation until PHP 9.0 and delay properly solving this until then. This would lead to an awkward solution, as prior to PHP 8.0, error silencing would apply to all errors, while, as of PHP 8.0, it will no longer apply to fatal errors. It also would only buy us some time and wouldn't actually solve anything.

* Use `exit($status)` when `wp_trigger_error()` is called with `E_USER_ERROR`. This would make the code untestable and would disable handling of these errors via custom error handlers, which makes this an undesirable solution.

* Throw an exception when `wp_trigger_error()` is called with `E_USER_ERROR`. This makes for the most elegant solution with the least BC-breaking impact, though it does open it up to the error potential being "caught" via a `try-catch`. That's not actually a bad thing and is likely to only happen for those errors which can be worked around, in which case, it's a bonus that that's now possible.

The third option is implemented which:
* Introduces a new `WP_Exception` class.
* Starts using `WP_Exception` in the `wp_trigger_error()` function when the `$error_level` is set to `E_USER_ERROR`.

This change is covered by pre-existing tests, which have been updated to expect the exception instead of a PHP error.

Why not use `WP_Error`?

Well, for one, this would lead to completely different behaviour (BC).

As `WP_Error` doesn't extend `Exception`, the program would not be stopped, but would continue running, which would be a much bigger breaking change and carries security risks. `WP_Error` also doesn't natively trigger displaying/logging of the error message, so in that case, it would still need an `exit` with the error message, bringing us back to point 2 above.

Introducing `WP_Exception` provides (essentially) the same behaviour in that it retains the fatal error and error message displaying/logging behaviors. It also introduces a base Exception class, from which future exception classes can extend.

References:
* https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_e_user_error_to_trigger_error
* https://www.php.net/manual/en/migration80.incompatible.php

Follow-up to [56530].

Props jrf, hellofromTonya.
See .

git-svn-id: https://develop.svn.wordpress.org/trunk@59107 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-27 19:26:15 +00:00
Tonya Mork
9a9ca41ddd Code Modernization: Fix trigger_error() with E_USER_ERROR deprecation in Text_Diff::_check().
PHP 8.4 deprecates the use of `trigger_errror()` with `E_USER_ERROR` as the error level, as there are a number of gotchas to this way of creating a `Fatal Error` (`finally` blocks not executing, destructors not executing). The recommended replacements are either to use exceptions or to do a hard `exit`.

This is an unmaintained external dependency; thus, the fix is made in the WP specific copy of the dependency.

Now, there were basically three options:
* Silence the deprecation until PHP 9.0 and delay properly solving this until then.
    This would lead to an awkward solution, as prior to PHP 8.0, error silencing would apply to all errors, while, as of PHP 8.0, it will no longer apply to fatal errors.
    It also would only buy us some time and wouldn't actually solve anything.
* Use `exit($status)`.
    This would make the code untestable and would disable handling of these errors via custom error handlers, which makes this an undesirable solution.
* Throw an exception.
    This makes for the most elegant solution with the least BC-breaking impact.

The third option is implemented which:
* Introduces a new `Text_Exception` class.
* Starts using that in the `Text_Diff::_check()` method in all applicable places.
* Adds tests for the first two error conditions.

References:
* https://wiki.php.net/rfc/deprecations_php_8_4#deprecate_passing_e_user_error_to_trigger_error
* https://www.php.net/manual/en/migration80.incompatible.php

Follow-up to [59070], [52978], [7747].

Props jrf.
See .

git-svn-id: https://develop.svn.wordpress.org/trunk@59105 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-27 17:51:49 +00:00
bernhard-reiter
2952e563aa Block Hooks: apply_block_hooks_to_content in Patterns, Templates.
In the Patterns registry, use `apply_block_hooks_to_content` (introduced in [58291])  instead of the `WP_Block_Patterns_Registry` class's private `get_content` method. (The latter is removed as part of this changeset.)

In a similar vein, use `apply_block_hooks_to_content` in the `_build_block_template_result_from_file` and `_build_block_template_result_from_post` functions, respectively.

For that to work, `apply_block_hooks_to_content` is amended to inject the `theme` attribute into Template Part blocks, even if no hooked blocks are present.

This kind of centralization is required as a preparation for .

Props bernhard-reiter, jonsurrell.
See .

git-svn-id: https://develop.svn.wordpress.org/trunk@59101 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-27 09:18:46 +00:00
Dennis Snell
1e21ecedf1 HTML API: Switch to HTML namespace when entering Integration Points.
When encountering inline SVG and MathML content in an HTML document, there are certain "integration points" which transition back into the HTML parsing ruleset. Previously, the HTML API was incorrectly switching into the namespace of the element transitioning into that ruleset.

In this patch, the correct transition is made, where all integration points refer to HTML rules, while non-integration points refer to the rules of the namespace corresponding to the token itself.

Developed in https://github.com/wordpress/wordpress-develop/pull/7425
Discussed in https://core.trac.wordpress.org/ticket/61576

Props dmsnell, jonsurrell.
See .


git-svn-id: https://develop.svn.wordpress.org/trunk@59099 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-27 00:42:47 +00:00
Michal Czaplinski
bbec266c74 Revert [59097] because it was renaming a public method that should be deprecated instead.
git-svn-id: https://develop.svn.wordpress.org/trunk@59098 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-26 19:35:26 +00:00
Michal Czaplinski
ad1fabe417 Interactivity API: Move interactivity-router i18n strings to Script Module data.
Moves the 'loading' and 'loaded' i18n strings for the `interactivity-router` to the script module data via the `script_module_data_@wordpress/interactivity-router` filter.

Key changes:

- Add the `filter_script_module_interactivity_router_data()` method, hooked into the `script_module_data_@wordpress/interactivity-router` filter, to set the `i18n` data with the 'loading' and 'loaded' messages.
- Rename the `print_router_loading_and_screen_reader_markup()` method to `print_router_markup()` and remove the screen reader markup from it because it's no longer needed.
- Remove the `loading` and `loaded` strings from the `core/router` store state because they're no longer needed.
- Initialize the `core/router` store with a minimal navigation object to prevent errors in the interactivity-router script module when the store is not properly initialized.
- Update corresponding unit tests to reflect these changes.

This change ensures that the `interactivity-router` i18n messages are localized in a single place and removes the need to initialize them in the `core/router` store state.

Props jonsurrell, swissspidy, czapla. 
See .


git-svn-id: https://develop.svn.wordpress.org/trunk@59097 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-26 17:53:11 +00:00
Carlos Bravo
d9cb6e7e9d Block bindings: Ensure block receives __default bindings when render.
Fixes an issue with the image block when using pattern overrides, where the image block with overrides enabled was not outputting all the expected image attributes. Ensures that the `process_block_bindings` method returns any updates to the block's binding metadata along with other computed attributes.

Props talldanwp, cbravobernal, santosguillamot, mukesh27, gziolo.

Fixes .



git-svn-id: https://develop.svn.wordpress.org/trunk@59095 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-26 14:49:13 +00:00
Greg Ziółkowski
7d0e751ffb Editor: Default attribute value not used with get_block_wrapper_attributes
Ensures that the default values defined in the schema for block attributes are used when rendering the output of the block with `get_block_wrapper_attributes` helper.

Props gziolo, jonsurrell, youknowriad, ryelle.
Fixes .



git-svn-id: https://develop.svn.wordpress.org/trunk@59093 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-26 12:45:41 +00:00
Tonya Mork
9e290835d6 Canonical: Redirect when front page's paginated states not found.
Perform a canonical redirect for an invalid pagination request of a static front page.

When a site has a static front page assigned and that page has a `<!--nextpage-->` within its content, previously accessing non-existing pages (e.g. `example.com/page/3/`) did not redirect or return a 404 or 301. This changeset resolves that issue by performing a canonical redirect.

Unit tests are also included for this specific use case and to ensure the fix does not affect a blog listing home page.

Follow-up to [47738], [47727], [34492].

Props dd32, audrasjb, chaion07, hellofromTonya, joemcgill, lukecarbis, Mte90, mukesh27, peterwilsoncc, rajinsharwar, SergeyBiryukov. 
Fixes .
See meta#5184.

git-svn-id: https://develop.svn.wordpress.org/trunk@59091 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-25 19:35:20 +00:00
Sergey Biryukov
7f4fd30dff Build/Test Tools: Only require the WordPress Importer plugin when running core tests.
This allows other users of the WordPress unit test suite framework to run their own unit tests without needing the WordPress Importer plugin, which should only be a requirement if running core tests.

Follow-up to [59085].

Props bjorsch.
Fixes .

git-svn-id: https://develop.svn.wordpress.org/trunk@59086 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-24 19:15:33 +00:00
Sergey Biryukov
60a66de6ec Build/Test Tools: Check if the WordPress Importer plugin is installed in test bootstrap.
If a hard requirement for the test suite is not fulfilled, running the tests should be blocked from the test bootstrap. A test should only fail when it doesn't produce the expected result.

Since the WordPress Importer plugin is considered a hard requirement for the test suite at this time, this commit moves the check whether the plugin is installed from individual tests to the test bootstrap.

Includes defining a global constant for the path to the file for reuse in the tests.

Reference: [https://make.wordpress.org/core/handbook/contribute/git/#unit-tests Core Contributor Handbook: The Code Repository (Git): Unit Tests].

Follow-up to [40531], [40532], [41090], [41169], [48592], [49535], [49571].

Props jrf, hellofromTonya.
See .

git-svn-id: https://develop.svn.wordpress.org/trunk@59085 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-24 18:09:41 +00:00
Timothy Jacobs
ec80646878 App Passwords: Don't prevent non-unique App Password names.
In [50030] we enforced that Application Passwords have unique names. This was done with the assumption that applications would not connect to a user multiple times. However, in practice we've seen applications run into issues with the unique name constraint. Depending on the app, they may not know if they've been authorized before, or they may intentionally allow connecting multiple times. To prevent friction, App developers need to make their App Name unique, and in doing so often include things like the current date & time, which is already included in the App Passwords list table.

This commit removes this requirement to simplify usage of the Authorize Application flow.

Props mark-k, Boniu91, timothyblynjacobs, peterwilsoncc.
Fixes .


git-svn-id: https://develop.svn.wordpress.org/trunk@59084 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-24 16:38:36 +00:00
Greg Ziółkowski
0b8b80449f Build: Prepare for more Script Modules
This is a companion to https://github.com/WordPress/gutenberg/pull/65460 that requires syncing in WordPress Core. Namely, the block-library changes require registration with their updated script module IDs so that the blocks continue to work correctly.

They key improvement is script modules registration is handled in one central place, and a combined asset file is used to improve the performance by avoiding multiple disk operations for every individual file.

Props jonsurrell, gziolo, wildworks, noisysocks.
See , .



git-svn-id: https://develop.svn.wordpress.org/trunk@59083 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-24 07:33:55 +00:00
Greg Ziółkowski
fd104aed14 Comments: Pass $page as argument to comments functions
Removes query alteration from `build_comment_query_vars_from_block` by introducing a new way to pass the `$page` as argument to functions handling pagination for the comments.

Props cybr, santosguillamot, bernhard-reiter, gziolo.
Fixes .



git-svn-id: https://develop.svn.wordpress.org/trunk@59081 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-23 12:48:32 +00:00
Greg Ziółkowski
805b9333f2 Block Bindings: Adds context needed by sources during its processing
Extends block context during block bindings processing. This implies that the context is extended ONLY for the blocks where bindings are defined and only when rendered on the page.

Props santosguillamot, gziolo, artemiosans, cbravobernal.
Fixes .




git-svn-id: https://develop.svn.wordpress.org/trunk@59080 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-23 12:33:14 +00:00
Dennis Snell
03b12dc311 HTML API: Add normalize() to give us the HTML we always wanted.
HTML often appears in ways that are unexpected. It may be missing implicit tags, may have unquoted, single-quoted, or double-quoted attributes, may contain duplicate attributes, may contain unescaped text content, or any number of other possible invalid constructions. The HTML API understands all fo these inputs, but downline parsers may not, and HTML snippets which are safe on their own may introduce problems when joined with other HTML snippets.

This patch introduces the `serialize()` method on the HTML Processor, which prints a fully-normative HTML output, eliminating invalid markup along the way. It produces a string which contains every missing tag, double-quoted attributes, and no duplicates. A `normalize()` static method on the HTML Processor provides a convenient wrapper for constructing a fragment parser and immediately serializing.

Subclasses relying on the `serialize_token()` method may perform structural HTML modifications with as much security as the upcoming `\Dom\HTMLDocument()` parser will, though these are not
able to provide the full safety that will eventually appear with `set_inner_html()`.

Further work may explore serializing to XML (which involves a number of other important transformations) and adding constraints to serialization (such as only allowing inline/flow/formatting elements and text).

Developed in https://github.com/wordpress/wordpress-develop/pull/7331
Discussed in https://core.trac.wordpress.org/ticket/62036

Props dmsnell, jonsurrell, westonruter.
Fixes .


git-svn-id: https://develop.svn.wordpress.org/trunk@59076 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-20 22:30:04 +00:00
Dennis Snell
675a1aa5e5 HTML API: Add get_full_comment_text() method.
Previously, there were a few cases where the modifiable text read from an HTML comment differs slightly from the parsed value of its inner text in a browser. This is due to the specific way that invalid HTML syntax tokens become "bogus comments."

This patch introduces a new method to the Tag Processor to allow differentiating these specific cases, such as when copying or serializing HTML from one source to another. Similar code has already been in use in the html5lib tests, and this patch simplifies the test runner, evidencing the fact that this method was already needed.

Developed in https://github.com/wordpress/wordpress-develop/pull/7342
Discussed in https://core.trac.wordpress.org/ticket/62036

Props dmsnell, jonsurrell.
See .


git-svn-id: https://develop.svn.wordpress.org/trunk@59075 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-20 20:21:59 +00:00
Sergey Biryukov
1eb5f61c9e Editor: Restore the merging of TinyMCE settings in wp_tinymce_inline_scripts().
This ensures that the function applies the `wp_editor_settings` filter and merges the resulting array with the rest of TinyMCE init settings.

Includes a unit test to verify that the settings are merged correctly after adding the assignment of `array_merge()` result that was missed in the initial commit.

Follow-up to [44265], [59033].

Props kkmuffme, akshat2802, davidbaumwald, SergeyBiryukov.
Fixes .

git-svn-id: https://develop.svn.wordpress.org/trunk@59074 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-20 14:07:11 +00:00
Robert Anderson
35907da951 Editor: Add plugin template registration API and improve theme overrides for plugin-registered templates
This commit introduces a new API to allow plugins to easily register block
templates with `wp_register_block_template()` and the
`WP_Block_Templates_Registry` class, addressing the complexity of hooking into
multiple filters. It also ensures plugin-registered templates overridden by
themes fall back to the plugin-provided title and description when the theme
doesn't define them.

See https://github.com/WordPress/gutenberg/pull/61577.
See https://github.com/WordPress/gutenberg/pull/64610.

Fixes .
Props aljullu, peterwilsoncc, antonvlasenko, azaozz, youknowriad, noisysocks.


git-svn-id: https://develop.svn.wordpress.org/trunk@59073 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-20 02:05:50 +00:00
Peter Wilson
d46067a776 External Libraries: Test registered script versions match package.json.
Expands tests to ensure the version number of packages updated via NPM matches the version number used for registering the script in the script loader.

This adds tests for (by their registered name in WordPress):

* backbone
* clipboard
* hoverIntent
* hoverintent-js
* imagesloaded
* jquery-color
* jquery-core
* jquery-form
* masonry
* react-jsx-runtime
* underscore
* wp-polyfill-dom-rect
* wp-polyfill-element-closest
* wp-polyfill-fetch
* wp-polyfill-formdata
* wp-polyfill-inert
* wp-polyfill-node-contains
* wp-polyfill-object-fit
* wp-polyfill-url


This expands on the earlier tests introduced for:

* lodash
* moment
* react
* react-dom
* regenerator-runtime

An additional test is added to ensure that the data provider for these tests is maintained as libraries are added via package.json.

`@wordpress/*` scripts are excluded from these tests as wp-scripts generates a version number automatically based on the file's contents.

Additionally, the version of element-closest listed in package.json is updated to use a fixed version rather than a range. This reflects the current practice of WordPress to define the specific version in core. For the avoidance of doubt, this does not affect the version shipped in WordPress.

Follow up to [57185].

Props peterwilsoncc, jorbin.
Fixes .


git-svn-id: https://develop.svn.wordpress.org/trunk@59071 602fd350-edb4-49c9-b593-d223f7449a82
2024-09-20 00:50:51 +00:00