6262 Commits

Author SHA1 Message Date
Peter Wilson
c1ffe3309a Users: Always use HTTPS URLs for Gravatar links.
Modifies gravatar image URLs to always use the HTTPS version from secure.gravatar.com. 

Gravatar now redirects HTTP image requests to their HTTPS equivalent, resulting in redirects for sites running over an HTTP connection (`is_ssl() === false`). Since the introduction of HTTP/2 the use of sub-domains for different hashes ([1-3].gravatar.com) now represents a performance hinderance rather than improvement.

The scheme passed to `get_avatar_data()` is now ignored for the generation of Gravatar URLs but the setting retained to avoid introducing bugs for sites using either local avatars or third party providers.

Props neoxx, SergeyBiryukov, sippis, peterwilsoncc, mukesh27, costdev, dd32.
Fixes #37454.



git-svn-id: https://develop.svn.wordpress.org/trunk@58822 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-29 01:57:11 +00:00
Peter Wilson
c41304d73c General: Introduce wp_get_wp_version() to get unmodified version.
Introduces `wp_get_wp_version()` to get an unmodified value of `$wp_version` from `wp-includes/version.php`. Some plugins modify the global in an attempt to improve security through obscurity. This practice can cause errors in WordPress so the ability to get an unmodified version is needed.

Replaces instances within the code base in which `version.php` was required in order to get an unmodified value. `script-loader.php` is intentionally excluded from the replacements as the function is not always available to the file.

Props debarghyabanerjee, afragen, costdev.
See #61627.



git-svn-id: https://develop.svn.wordpress.org/trunk@58813 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-27 00:25:44 +00:00
Sergey Biryukov
ed59f778ba General: Cast $max_depth and $depth to an integer in the Walker class.
This ensures that the arguments are correctly interpreted when passed as a query string, i.e. when `wp_parse_args()` is involved. For example, `wp_list_pages( 'depth=0' )` should display a list of all pages to the maximum depth.

Follow-up to [57848].

Props freibergergarcia, peterwilsoncc, ahortin.
Fixes #61749.

git-svn-id: https://develop.svn.wordpress.org/trunk@58812 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-26 07:54:26 +00:00
Peter Wilson
b38541de39 Options, Meta APIs: Prevent Single Site installs using network notoptions cache.
Modifies the caching of `notoptions` in `delete_network_option()` to ensure that the network cache is bypassed on single site installs.

On single site installs the incorrect caching was causing the `notoptions` cache to remain populated once a deleted option was subsequently added or updated.

Follow up to [58782].

Props bjorsch, pbearne.
Fixes #61730.
See #61484.



git-svn-id: https://develop.svn.wordpress.org/trunk@58811 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-25 23:02:47 +00:00
Sergey Biryukov
5ea8ba0bf0 Comments: Only type cast a scalar $comment_id in get_comment_author_link().
This aims to resolve a fatal error when the incoming `$comment_id` is an instance of `WP_Comment` (or any object) without a `comment_ID` property defined, or if it's empty:
{{{
Object of class WP_Comment could not be converted to string
}}}

This commit mirrors the changes previously made for a similar code fragment in `get_comment_author()`.

Includes:
* Unit tests to demonstrate the fatal error and validate the fix.
* Changing the default value for a non-existent comment ID in `get_comment_author()` from an empty string to zero as a numeric string, for consistency with `get_comment_ID()`.

Follow-up to [52818], [55289], [58335], [58755].

Props narenin, mukesh27, iflairwebtechnologies, umeshsinghin, SergeyBiryukov.
Fixes #61715.

git-svn-id: https://develop.svn.wordpress.org/trunk@58809 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-25 22:36:13 +00:00
Felix Arntz
4acefacbf6 Taxonomy: Ensure get_edit_term_link() produces the correct result when called without taxonomy.
This fixes an oversight missed in [36646].

Props debarghyabanerjee.
Fixes #61726.
See #35922.


git-svn-id: https://develop.svn.wordpress.org/trunk@58807 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-24 21:40:59 +00:00
Dennis Snell
5351cd20f3 HTML API: Add TABLE support in HTML Processor.
As part of work to add more spec support to the HTML API, this patch adds
support for various table-related insertion modes. This includes support
for tables, table rows, table cells, table column groups, etc...

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

Props: dmsnell, jonsurrell.
See #61576.


git-svn-id: https://develop.svn.wordpress.org/trunk@58806 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-24 18:39:46 +00:00
Sergey Biryukov
edcd7d285f Tests: Use more specific assertions in get_comment_author() tests.
Follow-up to [58335].

See #61530.

git-svn-id: https://develop.svn.wordpress.org/trunk@58803 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-24 15:08:08 +00:00
bernhard-reiter
5a76260c3c block.json: Allow passing PHP filename as variations field.
Previously, the `variations` field in a block.json file could be used to provide a static list of the block's variations (i.e., an array). Alternatively, the block's `variation_callback` could be set during server-side block registration to point to a PHP function to generate those variations.

This changeset makes it so that the block.json `variations` field can be alternatively set to a string, which will be interpreted as the filename of a PHP file that generates the variations.

It is loosely modeled after [54132], which introduced the `render` field for `block.json`, as a way to point to a PHP file instead of providing a `render_callback`.

Props bernhard-reiter, gziolo.
Fixes #61280.

git-svn-id: https://develop.svn.wordpress.org/trunk@58801 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-24 14:09:58 +00:00
Michal Czaplinski
ef71a9ed39 Tests: Removes the obsolete Block Binding unregistration
Follow-up to [58798].
Props santosguillamot, cbravobernal, gziolo.
See #61641.


git-svn-id: https://develop.svn.wordpress.org/trunk@58799 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-24 11:29:58 +00:00
Carlos Bravo
e0ed30f1c8 Block Bindings: Adds sources in the editor settings to consume them in the client
Adds a new property `blockBindingsSources` to the editor settings to expose the block bindings sources registered in the server.

Props santosguillamot, cbravobernal, gziolo, artemiosans.
Fixes #61641.



git-svn-id: https://develop.svn.wordpress.org/trunk@58798 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-24 10:57:27 +00:00
Robert Anderson
a8915f8893 Block themes: Enable block-level background image styles
Allows defining background images for blocks in theme.json.

Syncs PHP changes from https://github.com/WordPress/gutenberg/pull/60100.

Props ramonopoly, aaronrobertshaw.
Fixes #61588.


git-svn-id: https://develop.svn.wordpress.org/trunk@58797 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-24 00:24:31 +00:00
bernhard-reiter
ddd78e3851 Block Hooks: Don't erase post content if it isn't changed by client.
The `inject_ignored_hooked_blocks_metadata_attributes` filter that is attached to both the `rest_pre_insert_wp_template` and `rest_pre_insert_wp_template_part` hooks receives a `stdClass` object from the Templates REST API controller that contains all fields that the client would like to modify when making a `POST` request (plus the `id` to identify the relevant template or template part, respectively).

There are cases when the `post_content` field is not set, e.g. when the client would like to rename an existing template (in which case it would only set the `title` field).

Prior to this changeset, the filter would erroneously apply the Block Hooks algorithm to the non-existent `post_content` field regardless, which would result in it being set to the empty string `''`. As a consequence, renaming a template would have the unwanted side effect of wiping its contents.

This changeset fixes the issue by returning early from the filter if the `post_content` field is not set.

Props alshakero, bernhard-reiter.
Fixes #61550.

git-svn-id: https://develop.svn.wordpress.org/trunk@58785 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-23 13:41:15 +00:00
Riad Benguella
edfc2b0d89 REST API: Remove post status prefix from REST API responses.
When using the /posts or /pages endpoints, for private posts or pages, you get the following title property: { raw: "Some title", rendered: "Private: Some title" }
this commit removes the prefix from rendered private posts titles (just like what we do for protected posts)

Props youknowriad, swissspidy, timothyblynjacobs, sergeybiryukov, ramonopoly.
Fixes #61639.

git-svn-id: https://develop.svn.wordpress.org/trunk@58783 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-23 07:49:54 +00:00
Peter Wilson
fc33ab6999 Options, Meta APIs: Prime notoptions cache when deleting options.
Prime the `notoptions` cache within `delete_option` and `delete_network_option` to avoid the need for a database query if `get_option` or `get_network_option` is subsequently called.

Adds some associated tests to ensure that an option is cleared from the notoptions cache when an option is added either via `add_option`, `update_option` or their network option equivalent.

Props pbearne, mukesh27.
Fixes #61484.



git-svn-id: https://develop.svn.wordpress.org/trunk@58782 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-23 00:25:19 +00:00
Dennis Snell
7c6c0d7ee5 HTML API: Remove empty test file after adding support for missing elements.
When support was added for the remaining tags in the IN BODY insertion mode, a test
file indicating that support was necessary for certain parts of the parser was
removed, but it wasn't removed from SVN when sending over the patch from `git`.

This patch removes that empty file so that the WPCS workflows pass.

Discussed in https://core.trac.wordpress.org/ticket/61576

Follow-up to [58779].

See #61576.


git-svn-id: https://develop.svn.wordpress.org/trunk@58780 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-22 22:49:52 +00:00
Dennis Snell
db30ce9c8c HTML API: Add missing tags in IN BODY insertion mode to HTML Processor.
As part of work to add more spec support to the HTML API, this patch adds
support for the remaining missing tags in the IN BODY insertion mode. Not
all of the added tags are supported, because in some cases they reset the
insertion mode and are reprocessed where they will be rejected.

This patch also improves the support of `get_modifiable_text()`, removing
a leading newline inside a LISTING, PRE, or TEXTAREA element.

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

Props dmsnell, jonsurrell, westonruter.
See #61576.


git-svn-id: https://develop.svn.wordpress.org/trunk@58779 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-22 22:22:03 +00:00
Sergey Biryukov
68b23387d7 Media: Check if content URL includes a hostname in wp_calculate_image_srcset().
This resolves an `Undefined array key "host"` PHP warning if `WP_CONTENT_URL` is set to a relative URL.

Follow-up to [58097].

Props mattraines, narenin, pamprn, SergeyBiryukov.
Fixes #61690.

git-svn-id: https://develop.svn.wordpress.org/trunk@58773 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-20 13:30:52 +00:00
Tonya Mork
f600e5409f Coding Standards: Capitalize inline comment in get_comment_author() test dataset.
Per coding standards, capitalizes the first character of the inline comment in the test dataset.

Follow-up to [58755].

Props SergeyBiryukov.
See #61681.

git-svn-id: https://develop.svn.wordpress.org/trunk@58756 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-18 15:17:58 +00:00
Tonya Mork
9aa777d9f4 Comments: Fix fatal error when get_comment_author() receives an object with no comment_id.
[58335] introduced `(string)` type casting of the passed in `$comment_id` value. If `$comment_id` is a scalar, it works as expected. But if it's an `object`, the following fatal error is thrown:

{{{
Object of class WP_Comment could not be converted to string
}}}

This fatal error happens when the incoming `$comment_id` is an instance of `WP_Comment` (or any object) without a `comment_ID` (empty). 

This changeset adds tests to demonstrate the fatal error and validate the fix.

It fixes the fatal error by restructuring the ternary checks into an `if/elseif/else` structure for the 3 paths:

- When `$comment->comment_ID` is not empty, then it uses the property.
- When `$comment_id` is scalar, then it type casts it to a `string`.
- Else, the default is an empty `string`.

Follow-up to [58335], [41127], [52818].

Props ambrosiawt, hellofromTonya, jorbin, mukesh27, SergeyBiryukov.
Fixes #61681.

git-svn-id: https://develop.svn.wordpress.org/trunk@58755 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-18 15:08:01 +00:00
Robert Anderson
842a353673 Block Themes: Avoid specificity bump for top-level element-only selectors
Prevent issues (e.g. links being underlined) caused by a bump in CSS
specificity for top-level element-only global element styles.

Backports the PHP changes from https://github.com/WordPress/gutenberg/pull/63403.

Fixes #61630.
Fixes #61660.
Props aaronrobertshaw, andrewserong, noisysocks.


git-svn-id: https://develop.svn.wordpress.org/trunk@58749 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-18 06:41:29 +00:00
Dennis Snell
48c0c96846 Fix phpdoc nullable types in some files.
It was found that in several places in the HTML API and its supporting files,
the wrong form of type annotation was used for optional parameters.

Instead of using `?type`, this patch uses `type|type-of-default-value` instead,
noting where important if the parameter is optional, and if so, what its default
value is.

Developed in https://github.com/WordPress/wordpress-develop/pull/7031
Discussed in https://core.trac.wordpress.org/ticket/61399

Props dmsnell, jonsurrell.
See #61399.


git-svn-id: https://develop.svn.wordpress.org/trunk@58742 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-17 00:51:34 +00:00
Dennis Snell
8f11947d79 HTML API: Test code improvements in virtual node breadcrumb tests.
Follow-up after feedback to newly-introduced tests,
mostly to enhance the message when the tests fail.

Developed in https://github.com/WordPress/wordpress-develop/pull/7030
Discussed in https://core.trac.wordpress.org/ticket/61646

Follow-up to [58592].

Props dmsnell, jonsurrell.
See #61646.


git-svn-id: https://develop.svn.wordpress.org/trunk@58741 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-17 00:33:21 +00:00
Dennis Snell
2f1cf1f3db HTML API: Remove leading whitespace after removing class names.
In part of a larger review of CSS semantics and behaviors, this patch
takes the opportunity to remove leading whitespace in an updated class
attribute after the first class in the attribute has been removed.

Previously, if the first class name had been removed, the whitespace
that formerly followed it would remain in the class attribute. This
stood in contrast to removing other class names, which removed their
associated whitespace.

There should be no semantic or functional changes in this patch, only
a slightly-large diff for modified HTML documents that looks prettier
when removing the first class name in a class attribute.

Developed in https://github.com/WordPress/wordpress-develop/pull/6933
Discussed in https://core.trac.wordpress.org/ticket/61531

Props dmsnell, jonsurrell.
See #61531.


git-svn-id: https://develop.svn.wordpress.org/trunk@58740 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-17 00:10:52 +00:00
Tonya Mork
81702ce6de Tests: Use data provider in Tests_Interactivity_API_wpInteractivityAPIFunctions.
Refactors the following tests to use a data provider with named test cases:
* `test_wp_interactivity_data_wp_context_with_different_arrays()`
* `test_wp_interactivity_data_wp_context_with_different_arrays_and_a_namespace()`
* `test_wp_interactivity_data_wp_context_with_json_flags()`

This is better as:
1. One failing test will not block the other tests from running.
2. Each test is now referenced by name in any error message, making it more straight forward to see which test failed.
3. The test no longer contains multiple assertions.
3. It makes it more straight forward to add additional tests.

Follow-up to [58594], [58234], [57762], [57743], [57742], [57563].

Props jrf.
See #61530.

git-svn-id: https://develop.svn.wordpress.org/trunk@58739 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-16 18:37:46 +00:00
Tonya Mork
a6d5694cde Tests: Don't declare nested named function in Tests_Interactivity_API_wpInteractivityAPIFunctions.
Once the `test_process_directives_when_block_is_filtered()` method has run, the named `test_render_block_data()` function declared nested within becomes part of the global namespace, which could cause problems for other tests.

Quite apart from the fact that the name starting with `test_`  is confusing (as methods prefixed with `test_` are supposed to be test methods to be run by PHPUnit).

Using a closure for this callback fixes the issue. Declared as `static` for a micro-optimization.

Follow-up to [57826].

Props jrf, hellofromTonya.
See #61530.

git-svn-id: https://develop.svn.wordpress.org/trunk@58738 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-16 18:20:43 +00:00
Dennis Snell
bd61b0bf23 HTML API: Add tests confirming comment behavior in HTML Processor.
There was a bug-fix late in the 6.6 cycle in the HTML Processor which
resolved an issue with the wrong name being reported when paused at
processing-instruction look-alike invalid comments, but no tests were
added to enforce the correct behaviors.

This patch adds the missing tests.

Developed in https://github.com/WordPress/wordpress-develop/pull/6765
Discussed in https://core.trac.wordpress.org/ticket/61530

Follow-up to [58304], [58558].

Props dmsnell, jonsurrell.
See #61530.


git-svn-id: https://develop.svn.wordpress.org/trunk@58734 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-16 16:00:38 +00:00
Tonya Mork
36ac310d82 HTML API: Fix "${var} in strings" deprecation notice in html5lib test.
Changeset [58712] introduced the following compile time PHP deprecation notice on >= PHP 8.2 test runs:

{{{
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in /var/www/tests/phpunit/tests/html-api/wpHtmlProcessorHtml5lib.php on line 257
PHPUnit 9.6.20 by Sebastian Bergmann and contributors.
}}}

The `${` syntax for string interpolation was deprecated in PHP 8.2 and should not be used anymore.

Ref: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation

Follow-up to [58712].

Props jrf.
See #61530, #59654, #61576.

git-svn-id: https://develop.svn.wordpress.org/trunk@58733 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-16 14:33:17 +00:00
bernhard-reiter
a87bac209b Interactivity API: Use Script Modules filter for store & config data.
A dedicated API exists for passing data to Script Modules implemented in changeset [58579].
Use this Core API instead of a custom implementation for Interactivity API to pass data to the client.

Developed in https://github.com/WordPress/wordpress-develop/pull/6683.

Props jonsurrell, gziolo, luisherranz, cbravobernal.
Fixes #61512.

git-svn-id: https://develop.svn.wordpress.org/trunk@58729 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-16 09:42:38 +00:00
Sergey Biryukov
8616ad913a Filesystem API: Add a return value for wp_delete_file().
This addresses a discrepancy where using `unlink()` allows for checking if it was successful via the return value, but `wp_delete_file()` did not have a return value, making it impossible to verify the result without doing overhead checks if the file still exists.

This also brings more consistency with the other `wp_delete_*()` functions, specifically:

* `wp_delete_file_from_directory()`
* `wp_delete_post()`
* `wp_delete_post_revision()`
* `wp_delete_attachment()`
* `wp_delete_attachment_files()`
* `wp_delete_comment()`
* `wp_delete_nav_menu()`
* `wp_delete_term()`
* `wp_delete_site()`
* `wp_delete_user()`

Includes adding basic unit tests for `wp_delete_file()`.

Follow-up to [31575].

Props bedas, debarghyabanerjee, mukesh27, SergeyBiryukov.
Fixes #61590.

git-svn-id: https://develop.svn.wordpress.org/trunk@58715 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-13 05:01:47 +00:00
Dennis Snell
4eec5cb978 HTML API: Simplify breadcrumb accounting.
Since the HTML Processor started visiting all nodes in a document, both
real and virtual, the breadcrumb accounting became a bit complicated
and it's not entirely clear that it is fully reliable.

In this patch the breadcrumbs are rebuilt separately from the stack of
open elements in order to eliminate the problem of the stateful stack
interactions and the post-hoc event queue.

Breadcrumbs are greatly simplified as a result, and more verifiably
correct, in this construction.

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

Follow-up to [58590].

Props bernhard-reiter, dmsnell.
See #61576.


git-svn-id: https://develop.svn.wordpress.org/trunk@58713 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-12 22:18:16 +00:00
Dennis Snell
cd3bf1b6fc HTML API: Join successive text nodes in html5lib test representation.
Many tests from the html5lib test suite fail because of differences in
text handling between a DOM API and the HTML API, even though the
semantics of the parse are equivalent. For example, it's possible in
the HTML API to read multiple successive text nodes when the tokens
between them are ignored.

The test suite didn't account for this and so was failing tests. This
patch improves the construction of the representation to compare
against the test suite so that those tests don't fail inaccurately.

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

Props bernhard-reiter, dmsnell, jonsurrell.
See #61576.


git-svn-id: https://develop.svn.wordpress.org/trunk@58712 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-12 21:58:20 +00:00
Joe McGill
7f697bceb1 Editor: Revert caching of global styles for blocks.
This reverts [58334] to fix a bug where edits to block styles made in the site editor were not showing in the front end.

Props joemcgill, spacedmonkey, andrewserong, hellofromtonya, audrasjb.
See #59595.


git-svn-id: https://develop.svn.wordpress.org/trunk@58710 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-12 19:24:12 +00:00
Sergey Biryukov
ad135d5f0a KSES: Add opacity to the list of safe CSS properties.
Original PR from Gutenberg repository:
* [https://github.com/WordPress/gutenberg/pull/59891 #59891 Update overlay step function in cover block]

Reference: [https://developer.mozilla.org/en-US/docs/Web/CSS/opacity MDN Web Docs: opacity].

Props sunil25393, wildworks, poena, Mamaduka, presstoke.
Fixes #61536.

git-svn-id: https://develop.svn.wordpress.org/trunk@58709 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-12 03:34:52 +00:00
Isabel Brison
e41df7cb12 Editor: enqueue block custom CSS only when block renders on the page.
Updates the global styles custom CSS handling logic to be consistent with other global styles and take advantage of conditional enqueuing of block styles.

Props isabel_brison, aaronrobertshaw, andrewserong.
Fixes #61395.


git-svn-id: https://develop.svn.wordpress.org/trunk@58703 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-10 06:17:44 +00:00
Ella
4a2c9c5389 Section Styles: Fix ref values within block style variations.
Fixes #61589.
Fixes https://github.com/WordPress/wordpress-develop/pull/6989.
See https://github.com/WordPress/gutenberg/pull/63172.

Props aaronrobertshaw, andrewserong, ramonopoly.



git-svn-id: https://develop.svn.wordpress.org/trunk@58691 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-09 10:22:10 +00:00
Isabel Brison
87d24ded54 Editor: fix root padding for alignwide blocks.
Updates the root padding CSS selectors so wide width container blocks with constrained layout don’t receive padding.

Props isabel_brison, mukesh27, aaronrobertshaw.
Fixes #61587.


git-svn-id: https://develop.svn.wordpress.org/trunk@58685 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-08 06:39:39 +00:00
Sergey Biryukov
e3e7fdbf7c Code Modernization: Replace substr( PHP_OS, 0, 3 ) calls with PHP_OS_FAMILY.
The `PHP_OS_FAMILY` constant indicates the operating system family PHP was built for, and is available as of PHP 7.2.0.

Reference: [https://www.php.net/manual/en/reserved.constants.php#constant.php-os-family PHP Manual: Predefined Constants: PHP_OS_FAMILY].

Follow-up to [23255], [57753], [57985], [58678].

Props ayeshrajans, jrf.
See #61574.

git-svn-id: https://develop.svn.wordpress.org/trunk@58684 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-07 12:42:44 +00:00
Sergey Biryukov
55e0fafbbf Code Modernization: Simplify a conditional in wp_is_ini_value_changeable().
This commit reverts the code to the code from before the bug fix related to PHP 5.2.6–5.2.17.

As support for PHP 5.2 has been dropped, the workaround for the PHP 5.2 bug is no longer needed.

Follow-up to [38015], [38017], [44950], [45058], [57985], [58678], [58682].

Props jrf, ayeshrajans.
See #61574.

git-svn-id: https://develop.svn.wordpress.org/trunk@58683 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-06 15:05:37 +00:00
Sergey Biryukov
9de2177c4c Code Modernization: Remove obsolete comments about older PHP versions.
This commit:
* Removes various comments referencing PHP versions which are no longer supported.
* Removes various comments containing “hints” of things to do after a particular PHP version drop. These hints are incorrect/not actionable for various reasons, so have no value:
 * Even though a function could be turned into a closure, removing the function would be a backward compatibility break which is not acceptable, so this suggestion is not actionable.
 * Short ternaries are forbidden by the coding standard exactly to prevent the faulty code suggested in the comment from getting into the codebase.

Follow-up to [1243/tests], [6543], [11816], [29861], [29864], [34928], [35369], [36698], [38694], [50786], [58678].

Props jrf, ayeshrajans.
See #61574.

git-svn-id: https://develop.svn.wordpress.org/trunk@58682 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-06 14:52:05 +00:00
Dennis Snell
c1154f9d06 HTML API: Support SELECT insertion mode.
As part of work to add more spec support to the HTML API, this patch adds
support for the SELECT, OPTION, and OPTGROUP elements, including the
requisite support for the IN SELECT insertion mode.

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

Props dmsnell, jonsurrell.
See #61576.


git-svn-id: https://develop.svn.wordpress.org/trunk@58677 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-05 00:50:19 +00:00
Sergey Biryukov
70bad67ef1 Tests: Use assertSame() in WP_REST_Global_Styles_Revisions_Controller tests.
This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.

Follow-up to [56082].

See #61573.

git-svn-id: https://develop.svn.wordpress.org/trunk@58673 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-04 15:09:15 +00:00
Sergey Biryukov
5466b9c826 Users: Pass the previous state of the user as context to the wp_set_password hook.
Follow-up to [55056], [55250].

Props dd32.
Fixes #61541.

git-svn-id: https://develop.svn.wordpress.org/trunk@58653 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-03 16:08:55 +00:00
bernhard-reiter
a2bb45dfad Block Hooks: Fix a number of multi-line comment openers.
Add the missing second asterisk to a number of multi-line comment openers, and remove a superfluous second asterisk from two others.

Follow-up to [58614].
Props mukesh27.
See #60854.

git-svn-id: https://develop.svn.wordpress.org/trunk@58615 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-02 10:41:33 +00:00
bernhard-reiter
fdebb53bfe Block Hooks: Allow child insertion into Template Part block.
The Block Hooks mechanism was previously extended to allow insertion of a block as a Navigation block's first or last child. This was implemented by storing the `ignoredHookedBlocks` array in the corresponding `wp_navigation` post's post meta (instead of a metadata attribute on the anchor block).

This changeset extends that mechanism to Template Part blocks, by storing said metadata in the corresponding `wp_template_part` post's post meta, thus allowing extenders to use Block Hooks to insert a block as a Template Part block's first or last child, respectively.

Props tomjcafferkey, bernhard-reiter.
Fixes #60854.

git-svn-id: https://develop.svn.wordpress.org/trunk@58614 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-02 10:01:17 +00:00
Sergey Biryukov
80409a2420 REST API: Correct image cropping tools in the block editor.
As of [58457], the width and height cropping values are cast to an integer before the comparison to see if the target width and height differ from the original width and height.

Since they are now integers, it exposes a bug where the `&&` of the `if` conditional meant that if you were only cropping in one dimension, the check wouldn't pass, and cropping would not occur.

In the block editor, the cropping tools are aspect ratio based, so one of the dimensions will always match that of the source image. Therefore, now that the values are cast as integers, the condition that allows a cropping to occur needs to be updated. If either width or height is different from the source image, then a crop should be allowed.

Follow-up to [50124], [58457].

Props andrewserong, jrf, kevin940726.
Fixes #61514. See #59782.

git-svn-id: https://develop.svn.wordpress.org/trunk@58612 602fd350-edb4-49c9-b593-d223f7449a82
2024-07-01 20:43:55 +00:00
Sergey Biryukov
57910f67dd Date/Time: Replace abbreviations for minutes in human_time_diff().
This ensures that relative times are formatted the same way in both JS and PHP.

Follow-up to [1976], [2124], [4658], [41018], [56496].

Props wildworks.
Fixes #61535.

git-svn-id: https://develop.svn.wordpress.org/trunk@58600 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-29 09:29:08 +00:00
Sergey Biryukov
80bd30e4c1 Tests: Use assertSame() in WP_Interactivity_API tests.
This ensures that not only the return values match the expected results, but also that their type is the same.

Going forward, stricter type checking by using `assertSame()` should generally be preferred to `assertEquals()` where appropriate, to make the tests more reliable.

Follow-up to [57563], [57649], [57822], [57826], [57835], [58159], [58327].

See #61530.

git-svn-id: https://develop.svn.wordpress.org/trunk@58594 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-28 15:45:08 +00:00
Greg Ziółkowski
5effffccd0 HTML API: Add tests for virtual node breadcrumbs and depth
Follow-up [58590].
See #61348.
Props jonsurrell, gziolo.



git-svn-id: https://develop.svn.wordpress.org/trunk@58592 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-28 09:20:10 +00:00
bernhard-reiter
2516e98974 Script Modules: Add new API to embed server data in HTML.
Add a new filter `script_module_data_{$module_id}` to associate data
with a Script Module. For example:

{{{#!php
add_filter(
	'script_module_data_MyScriptModuleID',
	function ( array $data ): array {
		$data['script-needs-this-data'] = 'ok';
		return $data;
	}
);
}}}

If the Script Module is included in the page, enqueued or as a
dependency, the associated data will be JSON-encoded and embedded in the
HTML in a `<script type="application/json">` tag with an ID of the form
`wp-script-module-data-{$module_id}` allowing the Script Module to
access the data on the client.

See the original proposal: https://make.wordpress.org/core/2024/05/06/proposal-server-to-client-data-sharing-for-script-modules/

Developed in https://github.com/WordPress/wordpress-develop/pull/6682.

Props jonsurrell, cbravobernal, westonruter, gziolo, bernhard-reiter, youknowriad, sergiomdgomes, czapla.
Fixes #61510. See #60647.

git-svn-id: https://develop.svn.wordpress.org/trunk@58579 602fd350-edb4-49c9-b593-d223f7449a82
2024-06-26 13:19:47 +00:00