Commit Graph

48121 Commits

Author SHA1 Message Date
oandregal
66e0592185 Themes: add wp_get_theme_data_custom_templates function.
Adds a new public function, `wp_get_theme_data_custom_templates` that returns the `customTemplates` defined by the active theme from `theme.json`. It also substitutes the usage of private APIs by this new 
API.

Props johnbillion, audrasjb.
Fixes #59137


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


git-svn-id: http://core.svn.wordpress.org/trunk@55925 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-18 13:22:13 +00:00
oandregal
6f42888d5e Add missing @ to the return tag in the wp_get_theme_data_template_parts function.
Props audrasjb, johnbillion.
Fixes #59003


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


git-svn-id: http://core.svn.wordpress.org/trunk@55924 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-18 13:18:17 +00:00
Sergey Biryukov
3fa176f4fe Coding Standards: Improve variable names in wp_save_image().
This resolves a few WPCS warnings:
{{{
Variable "$sX" is not in valid snake_case format, try "$s_x"
Variable "$sY" is not in valid snake_case format, try "$s_y"
}}}

The `$sX` and `$sY` variables are renamed to `$original_width` and `$original_height`, respectively.

Additionally, the `$fwidth` and `$fheight` variables are renamed to `$full_width` and `$full_height`, for clarity.

Follow-up to [11965], [22094], [56400].

See #58831.
Built from https://develop.svn.wordpress.org/trunk@56411


git-svn-id: http://core.svn.wordpress.org/trunk@55923 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-18 10:09:23 +00:00
joedolson
3e1db7f59d Administration: Invalid argument passed in additional_classes.
Fix `additional_classes` argument passed as a string instead of an array. Follow up to [56409].

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


git-svn-id: http://core.svn.wordpress.org/trunk@55922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-17 21:36:21 +00:00
joedolson
82417a694f Administration: Apply admin notice functions in multisite.
Use `wp_get_admin_notice` and `wp_admin_notice` to handle multisite settings notices.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55921 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-17 21:03:19 +00:00
joedolson
d5f3b7feab Administration: Add function to standardize admin notices.
Add functions `wp_get_admin_notice()` and `wp_admin_notice()` to create and output admin notices & tests for usage. New functions accept a message and array of optional arguments. This commit does not implement the functions. Include new filters: `wp_admin_notice_args`, `wp_admin_notice_markup` and action: `wp_admin_notice`. 

Props joedolson, costdev, sakibmd, dasnitesh780, sabernhardt.
Fixes #57791.
Built from https://develop.svn.wordpress.org/trunk@56408


git-svn-id: http://core.svn.wordpress.org/trunk@55920 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-17 20:29:21 +00:00
desrosj
aa9955e926 Build/Test Tools: Revert Slack messaging changes.
This reverts [56404], [56405], [56406].

More testing is needed to ensure multiple messages are not sent unintentionally.

Unprops desrosj.
See #58867.
Built from https://develop.svn.wordpress.org/trunk@56407


git-svn-id: http://core.svn.wordpress.org/trunk@55919 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-17 17:58:15 +00:00
desrosj
3b88a37e6e Build/Test Tools: Send a failure notice in Slack when a run fails to start.
This adds `startup_failure` to the list of conclusions that the Slack workflow looks for when determining whether to send a failure notice.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55918 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-17 17:36:16 +00:00
desrosj
47a06aed12 Build/Test Tools: Use the correct variable for checking the previous conclusion.
Follow up to [56404].
See #58867.
Built from https://develop.svn.wordpress.org/trunk@56405


git-svn-id: http://core.svn.wordpress.org/trunk@55917 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-17 17:19:17 +00:00
desrosj
c165f9d301 Build/Test Tools: Don’t send a Slack notice when a workflow fails once.
[53947] introduced a callable workflow that allowed a workflow run to be retried automatic. By default all workflows are retried once.

Since a run is not considered “failed” until after the automatic retry, the first Slack message is unnecessary and can cause a lot of noise when there are network hiccups.

This alters the logic to skip a failure notice in Slack until the second failure.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55916 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-17 17:01:18 +00:00
Weston Ruter
36d24b511a Editor: Ensure defer loading strategy is only applied to a block's viewScript.
Amends [56398].
Props gziolo, westonruter.
Fixes #59115.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55915 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-17 16:39:18 +00:00
desrosj
a8ab676b36 Build/Test Tools: Simplify the required prerequisite jobs for the failed-workflow job.
Because `slack-notifications` job requires all preceding jobs in each workflow to complete, there’s no need to include the same jobs in the `needs` configuration for the `failed-workflow` one.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55914 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-17 14:44:16 +00:00
Sergey Biryukov
a26771b347 Site Health: Correct the check for disk space available to safely perform updates.
If the available disk space exceeds the `PHP_INT_MAX` value, i.e. a 32-bit PHP version is in use with more than 2 GB free, the type casting to `(int)` could cause an overflow, and the Site Health test would then erroneously report that there is not enough free space. 

This commit removes the unnecessary type casting and uses the result from `disk_free_space()` directly.

Includes optimizing the logic to skip further checks if the available disk space could not be determined.

Follow-up to [55720].

Props mathsgrinds, Presskopp, rajinsharwar, SergeyBiryukov.
Fixes #59116.
Built from https://develop.svn.wordpress.org/trunk@56401


git-svn-id: http://core.svn.wordpress.org/trunk@55913 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-17 11:18:21 +00:00
Sergey Biryukov
caddf7e3dc Coding Standards: Use strict comparison in wp-admin/includes/image-edit.php.
Follow-up to [11911], [11965], [11984], [12155], [12163], [22094].

Props aristath, poena, afercia, SergeyBiryukov.
See #58831.
Built from https://develop.svn.wordpress.org/trunk@56400


git-svn-id: http://core.svn.wordpress.org/trunk@55912 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-16 14:05:20 +00:00
Pascal Birchler
e30f7901a5 Build/Test Tools: Measure additional load time metrics in performance tests.
Three new metrics are being collected and reported as part of this change:

- Time To First Byte (TTFB) - the time between the request for a resource and when the first byte of a response begins to arrive
- Largest Contentful Paint (LCP) — the render time of the largest image or text block visible within the viewport
- The difference between the two (LCP minus TTFB)

Props joemcgill, flixos90, oandregal, mukesh27, youknowriad, swissspidy.
Fixes #58360.
Built from https://develop.svn.wordpress.org/trunk@56399


git-svn-id: http://core.svn.wordpress.org/trunk@55911 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-16 08:48:23 +00:00
Weston Ruter
467c7de24d Editor: Use defer loading strategy for block view scripts.
Props westonruter, joemcgill.
Fixes #59115.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55910 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-16 00:15:23 +00:00
Sergey Biryukov
832b4660fd Docs: Fix typo in duplicate hook references for views_{$this->screen->id}.
Follow-up to [29218], [29625].

Props nithins53, NekoJonez, mukesh27.
Fixes #59102. See #58833.
Built from https://develop.svn.wordpress.org/trunk@56397


git-svn-id: http://core.svn.wordpress.org/trunk@55909 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-15 10:09:24 +00:00
Sergey Biryukov
356e6cac57 Coding Standards: Use strict comparison in wp-admin/includes/class-wp-importer.php.
Follow-up to [14760], [50658].

Props aristath, poena, afercia, SergeyBiryukov.
See #58831.
Built from https://develop.svn.wordpress.org/trunk@56396


git-svn-id: http://core.svn.wordpress.org/trunk@55908 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-14 09:59:20 +00:00
Sergey Biryukov
11aa9b4da5 Coding Standards: Bring more consistency to Last-Modified and ETag checks.
This updates two fragments for sending a `304 Not Modified` header to better align with each other by using consistent variable names and formatting. 

Follow-up to [1036], [1037], [1043], [2534], [2584], [2627], [12603], [12936], [56362].

See #58831.
Built from https://develop.svn.wordpress.org/trunk@56395


git-svn-id: http://core.svn.wordpress.org/trunk@55907 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-13 10:31:23 +00:00
Sergey Biryukov
22f80e9382 Coding Standards: Use strict comparison in wp-includes/cron.php.
Includes minor code layout fixes for better readability.

Follow-up to [3634], [4189].

Props aristath, poena, afercia, SergeyBiryukov.
See #58831.
Built from https://develop.svn.wordpress.org/trunk@56394


git-svn-id: http://core.svn.wordpress.org/trunk@55906 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-12 12:02:24 +00:00
desrosj
0c05aa75e8 External Libraries: Update imagesLoaded to version 5.0.0.
This release drops support for IE and moves to using ES6.

A full list of changes can be found on GitHub: https://github.com/desandro/imagesloaded/compare/v4.1.4...v5.0.0.

Props nazsabuz, arnedb, costdev, audrasjb, ahmedgeek , valmedia2023 , hareesh-pillai.
Fixes #56731.
Built from https://develop.svn.wordpress.org/trunk@56393


git-svn-id: http://core.svn.wordpress.org/trunk@55905 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-11 18:18:26 +00:00
John Blackbourn
a240a161b9 Editor: Only exclude auto-generated block files from coding standards checks.
Prior to this change, all block files were excluded from coding standards checks, but there's no reason these files shouldn't adhere to core's coding standards.

Props lopo, Rahe, adamsilverstein 

Fixes #50010

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


git-svn-id: http://core.svn.wordpress.org/trunk@55904 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-11 17:03:17 +00:00
desrosj
43e676dedb External Libraries: Update Backbone.js to version 1.5.0.
This release contains bug fixes and documentation improvements.

A full list of changes can be found on GitHub: https://github.com/jashkenas/backbone/compare/1.4.1...1.5.0.

Props rajinsharwar, hareesh-pillai.
Fixes #58930.
Built from https://develop.svn.wordpress.org/trunk@56391


git-svn-id: http://core.svn.wordpress.org/trunk@55903 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-11 16:12:21 +00:00
desrosj
afd36de0b5 Build/Test Tools: Update all build tool related dependencies.
This updates the following dependencies to their latest versions:
- `chalk`
- `cssnano`
- `dotenv`
- `grunt-contrib-cssmin`
- `grunt-contrib-qunit`
- `grunt-webpack`
- `jest-image-snapshot`
- `postcss`
- `sass`
- `sinon`
- `webpack`

Additionally, `npm audit fix` has been run to automatically fix as many issues as possible.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55902 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-11 16:04:29 +00:00
desrosj
dbb1d98290 External Libraries: Update the whatwg-fetch polyfill library.
This updates the `whatwg-fetch` library from version `3.6.2` to `3.6.17`, the latest current version.

This library is included and registered within WordPress as the `wp-polyfill-fetch` script and is no longer used by WordPress itself.

Props rajinsharwar, hareesh-pillai.
Fixes #59066.
Built from https://develop.svn.wordpress.org/trunk@56389


git-svn-id: http://core.svn.wordpress.org/trunk@55901 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-11 14:44:18 +00:00
desrosj
c392de6215 Build/Test Tools: Update 3rd-party GitHub Actions.
This updates all 3rd-party GitHub Actions to their latest versions.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55900 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-11 13:05:17 +00:00
desrosj
1fca49bfda Build/Test Tools: Update the README file to reflect new Node.js/npm versions.
Follow up to [56378].

Props dantovbein, hbhalodia.
Fixes #59071. See #56658.
Built from https://develop.svn.wordpress.org/trunk@56387


git-svn-id: http://core.svn.wordpress.org/trunk@55899 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-11 12:49:15 +00:00
Sergey Biryukov
93bf4a6d6f Docs: Correct duplicate hook reference for wp_min_priority_img_pixels.
The original filter location is `wp_maybe_add_fetchpriority_high_attr()` in `wp-includes/media.php`.

This commit updates the instance in `wp_get_loading_optimization_attributes()` to point to the correct file.

Follow-up to [56037], [56143], [56347].

Props tmatsuur, rajinsharwar, khokansardar.
Fixes #59067.
Built from https://develop.svn.wordpress.org/trunk@56386


git-svn-id: http://core.svn.wordpress.org/trunk@55898 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-11 11:35:19 +00:00
oandregal
96c6c273dd Themes: add wp_get_theme_data_template_parts function.
Adds a new public function, `wp_get_theme_data_template_parts` that returns the `templateParts` defined by the active theme from `theme.json`. It also substitutes the usage of private APIs by this new API.

Props felixarntz.
Fixes #59003

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


git-svn-id: http://core.svn.wordpress.org/trunk@55897 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-11 11:24:11 +00:00
Sergey Biryukov
77a55d839e Tests: Correct two @covers annotations to use the recommended pattern.
When global functions are covered, they need to be prefixed with `::` (double colon) to distinguish them from class name.

Reference: [https://docs.phpunit.de/en/10.3/annotations.html#covers PHPUnit Manual: @covers annotation].

Follow-up to [48848], [49305], [53741], [56296].

Props ayeshrajans.
Fixes #59069.
Built from https://develop.svn.wordpress.org/trunk@56384


git-svn-id: http://core.svn.wordpress.org/trunk@55896 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-11 11:19:20 +00:00
Weston Ruter
a2cdce6c82 Embeds: Modernize wp-embed script with removal of obsolete IE10/IE11 code and support for WP<4.4.
* Remove obsolete `load` event handler in `wp-embed` since IE10+ support `DOMContentLoaded`.
* Replace obsolete use of `document.createElement('a')` in favor of the newer `URL` class (supported in all browsers but obsolete IE11).
* Remove obsolete IE10/IE11 code.
* Combine conditionals.
* Use `substring()` instead of deprecated `substr()` method.
* Eliminate the stipulation that `wp-embed.js` not include ampersands, considering this was put in place for WP<4.3 which now accounts for only 1.43% of sites. This includes the elimination of the `verify:wp-embed` grunt task.

Props westonruter, swissspidy.
Fixes #58974.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55895 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-10 19:49:17 +00:00
Felix Arntz
268203f8aa Editor: Simplify usage of block_has_support() function by supporting a string.
Most block feature checks are for a single feature string, and for such cases it is not intuitive to require an array for the `$feature` parameter of the `block_has_support()` function.

This changeset brings it in line with other functions like `post_type_supports()`, allowing to pass a string for the `$feature`. An array is still supported for more complex cases where support for sub-features needs to be determined. This change furthermore includes a very minor performance tweak by avoiding calls to the `_wp_array_get()` function if a single feature string is being checked for.

Props thekt12, nihar007, mukesh27, swissspidy.
Fixes #58532.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55894 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-10 16:48:19 +00:00
Sergey Biryukov
f106155bf8 Users: Correct the logic for switch_to_blog() in WP_User_Query::generate_cache_key().
If `$blog_id` equals `0`, it should be treated as the current site ID, and there is no need to switch to a different site.

This commit prevents an unnecessary call to `switch_to_blog()` on single site to avoid a fatal error when using `'orderby' => 'post_count'` and the deprecated `'who' => 'authors'` parameter:
{{{
Uncaught Error: Call to undefined function switch_to_blog() in wp-includes/class-wp-user-query.php:1077
}}}

Follow-up to [55657].

Props dd32, austinginder, RavanH, mukesh27.
Fixes #59011.
Built from https://develop.svn.wordpress.org/trunk@56381


git-svn-id: http://core.svn.wordpress.org/trunk@55893 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-10 10:26:19 +00:00
Bernhard Reiter
12884f0361 HTML API: Add support for BUTTON element.
This patch adds support to process the BUTTON element. This requires adding some additional semantic rules to handle situations where a BUTTON element is already in scope.

Also included is a fixup to enforce that `WP_HTML_Processor::next_tag()` never returns for a tag closer. This is useful with the Tag Processor, but not for the HTML Processor. There were tests relying on this behavior to assert that internal processes were working as they should, but those tests have been updated to use the semi-private `step()` function, which does stop on tag closers.

This patch is one in a series of changes to expand support within the HTML API, moving gradually to allow for more focused changes that are easier to review and test. The HTML Processor is a work in progress with a certain set of features slated to be ready and tested by 6.4.0, but it will only contain partial support of the HTML5 specification even after that. Whenever it cannot positively recognize and process its input it bails, and certain function stubs and logical stubs exist to structure future expansions of support.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55892 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-10 08:37:20 +00:00
Sergey Biryukov
5ac6ad6e2e Docs: Remove @see references for SimplePie classes.
As SimplePie is an external library, these classes are not parsed for the WordPress Code Reference, so the `@see` tags were linking to non-existing pages.

Follow-up to [38112].

Props crstauf.
Fixes #59030.
Built from https://develop.svn.wordpress.org/trunk@56379


git-svn-id: http://core.svn.wordpress.org/trunk@55891 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-10 01:06:21 +00:00
desrosj
c7133f4fae Build/Test Tools: Bump the required versions of Node.js and npm.
This changes the minimum required version of Node.js to 16.19.1, and npm to 8.19.3.

Node.js 14.x reached end of life on April 30, 2023. While 18.x is the currently active LTS version, it can’t yet be used due to a systems level constraint on the build server. 

Updating further will be considered once this blocker is resolved.

Gutenberg has also been updated to follow the same version requirements for consistency.

Props youknowriad, gziolo, swissspidy, kevin940726, desrosj.
Fixes #56658.
Built from https://develop.svn.wordpress.org/trunk@56378


git-svn-id: http://core.svn.wordpress.org/trunk@55890 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-09 18:54:51 +00:00
Sergey Biryukov
ba52c45385 Coding Standards: Use strict comparison in wp-includes/kses.php.
Follow-up to [649], [2896], [3418], [8386], [20540], [47219], [54933].

Props aristath, poena, afercia, SergeyBiryukov.
See #58831.
Built from https://develop.svn.wordpress.org/trunk@56377


git-svn-id: http://core.svn.wordpress.org/trunk@55889 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-09 11:01:24 +00:00
Aaron Jorbin
5341f9b212 HTML API: Fix missing * for docblock.
Follow up to [56363].

Props dmsnell.
See #58918. Fixes #59010.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55888 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-08 23:01:26 +00:00
Felix Arntz
65a442fbcd Options, Meta APIs: Expand $autoload parameter documentation.
This changeset expands documentation of the `$autoload` parameter of the `add_option()` and `update_option()` functions, in order to provide more context on what autoloading is and which considerations should go into the decision whether to autoload an option.

Excessive autoloading of options can lead to severe performance problems on some sites, and lack of documentation is a partial cause for the issue.

Props rajinsharwar.
Fixes #58963.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55882 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-07 19:33:32 +00:00
davidbaumwald
2ecfc4f9a0 Upgrade/Install: Update $_old_files for 6.3.
Props SergeyBiryukov.
Fixes #58994.
Built from https://develop.svn.wordpress.org/trunk@56365


git-svn-id: http://core.svn.wordpress.org/trunk@55877 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-07 17:21:29 +00:00
Bernhard Reiter
fa83c8e1cd HTML API: Adjust code styling to Gutenberg's linter's preferences.
Adjust the code style according to the rules that the linting process in Gutenberg requires.

There are only a couple code changes that should have no effect on the runtime:
 - A missing check to verify that only `UTF-8` is supported has been added (brought up because it was identified as an undefined variable).
 - A few `return false;` statements have been added to avoid having the linter complain that functions don't return a value despite indicating they return `bool`. The functions are stubs for coming support and currently `throw`, so the `return` statements are unreachable.

Props dmsnell, costdev, davidbaumwald, peterwilsoncc, SergeyBiryukov.
Fixes #58918.
Built from https://develop.svn.wordpress.org/trunk@56363


git-svn-id: http://core.svn.wordpress.org/trunk@55875 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-07 13:50:27 +00:00
Sergey Biryukov
da0f366b22 Coding Standards: Use strict comparison in wp-includes/class-wp.php.
Includes minor code layout fixes for better readability.

Follow-up to [1043], [2534], [2584], [2627], [2958], [3252], [3564], [21818], [37356].

Props aristath, poena, afercia, SergeyBiryukov.
See #58831.
Built from https://develop.svn.wordpress.org/trunk@56362


git-svn-id: http://core.svn.wordpress.org/trunk@55874 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-07 10:01:27 +00:00
Sergey Biryukov
52317da292 Coding Standards: Use strict comparison in wp-includes/class-wp-image-editor.php.
Follow-up to [22094].

Props aristath, poena, afercia, SergeyBiryukov.
See #58831.
Built from https://develop.svn.wordpress.org/trunk@56361


git-svn-id: http://core.svn.wordpress.org/trunk@55873 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-06 12:52:25 +00:00
Sergey Biryukov
df89489ac6 Coding Standards: Rewrite loose comparison in wp_list_categories().
A truthy check is more in line with similar checks elsewhere, including conditionals in the same exact code block.

Follow-up to [10275], [34696].

Props aristath, poena, afercia, SergeyBiryukov.
See #58831.
Built from https://develop.svn.wordpress.org/trunk@56360


git-svn-id: http://core.svn.wordpress.org/trunk@55872 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-05 14:02:26 +00:00
Sergey Biryukov
ba7c01a09c Coding Standards: Use strict comparison in wp-includes/revision.php.
Follow-up to [24414], [38118], [38433].

Props aristath, poena, afercia, SergeyBiryukov.
See #58831.
Built from https://develop.svn.wordpress.org/trunk@56359


git-svn-id: http://core.svn.wordpress.org/trunk@55871 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-04 11:58:25 +00:00
Weston Ruter
b26df97c16 Emoji: Suppress console errors from sessionStorage usage in sandboxed post embed iframe.
Amends [56074].

Props westonruter, flixos90.
Fixes #58978.
See #58472.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55870 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-04 00:23:25 +00:00
Felix Arntz
7c7f95a8b2 Themes: Avoid unnecessary check whether parent template file exists when not using a child theme.
Prior to this change, the `locate_template()` function would unconditionally check whether the relevant template file exists in the parent theme, which for sites not using a child theme is an exact duplicate of the previous check. This is wasteful and has a small impact on performance since `file_exists()` checks have a cost.

Props nihar007, thekt12, spacedmonkey, mukesh27.
Fixes #58576.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55869 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-03 20:31:22 +00:00
hellofromTonya
65da089d96 Code Modernization: Use "declare" in WP_List_Table magic methods deprecation message
Changes "define" to "declare" in the deprecation message in `WP_List_Table` magic methods.

Why is "declare" better?
It aligns well to:

* the topic of and published information about dynamic properties.
* the act of explicitly listing the variable as a property on the class.

The goal of this message is guide developers to change their code. Changing the term to "declare" hopefully will aid in the understanding of what is being asked of developers when this deprecation is thrown.

Follow-up [56349].

Props hellofromTonya, antonvlasenko.
Fixes #58896.
Built from https://develop.svn.wordpress.org/trunk@56356


git-svn-id: http://core.svn.wordpress.org/trunk@55868 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-03 19:52:22 +00:00
Weston Ruter
5ccbf34eaa Script Loader: Use defer loading strategy for wp-embed script and move to head (in block themes).
Props westonruter, flixos90, swissspidy.
Fixes #58931.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55867 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-03 19:22:22 +00:00
hellofromTonya
7d0d2b0edf Code Modernization: Deprecate dynamic properties in WP_Text_Diff_Renderer_Table magic methods.
The unknown use of unknown dynamic property within the `WP_Text_Diff_Renderer_Table` property magic methods is now deprecated. A descriptive deprecation notice is provided to alert developers to declare the property on the child class extending `WP_Text_Diff_Renderer_Table`.

Changes in this commit:
* Adds a deprecation notice to the `__get()`, `__set()`, `__isset()`, `__unset()` magic methods, i.e. to alert and inform developers when attempting to get/set/isset/unset a dynamic property.
* Fixes `__get()` to explicitly returns `null` when attempting to get a dynamic property.
* Fixes `__set()` by removing the value return after setting a declared property, as (a) unnecessary and (b) `__set()` should return `void` [https://www.php.net/manual/en/language.oop5.overloading.php#object.set per the PHP handbook].
* Fixes `__isset()` to return `false` if not in the `$compat_fields`, as `isset()` and `__isset()` should always return `bool`:
   * [https://www.php.net/manual/en/language.oop5.overloading.php#object.isset `__isset()` in the PHP manual] 
   * [https://www.php.net/manual/en/function.isset.php `isset()` in the PHP manual] 
* Adds a test class with happy and unhappy paths for these changes.

For backward compatibility, no changes are made to the internal declared properties listed in `$compat_fields` and accessed through the magic methods. 

For example:
A child class uses a property named `$data` that is not declared as a property on the child class. When getting its value, e.g. `$user_query->data`, the `WP_Text_Diff_Renderer_Table::__get()` magic method is invoked, the following deprecation notice thrown, and `null` returned:

>The property `data` is not declared. Setting a dynamic property is deprecated since version 6.4.0! Instead, declare the property on the class.

=== Why not remove the magic methods, remove the `$compat_fields` property, and restore the properties `public`?

tl;dr Backward compatibility.

If a plugin adds a property to `$compat_fields` array, then sites using that plugin would experience (a) an `Undefined property` `Warning` (PHP 8) | `Notice` (PHP 7) and (b) a possible change in behavior.

=== Why not limit the deprecation for PHP versions >= 8.2?

tl;dr original design intent and inform

The magic methods and `$compat_fields` property were added for one purpose: to continue providing external access to internal properties declared on `WP_Text_Diff_Renderer_Table`. They were not intended to be used for dynamic properties.

Deprecating that unintended usage both alerts developers a change is needed in their child class and informs them what to change.

References: 
* Dynamic (non-explicitly declared) properties are deprecated as of PHP 8.2 and are expected to become a fatal error in PHP 9.0.
* A [https://www.youtube.com/live/vDZWepDQQVE?feature=share&t=10097 live open public working session] where these changes were discussed and agreed to.
* [https://wiki.php.net/rfc/deprecate_dynamic_properties PHP RFC: Deprecate dynamic properties.]

Follow-up to [28525], [31135].

Props antonvlasenko, rajinsharwar, jrf, markjaquith, hellofromTonya, SergeyBiryukov, desrosj, peterwilsoncc, audrasjb, costdev, oglekler, jeffpaul.
Fixes #58898.
See #56034.
Built from https://develop.svn.wordpress.org/trunk@56354


git-svn-id: http://core.svn.wordpress.org/trunk@55866 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-08-03 18:13:24 +00:00