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
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
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
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
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
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
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
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
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
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
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
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
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
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
[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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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