Commit Graph

5700 Commits

Author SHA1 Message Date
bfcf2936db I18N: Correctly invalidate language file paths in WP_Textdomain_Registry.
Since the cache key in `::get_language_files_from_path()` is based on a path that always includes a trailing slash, the path in `::invalidate_mo_files_cache()` should include the trailing slash as well.

Includes adjusting the test expectations accordingly.

Follow-up to [57287], [57290], [57298].

See #58919.

git-svn-id: https://develop.svn.wordpress.org/trunk@57299 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-16 21:43:11 +00:00
9d7bc5111f Tests: Remove leftover trailingslashit() calls in WP_Textdomain_Registry tests.
Follow-up to [57287], [57290].

See #58919.

git-svn-id: https://develop.svn.wordpress.org/trunk@57298 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-16 21:32:21 +00:00
dd691394f2 Media: Consider inline image CSS width to backfill width and height attributes.
Prior to this changeset, WordPress core would use the original image size, which in the particular case of inline images would be severely off, as they are usually very small. This could lead to incorrect application of `fetchpriority="high"` and other performance optimizations.

Props westonruter, flixos90, joemcgill, mukesh27.
Fixes #59352.


git-svn-id: https://develop.svn.wordpress.org/trunk@57294 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-16 17:01:30 +00:00
c3fd114539 I18N: Do not use trailingslashit in WP_Textdomain_Registry.
This usage of `trailingslashit()`, introduced in [57287], is not only redundant, but also discouraged in order to avoid `formatting.php` dependency (which might not always be loaded).

Props SergeyBiryukov.
See #58919.

git-svn-id: https://develop.svn.wordpress.org/trunk@57290 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-16 12:10:47 +00:00
24531a9afc I18N: Cache list of language file paths in WP_Textdomain_Registry.
Loading a list of language file paths using `glob()` can be expensive if involving thousands of files.

Expands scope of `WP_Textdomain_Registry` to cache list of language file paths in object cache and provides a way to invalidate that cache upon translation updates. Plugins can clear the cache using calls such as `wp_cache_delete( 'cached_mo_files_' . md5( $path ), 'translations' );`

Props mreishus, swissspidy
Fixes #58919

git-svn-id: https://develop.svn.wordpress.org/trunk@57287 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-15 19:03:27 +00:00
0d109bda84 Upgrade/Install: Fix JavaScript localization on install page.
Blocks registration causes scripts to be initialized and localized very early, before the current locale has been properly set on the installation page.

This changes `determine_locale()` so that the locale chosen during installation is recognized and loaded earlier, ensuring proper script localization.

Props sabernhardt, NekoJonez, jornp, costdev.
Fixes #58696

git-svn-id: https://develop.svn.wordpress.org/trunk@57286 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-15 18:55:59 +00:00
ba40e28093 Tests: Move wp_parse_list() tests to their own file.
This aims to make the tests more discoverable and easier to expand.

Follow-up to [44546].

See #59647.

git-svn-id: https://develop.svn.wordpress.org/trunk@57284 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-14 17:15:49 +00:00
3d19b28eaf Administration: Introduce new_admin_email_subject filter.
This changeset introduces the `new_admin_email_subject` hook which allow developers to filter the subject of the email sent when a change of site admin email address is attempted.

Props MadtownLems, johnbillion, alexanderkoledov, shooper, Marc_J, nikmeyer, xlthlx, devmuhib, nuhel, audrasjb.
Fixes #59250.





git-svn-id: https://develop.svn.wordpress.org/trunk@57283 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-14 10:59:48 +00:00
9ae009f06d Tests: Correct the @group annotation in some tests.
Follow-up to [56971], [57146].

See #59647.

git-svn-id: https://develop.svn.wordpress.org/trunk@57278 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-13 16:31:08 +00:00
ed88ebb55c JavaScript: Add new Modules API.
This changeset adds a new API for WordPress, designed to work with native ES Modules and Import Maps. It introduces functions such as `wp_register_module`, and `wp_enqueue_module`.

The API aims to provide a familiar experience to the existing `WP_Scripts` class, offering similar functionality. However, **it's not intended to duplicate the exact functionality of `WP_Scripts`**; rather, it is carefully tailored to address the specific needs and capabilities of ES modules.

For this initial version, **the current proposal is intentionally simplistic**, covering only the essential features needed to work with ES modules. Other enhancements and optimizations can be added later as the community identifies additional requirements and use cases.

== Differences Between WP_Script_Modules and WP_Scripts

=== Dependency Specification

With `WP_Script_Modules`, the array of dependencies supports not only strings but also arrays that include the dependency import type (`static` or `dynamic`). This design choice allows for future extensions of dependency properties, such as adding a `version` property to support "scopes" within import maps.

=== Module Identifier

Instead of a handle, `WP_Script_Modules` utilizes the module identifier, aligning with the module identifiers used in JavaScript files and import maps.

=== Deregistration

There is no equivalent of `wp_deregister_script` at this stage.

== API

=== `wp_register_module( $module_identifier, $src, $deps, $version )`

Registers a module.

{{{
// Registers a module with dependencies and versioning.
wp_register_module(
  'my-module',
  '/path/to/my-module.js',
  array( 'static-dependency-1', 'static-dependency-2' ),
  '1.2.3'
);
}}}

{{{
// my-module.js
import { ... } from 'static-dependency-1';
import { ... } from 'static-dependency-2';

// ...
}}}

{{{
// Registers a module with a dynamic dependency.
wp_register_module(
  'my-module',
  '/path/to/my-module.js',
  array(
    'static-dependency',
    array(
      'id'     => 'dynamic-dependency',
      'import' => 'dynamic'
    ),
  )
);
}}}

{{{
// my-module.js
import { ... } from 'static-dependency';

// ...
const dynamicModule = await import('dynamic-dependency');
}}}

=== `wp_enqueue_module( $module_identifier, $src, $deps, $version )`

Enqueues a module. If a source is provided, it will also register the module.

{{{
wp_enqueue_module( 'my-module' );
}}}

=== `wp_dequeue_module( $module_identifier )`

Dequeues a module.

{{{
wp_dequeue_module( 'my-module' );
}}}

== Output

- When modules are enqueued, they are printed within script tags containing `type="module"` attributes.
- Additionally, static dependencies of enqueued modules utilize `link` tags with `rel="modulepreload"` attributes.
- Lastly, an import map is generated and inserted using a `<script type="importmap">` tag.

{{{
<script type="module" src="/path/to/my-module.js" id="my-module"></script>
<link rel="modulepreload" href="/path/to/static-dependency.js" id="static-dependency" />
<script type="importmap">
  {
    "imports": {
      "static-dependency": "/path/to/static-dependency.js",
      "dynamic-dependency": "/path/to/dynamic-dependency.js"
    }
  }
</script>
}}}

== Import Map Polyfill Requirement

Even though all major browsers already support import maps, an import map polyfill is required until the percentage of users using old browser versions without import map support drops significantly.

This work is ongoing and will be added once it's ready. Progress is tracked in #60232.

Props luisherranz, idad5, costdev, neffff, joemcgill, jorbin, swissspidy, jonsurrell, flixos90, gziolo, westonruter.
Fixes #56313.

git-svn-id: https://develop.svn.wordpress.org/trunk@57269 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-11 14:45:10 +00:00
fd42519d7b Tests: Remove some leftover debugging in WP_REST_Revisions_Controller tests.
Follow-up to [57222].

See #59875.

git-svn-id: https://develop.svn.wordpress.org/trunk@57268 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-11 13:16:26 +00:00
94b70f1ae0 Media: Fix handling of multibyte exif description metadata.
The exif standards expect the UserComment field to be used as a substitute for ImageDescription if multibyte characters are needed. WordPress media only mapped the ImageDescription field and did not correctly handle descriptions with multibyte characters.

Fix metadata saving to better handle media with multibyte characters in metadata and update unit tests.

Props fotodrachen, antpb, joedolson, mikinc860, azaozz, nicolefurlan.
Fixes #58082.

git-svn-id: https://develop.svn.wordpress.org/trunk@57267 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-10 21:57:50 +00:00
7e7315ba22 Tests: Fix tests following r57265.
Update unit tests failing after r57265 changed strings in single post template descriptions. Follow up to [57265].

Props joedolson.
Fixes #60216.

git-svn-id: https://develop.svn.wordpress.org/trunk@57266 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-10 21:12:07 +00:00
7c1c48c141 HTML API: Add support for list elements.
Adds support for the following HTML elements to the HTML Processor:

 - LI, OL, UL.
 - DD, DL, DT.

Previously, these elements were not supported and the HTML Processor would bail when encountering them.
With this patch it will proceed to parse an HTML document when encountering those tags as long as other normal conditions don't cause it to bail (such as complicated format reconstruction).

Props audrasjb, jonsurrell, bernhard-reiter.
Fixes #60215.



git-svn-id: https://develop.svn.wordpress.org/trunk@57264 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-10 14:03:57 +00:00
ca24196233 Editor: Allow default duotone styles if not explicitly disabled in theme.json.
Removes setting that disabled default duotone palette from being output in themes without theme.json.

Props andrewserong.
Fixes #60136.


git-svn-id: https://develop.svn.wordpress.org/trunk@57260 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-10 00:25:19 +00:00
788d709a56 Editor: output palette presets when appearance tools or border are enabled.
Adds color palette presets to global styles output if current theme supports either appearance tools or border.

Props andrewserong, noisysocks.
Fixes #60134.


git-svn-id: https://develop.svn.wordpress.org/trunk@57259 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-09 23:30:10 +00:00
52720efece Tests: Add hook priority call order tests.
Adds happy (integer) and unhappy (non-integer) tests for validating the priority call order for:

* `do_action()`
* `WP_Hook::do_action()`
* `apply_filters()`
* `WP_Hook::apply_filters()`

As each of these functions have differing code, the tests are added to each to ensure expected results and protect against future regressions.

Follow-up to [53804], [52010], [25002], [25/tests], [62/tests].

Props hellofromTonya, mukesh27, dd32, valendesigns, drrobotnik.
Fixes #60193.

git-svn-id: https://develop.svn.wordpress.org/trunk@57257 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-09 16:32:14 +00:00
cb564055e0 Themes: Add theme support for appearance tools.
Reapplies the patch reverted in #57649 as the original patch was no longer applying cleanly. Adds theme support for appearance tools to `WP_Theme_JSON_Resolver`.

Props andrewserong, mukesh27, noisysocks.
Fixes #60118.



git-svn-id: https://develop.svn.wordpress.org/trunk@57255 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-09 06:24:44 +00:00
15b5be2acd Editor: add size and repeat to background image support.
Adds background size and background repeat style processing to the background image block support and `WP_Style_Engine` definitions.

Props andrewserong, mukesh27.
Fixes #60175.



git-svn-id: https://develop.svn.wordpress.org/trunk@57254 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-09 06:10:09 +00:00
2d764b4101 Editor: add CSS var parsing for fontSize and fontFamily.
Adds capability to parse CSS custom properties for fontSize and fontFamily in `WP_Style_Engine`.

Props ramonopoly.
Fixes #59982.


git-svn-id: https://develop.svn.wordpress.org/trunk@57253 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-09 02:43:48 +00:00
868f2ef1fd Taxonomy: Check for empty term after DB sanitization in wp_insert_term().
When inserting a new term in the database, `wp_insert_term()` will check if the term is empty and return a corresponding error.

Afterwards the term is sanitized and inserted in the database. However, there is a chance the term is empty after the DB sanitization.

This commit adds a check for an empty term name after the term is sanitized, returning an error in that case.

Follow-up to [5726], [8393].

Props fgiannar, kraftbj.
Fixes #59995.

git-svn-id: https://develop.svn.wordpress.org/trunk@57251 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-08 22:42:49 +00:00
8b2ed2fe62 HTML API: Add explicit handling or failure for all tags.
The HTML API HTML processor does not yet support all tags. Many tags (e.g. list elements) have some complicated rules in the [https://html.spec.whatwg.org/#parsing-main-inbody "in body" insertion mode].

Implementing these special rules is blocking the implementation for a catch-all rule for "any other tag" because we need to prevent special rules from being handled by the catch-all.

  Any other start tag
  Reconstruct the active formatting elements, if any.

  Insert an HTML element for the token.

  …

This change ensures the HTML Processor fails when handling special tags. This is the same as existing behavior, but will allow us to implement the catch-all "any other tag" handling without unintentionally handling special elements.

Additionally, we add tests that assert the special elements are unhandled. As these tags are implemented, this should help to ensure they're removed from the unsupported tag list.

Props jonsurrell, dmsnell.
Fixes #60092.

git-svn-id: https://develop.svn.wordpress.org/trunk@57248 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-08 14:03:40 +00:00
f7041f1cbf Editor: add layout classes to legacy Group inner container.
Moves generated layout classes into the Group block inner container in classic themes, so that block gap support can work correctly.

Props flixos90, mukesh27.
Fixes #60130.


git-svn-id: https://develop.svn.wordpress.org/trunk@57246 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-08 06:12:00 +00:00
b9ca649f3b Tests: Use assertSame() in some newly introduced 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 [55859], [56380], [56802], [57115], [57129], [57185].

See #59655.

git-svn-id: https://develop.svn.wordpress.org/trunk@57244 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-06 12:59:49 +00:00
cb85d888a0 Tests: Add a @ticket reference for WP_Customize_Manager::trash_changeset_post() test.
Follow-up to [56043], [57238], [57241].

Props mukesh27.
See #60183.

git-svn-id: https://develop.svn.wordpress.org/trunk@57242 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-05 11:38:34 +00:00
e43275b61c Tests: Add a unit test for post trash hooks executed when trashing a changeset.
The test ensures that the correct number of arguments is passed to post trash hooks in `WP_Customize_Manager::trash_changeset_post()`, which bypasses `wp_trash_post()`.

Follow-up to [56043], [57238].

See #60183.

git-svn-id: https://develop.svn.wordpress.org/trunk@57241 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-04 11:45:31 +00:00
489b9e737f Docs: Replace "sanity" with "confidence" for inclusive language.
The phrase "sanity check" unnecessarily references mental health. It's an old phrase used to denote an extra step in verifying code works as expected.

“The WordPress open source community cares about diversity. We strive to maintain a welcoming environment where everyone can feel included.”

While "sanity check" is a well-known phrase with a specific meaning, "confidence check" is a direct replacement that is more clear of its intent while being more inclusive.

Words matter.

Follow-up to [49216], [46271], [40583], [38832], [38637], [37409], [33359], [32162], [30346], [30345], [30238], [30055], [29902], [28763], [26141], [25002], [22227], [13428], [12148], [11025], [8927].

Props dartiss, hellofromTonya.
Fixes #60187.

git-svn-id: https://develop.svn.wordpress.org/trunk@57239 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-03 21:57:32 +00:00
67296ea571 Tests: Use more specific assertions in wp_scheduled_delete() tests.
Includes clarifying test method names and descriptions.

Follow-up to [57224].

See #59938.

git-svn-id: https://develop.svn.wordpress.org/trunk@57237 602fd350-edb4-49c9-b593-d223f7449a82
2024-01-02 15:57:20 +00:00
9f7fc54ca7 Canonical: Check if the author parameter is a string in redirect_canonical().
This avoids a PHP warning or error when viewing an author on the front end, while an array is passed as `$_GET['author']`.

Follow-up to [12034], [12040], [12202].

Props david.binda, antonvlasenko, azaozz, SergeyBiryukov.
Fixes #60059.

git-svn-id: https://develop.svn.wordpress.org/trunk@57232 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-29 13:52:57 +00:00
0e28444795 KSES: Add background-repeat to the list of safe CSS properties.
Follow-up to [45242], [46235].

Props andrewserong, ramonopoly, mukesh27.
Fixes #60132.

git-svn-id: https://develop.svn.wordpress.org/trunk@57228 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-26 14:22:45 +00:00
54a09a7ec9 Build/Test: Add Tests for wp_scheduled_delete.
Props pbearne.
Fixes #59938.


git-svn-id: https://develop.svn.wordpress.org/trunk@57224 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-22 15:20:34 +00:00
d1faee936d REST API: check parent and revision ids match before retrieving revision.
Adds a condition to check that parent id matches revision parent id in `WP_REST_Revisions_Controller` `get_item` method.

Props ramonopoly, adamsilverstein, danielbachhuber, spacedmonkey, andrewserong.
Fixes #59875.


git-svn-id: https://develop.svn.wordpress.org/trunk@57222 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-22 02:10:18 +00:00
77dcb1771a Themes: Improve the performance of _get_block_templates_paths.
This avoids redundant recursive lookups for block template paths in the same base directory by implementing a static cache. It also replaces an potentially expensive `file_exists` call in favor of doing recursive iteration of files inside a try/catch block. 

Props thekt12, spacedmonkey, flixos90, mukesh27, joemcgill.
Fixes #58196.


git-svn-id: https://develop.svn.wordpress.org/trunk@57215 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-20 20:00:04 +00:00
c6773eeffd HTML API: Avoid processing incomplete tokens.
Currently the Tag Processor assumes that an input document is a ''full'' HTML document. Because of this, if there's lingering content after the last tag match it will treat that content as plaintext and skip over it. This is fine for the Tag Processor because if there is lingering content that isn't a valid tag then there's nothing for `next_tag()` to match.

However, in order to support a number of feature expansions it is important to recognize that the remaining content ''may'' involve partial syntax elements, such as incomplete tags, attributes, or comments.

In this patch we're adding a mode inside the Tag Processor which will flip when we start parsing HTML syntax but the document finishes before the token does. This will provide the ability to:

- extend the input document,
- avoid misinterpreting syntax as text, and
- guess if we have a complete document, know if we have an incomplete document.

In the process of building this patch a few fixes were identified and fixed in the Tag Processor, namely in the handling of incomplete syntax elements.

Props dmsnell, jonsurrell.
Fixes #60122, #60108.

git-svn-id: https://develop.svn.wordpress.org/trunk@57211 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-20 17:50:04 +00:00
1bca32e30e Tests: Correct the @group annotation for _wp_mysql_week() tests.
Includes updating the data provider name for consistency.

Follow-up to [57207].

See #59931.

git-svn-id: https://develop.svn.wordpress.org/trunk@57208 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-20 10:01:17 +00:00
3c6680b657 Build/Test: Add Tests for _wp_mysql_week.
Props pbearne.
Fixes #59931.


git-svn-id: https://develop.svn.wordpress.org/trunk@57207 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-19 23:11:11 +00:00
144d098ac5 Build/Test: Update name of test to show its breadth.
The test covers multiple libraries, not just lodash.

Follow up to [57185].

Props TobiasBg.
Fixes #60048.


git-svn-id: https://develop.svn.wordpress.org/trunk@57187 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-13 20:00:49 +00:00
32dd59bb9a HTML API: Add support for H1-H6 elements in the HTML Processor.
Previously these have been unsupported, but in this patch, support is added for the tags so that the HTML Processor can process documents containing them.

There was a design discussion about introducing a constant to communicate "any of the H1 - H6 elements" but this posed a number of challenges that don't need to be answered in this patch. For the time being, because the HTML specification treats H1 - H6 specially as a single kind of element, the HTML Processor uses an internal hard-coded string to indicate this. By using a hard-coded string it's possible to avoid introducing a class constant which cannot be made private due to PHP's class design. In the future, this will probably appear as a special constant in a new constant-containing class.

Props dmsnell, jonsurrell.
Fixes #60060.

git-svn-id: https://develop.svn.wordpress.org/trunk@57186 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-13 17:51:42 +00:00
edb416c9b2 External Libraries: For Lodash, sync the declared version number with the one that is loaded.
In [50941] the version of lodash was updated, however the version inside `wp_default_packages_vendor` was not updated at the same time. This updates the version to correctly reflect the version that is loaded.

Also adds some basic tests for the scripts in `wp_default_packages_vendor` that match the name of the package from package.json to help prevent errors like this in the future.

Props jadpm, jorbin, swissspidy.
Fixes #60048. See #52991.




git-svn-id: https://develop.svn.wordpress.org/trunk@57185 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-13 17:48:09 +00:00
5eef2bbb2a Tests: Add unit tests for wp_checkdate().
Follow-up to [21922].

Props pbearne, ironprogrammer, antonvlasenko, SergeyBiryukov.
Fixes #59825.

git-svn-id: https://develop.svn.wordpress.org/trunk@57184 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-12 12:19:38 +00:00
9bfb30462a REST API: Pass correct number of arguments to the comment_text filter.
This ensures that `WP_REST_Comments_Controller::prepare_item_for_response()` passes three arguments to the `comment_text` filter, for consistency with all the other instances in core.

Follow-up to [15957], [16357], [25555], [38832], [40664].

Props sjregan, SergeyBiryukov.
Fixes #58238.

git-svn-id: https://develop.svn.wordpress.org/trunk@57176 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-09 22:11:45 +00:00
d1f73cd80f Block Hooks: Fix @ticket references in tests, add missing ones.
Some tests that were added in [57157] erroneously set their `@ticket` reference to #59646, rather than #60008.
This changeset rectifies that mistake.

Additionally, it adds ticket references to #60008 to tests that were modified by [57157].

Follow-up to [57157].

See #60008.

git-svn-id: https://develop.svn.wordpress.org/trunk@57172 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-08 11:44:54 +00:00
c44432b338 Block Hooks: Store ignored hooked blocks metadata in anchor block.
The biggest tradeoff that was made in the implementation of Block Hooks was that they were limited to layouts (i.e. templates, template parts, and patterns) that ''didn't have any user modifications'' (see #59313 for the reason). This changeset is a preparatory step to remove this limitation, so they’ll eventually also work with user-modified layouts.

The crucial problem to solve is how to acknowledge that a user has opted to remove or persist a hooked block, so that the auto-insertion mechanism won't run again and inject an extraneous hooked block on the frontend when none is solicited.

This is achieved by storing all known blocks hooked to a given anchor block in the `metadata` attribute on that anchor block; specifically in a field called `ignoredHookedBlocks` inside of the `metadata`. Hooked blocks are only rendered on the frontend if they're absent from that field; OTOH, they're injected into that field (via the REST API) when first loaded in the editor.

This simple logic guarantees that once a user modifies a given layout, those changes are respected on the frontend; yet if a plugin that includes a hooked block is activated after those modifications have taken place, the hooked block will be rendered on the frontend. This new technique supplants the one previously used (i.e. rendering hooked blocks on the frontend only if a layout doesn't have any modifications) in a rather direct way.

Note that this changeset only introduces the new metadata field and relevant logic; it does not yet enable hooked block insertion into modified layouts. That will be done in a subsequent step (see #59646).

Props gziolo.
Closes #60008.

git-svn-id: https://develop.svn.wordpress.org/trunk@57157 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-04 20:24:33 +00:00
7ce1281349 Themes: Avoid autoloading the previous theme's theme mods when switching to another theme.
This reduces unnecessarily autoloaded data from inactive themes, which can contribute to slow database performance as part of excessive autoloading.

Props mukesh27, rajinsharwar, igmoweb, joemcgill, swissspidy, westonruter, flixos90.
Fixes #59537.
See #59975.


git-svn-id: https://develop.svn.wordpress.org/trunk@57153 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-04 19:36:27 +00:00
76ab1b8891 Build/Test Tools: Allow overriding the WP_UnitTestCase_Base::factory() method.
This allows third-party plugins to write their own factory extending `WP_UnitTest_Factory` for testing purposes, as well as benefit from `WP_UnitTestCase_Base` features.

Follow-up to [35186], [35225], [35242].

Props hugod.
Fixes #59999.

git-svn-id: https://develop.svn.wordpress.org/trunk@57149 602fd350-edb4-49c9-b593-d223f7449a82
2023-12-02 11:56:31 +00:00
4d19f6c23f REST API: Restore site logo and icon in index.
Restores setting the site's logo, icon, and wp-admin's back button image (which defaults to W).

Prior to [56566], the site logo and icon were unconditionally added to the index. [56566] changed this by conditionally adding them if either the `_links` or `_embedded` fields were included. However, these fields are not included when using the Site Logo block, as it uses the `site_logo`, `site_icon`, and `site_icon_url` fields instead.

This changeset restores the functionality by checking specifically for the `site_*` fields when neither of the `_links` or `_embedded` fields are present.

Follow up to [56566].

Props antonvlasenko, hellofromTonya, ironprogrammer, priethor, wildworks.
Fixes #59935.

git-svn-id: https://develop.svn.wordpress.org/trunk@57147 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-30 14:52:52 +00:00
36a7c6ca40 Tests: Update _wp_timezone_choice_usort_callback() tests for consistency.
* Use the same `@group` annotation as the other tests.
* Use `assertSame()` to verify the type of the result.
* Use `data_` prefix for the data provider.
* Use named data set in the data provider. This makes the output when using the `--testdox` option more descriptive and is helpful when trying to debug which data set from a data provider failed the test.
* Other minor corrections.

Reference: [https://make.wordpress.org/core/handbook/testing/automated-testing/writing-phpunit-tests/#repetitive-tests Core Handbook: Writing PHP Tests: Repetitive Tests].

Follow-up to [57145].

See #59953, #59647.

git-svn-id: https://develop.svn.wordpress.org/trunk@57146 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-30 11:15:34 +00:00
4cee935825 Add automated tests for _wp_timezone_choice_usort_callback
Props pbearne.
Fixes #59953.


git-svn-id: https://develop.svn.wordpress.org/trunk@57145 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-29 17:31:44 +00:00
09a2050fca Tests: Avoid an infinite loop in Spy_REST_Server if a non-existing method is called.
Follow-up to [34928].

Props xknown, joemcgill.
Fixes #59601.

git-svn-id: https://develop.svn.wordpress.org/trunk@57133 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-23 14:39:16 +00:00
b6bf3553d9 Themes: Remove memoization from stylesheet and theme directories.
This fixes bugs introduced in [56635] whereby the template or stylesheet path could be memoized incorrectly if `get_template_directory()` or `get_stylesheet_directory()` were called before the theme has been fully initialized.

Props partyfrikadelle, coreyw, kdowns, rebasaurus, meta4, flixos90, mukesh27, joemcgill.
Fixes #59847.


git-svn-id: https://develop.svn.wordpress.org/trunk@57129 602fd350-edb4-49c9-b593-d223f7449a82
2023-11-20 22:27:17 +00:00