Commit Graph

48208 Commits

Author SHA1 Message Date
Felix Arntz
ca8a033079 General: Update wp_register_script() calls in core to use new function signature.
Since most core scripts are registered using `WP_Scripts::add()`, which is not affected by the signature change, only calls to `wp_register_script()` using the old signature need to be updated. There is only a single instance left, which is updated in this changeset.

Props incursadesigns.
Fixes #58634.

Built from https://develop.svn.wordpress.org/trunk@56568


git-svn-id: http://core.svn.wordpress.org/trunk@56080 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-13 20:52:22 +00:00
Tammie Lister
d6c86f944f Twenty-Twenty One: Fixes quotation mark being outside with background.
The quotation marks were outside when the background color was applied.

Props nidhidhandhukiya, sabernhardt, shailu25, harshgajipara, poena, huzaifaalmesbah.
Fixes #57377. 

Built from https://develop.svn.wordpress.org/trunk@56567


git-svn-id: http://core.svn.wordpress.org/trunk@56079 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-13 15:40:20 +00:00
spacedmonkey
7d1e95ec7f REST API: Avoid unnecessarily preparing item links REST API index.
Building upon the changes introduced in [53760], this commit refines the behavior of the REST API index. Specifically, it addresses performance concerns related to the unnecessary preparation of item links, such as site icon and logo links.

Prior to this update, the index controller was invoking the prepare_links method regardless of whether the _links or _embedded fields were requested in the response. This led to unnecessary database lookups and decreased overall performance.

In this commit, we implement a more efficient approach. Now, the prepare_links method will only be called when the _links or _embedded fields are explicitly requested in the response. This optimization ensures that we prepare links only when they are intended for inclusion in the API response, reducing unnecessary overhead.

By implementing this improvement, we enhance the overall efficiency and performance of the WordPress core REST API index controller.

Props spacedmonkey, niravsherasiya7707, dlh, mukesh27, costdev, swissspidy.
Fixes #57902.
Built from https://develop.svn.wordpress.org/trunk@56566


git-svn-id: http://core.svn.wordpress.org/trunk@56078 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-13 14:34:20 +00:00
Bernhard Reiter
15c3f036fd HTML API: Update documentation and rename internal variable on HTML Processor
This patch updates documentation and an internal variable name within the
HTML Processor class so that they are more helpful and complete to a reader.

There should be no functional or visual changes in this patch.

Props dmsnell, mukesh27.
Fixes #59267.
Built from https://develop.svn.wordpress.org/trunk@56565


git-svn-id: http://core.svn.wordpress.org/trunk@56077 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-13 13:02:17 +00:00
Bernhard Reiter
deaa431a90 HTML API: Skip over contents of RAWTEXT elements such as STYLE.
When encountering elements that imply switching into the RAWTEXT parsing state,
the Tag Processor should skip processing until exiting the RAWTEXT state.

In this patch the Tag Processor does just that, except for the case of the
deprecated XMP element which implies further and more complicated rules.

There's an implicit assumption that the SCRIPT ENABLED flag in HTML parsing
is enabled so that the contents of NOSCRIPT can be skipped. Otherwise, it would
be required to parse the contents of that tag.

Props dmsnell.
Fixes #59292.
Built from https://develop.svn.wordpress.org/trunk@56563


git-svn-id: http://core.svn.wordpress.org/trunk@56075 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-13 12:49:16 +00:00
Bernhard Reiter
51e2cb9e33 Themes: Add test for theme atttibute in file-based block template.
While we already have unit test coverage for `_inject_theme_attribute_in_block_template_content`, those tests only verify that ''that'' function does what is supposed to do; there's however no guarantee that `_build_block_template_result_from_file` uses that function (or whatever other technique) to actually inject the theme attribute.

This patch adds test coverage to verify that the theme attribute is correctly injected by `_build_block_template_result_from_file`.

Props costdev, gziolo, mukesh27, spacedmonkey.
Fixes #59325. See #59313.
Built from https://develop.svn.wordpress.org/trunk@56562


git-svn-id: http://core.svn.wordpress.org/trunk@56074 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-13 12:05:15 +00:00
Sergey Biryukov
7630eab57f Docs: Fix typo in a comment in wp_trim_excerpt().
Includes removing redundant `@covers` tags. There is already an existing annotation for the whole test class, following the [https://docs.phpunit.de/en/9.6/annotations.html#covers PHPUnit recommendation]:
> This annotation can be added to the docblock of the test class or the individual test methods. The recommended way is to add the annotation to the docblock of the test class, not to the docblock of the test methods.

Follow-up to [56560].

See #58682.
Built from https://develop.svn.wordpress.org/trunk@56561


git-svn-id: http://core.svn.wordpress.org/trunk@56073 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-13 08:08:20 +00:00
Felix Arntz
4bfba35169 Posts, Post Types: Avoid unnecessarily parsing blocks twice in wp_trim_excerpt().
All blocks relevant for the excerpt are already being parsed in `excerpt_remove_blocks()`. Therefore running `do_blocks()` on the post content only to create the excerpt is unnecessary and wasteful from a performance perspective.

Props thekt12, spacedmonkey, mukesh27, joemcgill.
Fixes #58682.

Built from https://develop.svn.wordpress.org/trunk@56560


git-svn-id: http://core.svn.wordpress.org/trunk@56072 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-12 19:20:21 +00:00
Sergey Biryukov
e5490118af Coding Standards: Include one space after function keyword for closures.
Note: This is enforced by WPCS 3.0.0.

Reference: [https://github.com/WordPress/WordPress-Coding-Standards/pull/2328 WPCS: PR #2328 Core: properly check formatting of function declaration statements].

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56559


git-svn-id: http://core.svn.wordpress.org/trunk@56071 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-12 15:23:18 +00:00
Bernhard Reiter
251a9c7653 HTML API: Store current token reference in HTML Processor state.
The `$current_token` reference has been stored in the HTML Processor itself, but I suggested to move it into the externalized state so that it can be stored and replaced.

In this patch the reference is moved to that state variable and it should become more possible to save and load state, to resume execution after pausing.

Props dmsnell.
Fixes #59268.
Built from https://develop.svn.wordpress.org/trunk@56558


git-svn-id: http://core.svn.wordpress.org/trunk@56070 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-12 15:12:17 +00:00
Bernhard Reiter
b847b9c484 General: Add optional callback argument to serialize_block(s).
Allow passing a function callback to serialize_block(s) that is invoked on each node in the tree of parsed blocks as it is traversed for serialization.

A function argument was chosen for passing the callback function as it reflects a pattern familiar from other algorithms that apply a given callback function while traversing a data structure -- most notably PHP's own `array_map()`.

Introducing a filter was considered as an alternative but ultimately dismissed. For a fairly low-level and general-purpose function such as `serialize_block()`, using a filter to pass the callback seemed risky, as it also requires ''removing'' that filter after usage in order to prevent the callback from being accidentally applied when `serialize_block()` is called in an entirely different context.

Introducing a separate function for applying a given operation during tree traversal (i.e. independently of serialization) was also considered but dismissed, as it would unnecessarily duplicate tree traversal.

Props dlh, gziolo.
Fixes #59327. See #59313.
Built from https://develop.svn.wordpress.org/trunk@56557


git-svn-id: http://core.svn.wordpress.org/trunk@56069 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-12 13:02:19 +00:00
Weston Ruter
ceb151029c Bundled Themes: Use defer loading strategy for theme scripts.
* Add `defer` loading strategy for all frontend end-user theme scripts (excluding Customizer preview).
* Move scripts to the `head` which relate to the initial page viewport to ensure they start loading earlier and execute sooner while still not blocking rendering.
* Update Twenty Twenty's script loader (`TwentyTwenty_Script_Loader`) to support core's built-in script loading strategies (#12009), while also retaining backwards-compatibility for child themes that may set `async` and `defer` script data.
* Update the main script loading strategy in Twenty Twenty from `async` to `defer` for better performance on repeat page views, since when an `async` script is cached it will block rendering.

Props westonruter, flixos90, sabernhardt.
Fixes #59316.

Built from https://develop.svn.wordpress.org/trunk@56556


git-svn-id: http://core.svn.wordpress.org/trunk@56068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-12 00:06:19 +00:00
spacedmonkey
de170c0c2e Taxonomy: Cache term objects in WP_Term_Query if query is filtered.
When utilizing the `terms_clauses` or `get_terms_fields` filters within `WP_Term_Query` and the selected fields are modified, the entire term object is now cached. This adjustment is necessary because filters can broaden the selected fields beyond just the term ID. Fields linked to the term object, such as the count or parent, may undergo modifications when queried. Caching the complete object ensures the accurate storage of these modified fields within the cache.

Props spacedmonkey, tnolte, peterwilsoncc.
Fixes #58116.
Built from https://develop.svn.wordpress.org/trunk@56555


git-svn-id: http://core.svn.wordpress.org/trunk@56067 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-11 11:37:19 +00:00
costdev
4920adb477 External Libraries: Update the Requests library to version 2.0.8.
This is a maintenance release with minor changes:
- Only force close cURL connection when needed (cURL < 7.22).

References:
- [https://github.com/WordPress/Requests/releases/tag/v2.0.8 Requests 2.0.8 release notes]
- [https://github.com/WordPress/Requests/compare/v2.0.6...v2.0.8 Full list of changes in Requests 2.0.8]

Follow-up to [54997], [55007], [55046], [55225], [55296], [55629].

Props jrf, mukesh27, spacedmonkey, costdev.
Fixes #59322.
Built from https://develop.svn.wordpress.org/trunk@56554


git-svn-id: http://core.svn.wordpress.org/trunk@56066 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-11 10:33:19 +00:00
Peter Wilson
e41f176a63 Cron: Cast doing_cron transient to a float.
Cast the `doing_cron` transient value to a float to prevent type errors if the transient is not set (in which case it returns `false`) or another unexpected type.

Props fzhantw, ankitmaru.
Fixes #58471.


Built from https://develop.svn.wordpress.org/trunk@56553


git-svn-id: http://core.svn.wordpress.org/trunk@56065 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-11 05:27:22 +00:00
Sergey Biryukov
c41829ea95 Code Modernization: Use dirname() with the $levels parameter.
PHP 7.0 introduced the `$levels` parameter to the `dirname()` function, which means nested calls to `dirname()` are no longer needed.

Note: This is enforced by WPCS 3.0.0.

Reference: [https://www.php.net/manual/en/function.dirname.php PHP Manual: dirname()].

Follow-up to [56141].

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56552


git-svn-id: http://core.svn.wordpress.org/trunk@56064 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-11 04:53:22 +00:00
Sergey Biryukov
d399e57a1f Coding Standards: Correct spacing for spread operators.
No space allowed between the operator and the variable it applies to.

Note: This is enforced by WPCS 3.0.0.

Follow-up to [46133].

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56551


git-svn-id: http://core.svn.wordpress.org/trunk@56063 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-10 09:04:18 +00:00
costdev
c170fd62f4 Upgrade/Install: Fix broken sprintf() call when deleting a backup.
In `WP_Upgrader::delete_temp_backup()`, a malformed `sprintf()` call did not pass the value, triggering a Warning in PHP 7 and a Fatal Error in PHP 8.

This fixes the malformed `sprintf()` call by correctly passing the value.

Follow-up to [55720].

Props akihiroharai, afragen.
Fixes #59320.
Built from https://develop.svn.wordpress.org/trunk@56550


git-svn-id: http://core.svn.wordpress.org/trunk@56062 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-10 07:33:22 +00:00
Sergey Biryukov
b80ce60f70 Coding Standards: Use pre-increment/decrement for stand-alone statements.
Note: This is enforced by WPCS 3.0.0:

1. There should be no space between an increment/decrement operator and the variable it applies to.
2. Pre-increment/decrement should be favoured over post-increment/decrement for stand-alone statements. “Pre” will in/decrement and then return, “post” will return and then in/decrement. Using the “pre” version is slightly more performant and can prevent future bugs when code gets moved around.

References:
* [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#increment-decrement-operators WordPress PHP Coding Standards: Increment/decrement operators]
* [https://github.com/WordPress/WordPress-Coding-Standards/pull/2130 WPCS: PR #2130 Core: add sniffs to check formatting of increment/decrement operators]

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56549


git-svn-id: http://core.svn.wordpress.org/trunk@56061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-09 09:28:26 +00:00
Sergey Biryukov
d8936a9fe7 Coding Standards: Remove superfluous blank lines at the end of various functions.
Note: This is enforced by WPCS 3.0.0.

Follow-up to [56536], [56547].

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56548


git-svn-id: http://core.svn.wordpress.org/trunk@56060 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-08 10:03:21 +00:00
Sergey Biryukov
9a49b70239 Coding Standards: Remove superfluous blank lines at the end of various classes.
Note: This is enforced by WPCS 3.0.0.

Follow-up to [56536].

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56547


git-svn-id: http://core.svn.wordpress.org/trunk@56059 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-08 09:32:23 +00:00
isabel_brison
b7439d5712 Editor: tweak root padding styles.
Removes root padding from children of flex and grid layout blocks when root padding aware alignments are set.

Props andrewserong, ramonopoly.
Fixes #59295.

Built from https://develop.svn.wordpress.org/trunk@56546


git-svn-id: http://core.svn.wordpress.org/trunk@56058 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-08 00:51:18 +00:00
isabel_brison
43a50913d6 Editor: performance enhancements to class-wp-theme-json.
Removes unnecessary sanitisation of hardcoded strings and avoids looping over style presets without classes or variables.

Props flixos90.
Fixes #59304.

Built from https://develop.svn.wordpress.org/trunk@56545


git-svn-id: http://core.svn.wordpress.org/trunk@56057 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-08 00:26:21 +00:00
hellofromTonya
f379cb7fdb Code Modernization: Use wp_trigger_error() in WP_Text_Diff_Renderer_Table magic methods.
Replaces `trigger_error()` with `wp_trigger_error()` in each of the `WP_Text_Diff_Renderer_Table` magic methods.

[56354] added the dynamic properties deprecation messages to the `__get()`, `__set()`, `__isset()`, `__unset()` magic methods. Since that commit, `wp_trigger_error()` was introduced (see [56530]) as a wrapper for `trigger_error()`.

Follow-up to [56354], [56530].

See #58898, #57686.
Built from https://develop.svn.wordpress.org/trunk@56544


git-svn-id: http://core.svn.wordpress.org/trunk@56056 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-07 20:48:12 +00:00
hellofromTonya
6b0b3eb6a1 Code Modernization: Use wp_trigger_error() in WP_User_Query magic methods.
Replaces `trigger_error()` with `wp_trigger_error()` in each of the `WP_User_Query` magic methods.

[56353] added the dynamic properties deprecation messages to the `__get()`, `__set()`, `__isset()`, `__unset()` magic methods. Since that commit, `wp_trigger_error()` was introduced (see [56530]) as a wrapper for `trigger_error()`.

Follow-up to [56353], [56530].

See #58897, #57686.
Built from https://develop.svn.wordpress.org/trunk@56543


git-svn-id: http://core.svn.wordpress.org/trunk@56055 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-07 20:45:16 +00:00
hellofromTonya
3356628935 Code Modernization: Use wp_trigger_error() in WP_List_Table magic methods.
Replaces `trigger_error()` with `wp_trigger_error()` in each of the `WP_List_Table` magic methods.

[56349] added the dynamic properties deprecation messages to the `__get()`, `__set()`, `__isset()`, `__unset()` magic methods. Since that commit, `wp_trigger_error()` was introduced (see [56530]) as a wrapper for `trigger_error()`.

Follow-up to [56349], [56356], [56530].

See #58896, #57686.
Built from https://develop.svn.wordpress.org/trunk@56542


git-svn-id: http://core.svn.wordpress.org/trunk@56054 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-07 20:41:11 +00:00
joedolson
eb635e4796 Plugins: Respect prefers-reduced-motion on plugin thumbnails.
Pause animated plugin thumbnails when a user has reduced motion preferences configured in their device or operating system.

Props Travel_girl, audrasjb, bordoni, stevejonesdev, joedolson.
Fixes #55723.
Built from https://develop.svn.wordpress.org/trunk@56541


git-svn-id: http://core.svn.wordpress.org/trunk@56053 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-07 20:37:15 +00:00
hellofromTonya
aaec843875 Fonts: Removes static instance in wp_print_font_faces().
The static instance of `WP_Font_Face` is not needed. It was an unnecessary carryover from the experimental Fonts API (which was not introduced into Core).

Whereas the Fonts API needed to persist its data (i.e. to maintain the registered and enqueued fonts throughout the web request), Font Face does not have data to persist.

Font Face processes the fonts it receives when `WP_Font_Face::generate_and_print( $fonts )` is invoked. Thus, a singleton is not needed.

Removing the static reduces the amount of the code in the function and eliminates running its tests in separate processes to ensure a different instance is always used.

References:
* [https://github.com/WordPress/gutenberg/pull/54228 Gutenberg PR 54228].

Follow-up to [56500].

Props hellofromTonya, costdev.
Fixes #59165.
Built from https://develop.svn.wordpress.org/trunk@56540


git-svn-id: http://core.svn.wordpress.org/trunk@56052 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-07 17:30:17 +00:00
desrosj
dedb9c6d5a Build/Test Tools: Update a few more 3rd-party GitHub Action occurrences.
Follow up to [56537].

See #58867.
Built from https://develop.svn.wordpress.org/trunk@56538


git-svn-id: http://core.svn.wordpress.org/trunk@56050 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-07 16:56:21 +00:00
desrosj
0bd85f3b77 Build/Test Tools: Update 3rd-party GitHub Actions.
This updates all 3rd-party GitHub actions to their latest versions. The following actions were updated:
- `actions/cache`
- `actions/checkout`
- `actions/setup-node`
- `codecov/codecov-action`
- `shivammathur/setup-php`
- `slackapi/slack-github-action`

In the latest version of `actions/checkout` (`4.0.0`), a new input was introduced to control the output of command progress. This change uses this new `show-progress` input to turn off displaying progress by default. Progress will be shown when a workflow is run with debug mode enabled, just in case it contains helpful information.

Props johnbillion, desrosj.
See #58867.
Built from https://develop.svn.wordpress.org/trunk@56537


git-svn-id: http://core.svn.wordpress.org/trunk@56049 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-07 16:51:16 +00:00
Sergey Biryukov
2484b193b4 Coding Standards: Remove superfluous blank lines at the end of various files.
Note: This is enforced by WPCS 3.0.0.

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56536


git-svn-id: http://core.svn.wordpress.org/trunk@56048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-07 14:59:21 +00:00
isabel_brison
337a910076 Editor: add configurable viewport sizes for fluid typography.
Adds options to configure min and max viewport sizes for fluid typography in theme.json settings.

Props ramonopoly.
Fixes #59048.

Built from https://develop.svn.wordpress.org/trunk@56535


git-svn-id: http://core.svn.wordpress.org/trunk@56047 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-07 04:30:21 +00:00
isabel_brison
4b87f197f4 Editor: allow disabling layout controls.
Adds the ability to disable layout controls on a per-block level from theme.json.

Props mukesh27.
Fixes #59294.

Built from https://develop.svn.wordpress.org/trunk@56534


git-svn-id: http://core.svn.wordpress.org/trunk@56046 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-07 01:05:19 +00:00
desrosj
1037cc24d7 Bundled Themes: Update npm dependencies for Twenty Nineteen and Twenty Twenty.
This updates the npm dependencies for Twenty Nineteen and Twenty Twenty to their latest versions. This also includes the results of running `npm audit fix`.

There are no changes in any built files as a result.

See #58863.
Built from https://develop.svn.wordpress.org/trunk@56533


git-svn-id: http://core.svn.wordpress.org/trunk@56045 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-07 00:59:18 +00:00
desrosj
d812270755 Bundled Themes: Set legacy-peer-deps to true.
While `npm install` was working without issue after [56531], `npm ci` was not. The latter expects dependencies in the `package-lock.json` to match those in `package.json` exactly.

Follow up to [56378], [56387], [56442], [56531[.

Fixes #59187. See #56658.
Built from https://develop.svn.wordpress.org/trunk@56532


git-svn-id: http://core.svn.wordpress.org/trunk@56044 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-07 00:09:18 +00:00
desrosj
9fae0aac37 Bundled Themes: Use Node.js 16.x in themes with a build process.
This results in a new `package-lock.json` file being generated that uses `lockfileVersion` 2.x.

There are no changes to built files as a result of this update.

Follow up to [56378], [56387], [56442].

Props mikestraw, whyisjake, jivygraphics.
Fixes #59187. See #56658.
Built from https://develop.svn.wordpress.org/trunk@56531


git-svn-id: http://core.svn.wordpress.org/trunk@56043 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-06 23:44:20 +00:00
hellofromTonya
2653e93e09 General: Introduce wp_trigger_error().
Introduces `wp_trigger_error()` as a wrapper around PHP's native `trigger_error()`. As a wrapper, it's lean and not opinionated about the message. It accepts an E_USER family error level, meaning it is not limited to only notices.

Where `_doing_it_wrong()` intends to loudly alert developers "Hey you're doing it wrong - fix it", `wp_trigger_error()` is not opinionated and does not add wording. Rather, it passes the given message to `trigger_error()`.

`wp_trigger_error()` is meant for every `trigger_error()` instance. It can be used:
* in `_doing_it_wrong()` and each `_deprecated_*()` function.
* for PHP 8.x deprecations.
* for PHP error parity.
* for less severe "doing it wrong" instance that do not require bailing out.
* when a component or extension is not available on the server
* for instances where it's not clear if a plugin's or theme's code is the root cause.
* and more.

Technical details:

* Does not trigger the error if `WP_DEBUG` is not `true`.

* Includes `wp_trigger_error_run` action to allow hooking in for backtracing and deeper debug.

* Accepts an E_USER error level, but defaults to `E_USER_NOTICE`.

* Requires a function name, though can be an empty string. As the output message generated by `trigger_error()` references the file and line number where it was invoked, passing the function's name provides more information where the error/warning/notice/deprecation happened. It's intended to help with debug.

* A WordPress version number is not included.

* As messages can appear in the browser, the message is escaped using `esc_html()`. As noted in [https://www.php.net/manual/en/function.trigger-error.php the PHP manual]: "HTML entities in message are not escaped. Use htmlentities() on the message if the error is to be displayed in a browser."

References:
* [https://www.php.net/manual/en/function.trigger-error.php PHP manual for `trigger_error()`].
* [https://www.php.net/manual/en/errorfunc.constants.php E_USER constants (error level) in the PHP manual].

Props azaozz, hellofromTonya, flixos90, costdev, peterwilsoncc, oglekler, mukesh27.
See #57686.
Built from https://develop.svn.wordpress.org/trunk@56530


git-svn-id: http://core.svn.wordpress.org/trunk@56042 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-06 22:08:18 +00:00
Andrew Ozz
91167c488d Editor: Prevent possibility of a fatal error when previewing block themes.
Ensures that preview callbacks attached to the `stylesheet` and `template` filters do not run before `pluggable.php` has been included. These callbacks need functionality from `pluggable.php`.

Props: scruffian, johnbillion, SergeyBiryukov, okat, okat.
Fixes: #59000.
Built from https://develop.svn.wordpress.org/trunk@56529


git-svn-id: http://core.svn.wordpress.org/trunk@56041 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-06 21:48:17 +00:00
Andrew Ozz
a5a870cb4c Editor: Fix loading of assets in blocks in child themes where the directory name starts with the parent theme's directory name. Example: twentyseventeen and twentyseventeen-child.
Props: lgladdy, masteradhoc, audrasjb, rajinsharwar, azaozz.
Fixes: #59018.


Built from https://develop.svn.wordpress.org/trunk@56527


git-svn-id: http://core.svn.wordpress.org/trunk@56039 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-06 21:25:15 +00:00
Felix Arntz
615996176a Bundled Theme: Update default themes to use new script function signature.
In WordPress 6.3, the last parameter of `wp_register_script()` and `wp_enqueue_script()` was changed to an array rather than a boolean. While a boolean is still supported for backward compatibility, it makes sense to update the codebase to use the new signature.

The updates are fully backward compatible:
* In places where `true` was provided, `array( 'in_footer' => true )` will still be interpreted as a boolean true in WordPress versions prior to 6.3.
* In places where `false` was provided, the parameter is omitted which will work correctly throughout all WordPress versions given that is and has been the default value anyway.

Props mrinal013, huzaifaalmesbah, niravsherasiya7707, joemcgill.
Fixes #59302.
See #58634.

Built from https://develop.svn.wordpress.org/trunk@56526


git-svn-id: http://core.svn.wordpress.org/trunk@56038 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-06 21:23:20 +00:00
costdev
9ebcbfae5c Upgrade/Install: Check plugin compatibility during bulk upgrades.
Previously, bulk upgrades did not verify that a plugin package was compatible with the site's WordPress version or the server's PHP version. This could lead to incompatible updates being installed, causing various compatibility issues and errors.

This change implements the following checks:
- If available, the API response's `requires` and `requires_php` values are checked for compatibility. This saves time, diskspace, memory and file operations by failing the upgrade before the package is downloaded and unpacked.
- If the API check passes, the downloaded and unpacked package is verified using `Plugin_Upgrader::check_package()` to ensure a plugin file is present, and the plugin's "RequiresWP" and "RequiresPHP" headers are compatible, if present. This ensures that a mismatch between the API response and the plugin file's headers does not cause an incompatible plugin to be installed.

Props salcode, afragen, mukesh27, iammehedi1, zunaid321, johnbillion, SergeyBiryukov, costdev.
Fixes #59198.
Built from https://develop.svn.wordpress.org/trunk@56525


git-svn-id: http://core.svn.wordpress.org/trunk@56037 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-06 18:30:19 +00:00
Joe McGill
be1b61326b Themes: Avoid stale caches for core block styles.
This fixes an issue introduced in [56044] in which the path to core block styles are cached to avoid expensive file operations on every page load. The original caching strategy is now modified so that only the path relative to the blocks location are stored, rather than the full path, since the path to the `wp-includes` folder can change after the value is generated. The new cached value also includes the current WordPress version value to ensure it is rebuilt when the version changes.

Props lhe2012, coreyw, colorful tones, petitphp, mukesh27, spacedmonkey, joemcgill, flixos90, kimannwall, desmith.
Fixes #59111.


Built from https://develop.svn.wordpress.org/trunk@56524


git-svn-id: http://core.svn.wordpress.org/trunk@56036 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-06 18:08:17 +00:00
spacedmonkey
80245f0791 Themes: Remove unnecessary check if file exists in the theme functions.
Previously, several functions and methods in themes api were designed to check for the existence of files in a child theme before falling back to the parent theme. However, these checks did not consider whether the current theme was a child theme or not, resulting in unnecessary file existence checks for non-child themes. Check to see if stylesheet directory matches the template directory before doing the file exists. This optimization helps reduce unnecessary file system access, as file existence checks can be resource-intensive in PHP. 

The following functions and methods have been updated as part of this enhancement: 
- `WP_Theme::get_file_path`
- `get_theme_file_path`
- `get_theme_file_uri`

Props spacedmonkey, flixos90, sabernhardt, 10upsimon, mukesh27.
Fixes #59279.
Built from https://develop.svn.wordpress.org/trunk@56523


git-svn-id: http://core.svn.wordpress.org/trunk@56035 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-06 13:00:22 +00:00
spacedmonkey
eb7094465d Database: Add expiration for dirsize_cache to transient to improve performance.
The transient `dirsize_cache` stores an array of directory sizes. This transient can grow very large, if the plugin directory has lots of sub directories in it. For example, a site with 30 plugins, the transient was around 2MB. For sites without a persistent object cache, transients without an expiration, are stored in autoloaded options. This means this option would load on every page request. Loading this option on every page request when it is not used it wasteful. Adding a expiration to this transient means it will not autoload. To ensure there is no degradation in performance, the expiration was set to a generous 10-year timeframe, making it highly unlikely to expire before it's refreshed.

Props nicomollet, spacedmonkey, flixos90, wpgurudev.
Fixes #54221.
Built from https://develop.svn.wordpress.org/trunk@56522


git-svn-id: http://core.svn.wordpress.org/trunk@56034 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-06 10:03:20 +00:00
Sergey Biryukov
541fdbceb2 Coding Standards: Correct equals sign alignment in various files.
This resolves a few WPCS warnings:
{{{
Equals sign not aligned with surrounding statements
}}}
so that the output of `composer format` is clean.

Follow-up to [56276], [56302].

Props jrf.
See #59161, #58831.
Built from https://develop.svn.wordpress.org/trunk@56521


git-svn-id: http://core.svn.wordpress.org/trunk@56033 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-06 09:33:21 +00:00
isabel_brison
aac1b7c487 Editor: update packages with bug fixes for 6.3.2
Updates editor npm packages to latest patch versions for the 6.3.x branch.

Props ramonopoly.
See #59293.

Built from https://develop.svn.wordpress.org/trunk@56520


git-svn-id: http://core.svn.wordpress.org/trunk@56032 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-06 03:19:44 +00:00
Sergey Biryukov
f69316e8a5 Docs: Add a @since note for add_new labels change in get_post_type_labels().
Includes removing an obsolete recommendation to use a gettext context matching the post type for disambiguation, which would be redundant with the new labels, as they already include the type of content.

Follow-up [14571], [56515].

See #47125.
Built from https://develop.svn.wordpress.org/trunk@56519


git-svn-id: http://core.svn.wordpress.org/trunk@56031 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-06 00:46:24 +00:00
joedolson
1141b9fee2 Administration: Use admin notice functions in nav menu admin.
Use `wp_get_admin_notice` and `wp_admin_notice` to handle settings notices on the nav menu admin screens.

Props joedolson.
See #57791.
Built from https://develop.svn.wordpress.org/trunk@56518


git-svn-id: http://core.svn.wordpress.org/trunk@56030 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-05 20:50:24 +00:00
joedolson
0aa0c763e2 Administration: Add improved context for add new links.
Consistently expand `Add New` links to include the type of content to add. Improve consistency of text casing to use initial caps throughout.

Props afercia, gonzomir, alexstine, swissspidy, joedolson.
Fixes #47125.
Built from https://develop.svn.wordpress.org/trunk@56515


git-svn-id: http://core.svn.wordpress.org/trunk@56027 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-05 19:26:26 +00:00
Sergey Biryukov
70d853b9cd Code Modernization: Rename parameters that use reserved keywords in wp-includes/functions.php.
While using reserved PHP keywords as parameter name labels is allowed, in the context of function calls using named parameters in PHP 8.0+, this will easily lead to confusion. To avoid that, it is recommended not to use reserved keywords as function parameter names.

This commit renames the `$class` parameter to `$class_name` in `_deprecated_class()`.

Follow-up to [54929], [56467].

Props jrf.
See #59161.
Built from https://develop.svn.wordpress.org/trunk@56514


git-svn-id: http://core.svn.wordpress.org/trunk@56026 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-09-05 12:25:13 +00:00