Commit Graph

1411 Commits

Author SHA1 Message Date
Sergey Biryukov
84e9601e5a Code Modernization: Replace usage of substr() with str_starts_with() and str_ends_with().
`str_starts_with()` and `str_ends_with()` were introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins or ends with the given substring (needle).

WordPress core includes a polyfill for these functions on PHP < 8.0 as of WordPress 5.9.

This commit uses `str_starts_with()` and `str_ends_with()` in core files where appropriate:
* `$needle === substr( $string, 0, $length )`, where `$length` is the length of `$needle`, is replaced with `str_starts_with( $haystack, $needle )`.
* `$needle === substr( $string, $offset )`, where `$offset` is negative and the absolute value of `$offset` is the length of `$needle`, is replaced with `str_ends_with( $haystack, $needle )`.

This aims to make the code more readable and consistent, as well as better aligned with modern development practices.

Follow-up to [52039], [52040], [52326], [55703], [55710], [55987], [55988].

Props Soean, spacedmonkey, Clorith, ocean90, azaozz, sabernhardt, SergeyBiryukov.
Fixes #58220.
Built from https://develop.svn.wordpress.org/trunk@55990


git-svn-id: http://core.svn.wordpress.org/trunk@55502 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-22 14:57:24 +00:00
Sergey Biryukov
1ce5dc7444 Code Modernization: Replace usage of strpos() with str_contains().
`str_contains()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) contains the given substring (needle).

WordPress core includes a polyfill for `str_contains()` on PHP < 8.0 as of WordPress 5.9.

This commit replaces `false !== strpos( ... )` with `str_contains()` in core files, making the code more readable and consistent, as well as better aligned with modern development practices.

Follow-up to [52039], [52040], [52326], [55703], [55710], [55987].

Props Soean, spacedmonkey, costdev, dingo_d, azaozz, mikeschroder, flixos90, peterwilsoncc, SergeyBiryukov.
Fixes #58206.
Built from https://develop.svn.wordpress.org/trunk@55988


git-svn-id: http://core.svn.wordpress.org/trunk@55500 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-22 14:36:26 +00:00
Sergey Biryukov
c965fefd6e Posts, Post Types: Introduce item_trashed post type label.
This allows the block editor to announce the correct message when an entity is moved to the Trash.

Original issue from Gutenberg repository:
* [https://github.com/WordPress/gutenberg/issues/19144 #19144 Wrong notification message shown when an entity is moved to trash]

Props james-roberts, ntsekouras, nrqsnchz, afercia, swissspidy, joedolson, talldanwp, SergeyBiryukov.
Fixes #51387.
Built from https://develop.svn.wordpress.org/trunk@55923


git-svn-id: http://core.svn.wordpress.org/trunk@55435 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-15 01:39:20 +00:00
spacedmonkey
a88a66b0bd Posts, Post Types: Add a new filter for query arguments in get_pages.
In [55569] `get_pages` was converted to use `WP_Query` internally. But for plugins that were extending the `get_pages` filters and filter `WP_Query` query arguments, this could result in a conflict. Add a filter `get_pages_query_args` to allow developers to change arguments passed to `WP_Query` but also have the context of the original arguments passed to the `get_pages` function. 

This change also expands test coverage of `get_pages` to ensure no breakages in the future. 

Props spacedmonkey, westonruter, costdev, flixos90, kenwins, marianne38.
See #12821.
Built from https://develop.svn.wordpress.org/trunk@55845


git-svn-id: http://core.svn.wordpress.org/trunk@55357 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-22 10:03:22 +00:00
davidbaumwald
fe27bb8d0b Revisions: Add edit link functionality for the wp_template and wp_template_part post types.
In preparation for viewing revisions of templates and template parts in the editor, this set changes adds the `_edit_link` argument when registering the `wp_template` and `wp_template_part` post types.  This commit also updates `get_edit_post_link` to account for the unique edit URLs for these post types.

Finally, this commit also adds new unit tests for the `get_edit_post_link` function, including tests for the `post`, `wp_template`, and `wp_template_part` post types.

Fixes #57709.
Props andraganescu, spacedmonkey, antonvlasenko, youknowriad, ramonopoly, ironprogrammer, annezazu.
Built from https://develop.svn.wordpress.org/trunk@55743


git-svn-id: http://core.svn.wordpress.org/trunk@55255 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-10 17:36:21 +00:00
John Blackbourn
5ef972680a Docs: A host of corrections and improvements to inline documentation.
See #57840

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


git-svn-id: http://core.svn.wordpress.org/trunk@55244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-08 22:37:24 +00:00
Andrea Fercia
6064478fa7 Post Types: Add the view_items label to the wp_block post type.
The `view_items` post type label is used in the Editor, for the `aria-label` of the link to go back to the Posts list. When editing a Reusable block, it fallbacks to 'View Posts'. It should be 'View Reusable blocks'.

Fixes #58209.

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


git-svn-id: http://core.svn.wordpress.org/trunk@55221 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-03 14:08:18 +00:00
Sergey Biryukov
2ec23a82ed Code Modernization: Replace usage of strpos() with str_starts_with().
`str_starts_with()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins with the given substring (needle).

WordPress core includes a polyfill for `str_starts_with()` on PHP < 8.0 as of WordPress 5.9.

This commit replaces `0 === strpos( ... )` with `str_starts_with()` in core files, making the code more readable and consistent, as well as improving performance.

While `strpos()` is slightly faster than the polyfill on PHP < 8.0, `str_starts_with()` is noticeably faster on PHP 8.0+, as it is optimized to avoid unnecessarily searching along the whole haystack if it does not find the needle.

Follow-up to [52039], [52040], [52326].

Props spacedmonkey, costdev, sabernhardt, mukesh27, desrosj, jorbin, TobiasBg, ayeshrajans, lgadzhev, SergeyBiryukov.
Fixes #58012.
Built from https://develop.svn.wordpress.org/trunk@55703


git-svn-id: http://core.svn.wordpress.org/trunk@55215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-02 15:45:22 +00:00
spacedmonkey
c1facaa4ce Cache API: Add helper function wp_cache_set_last_changed.
Add a helper function called `wp_cache_set_last_changed` to set the last changed value for cache groups. This function has a new action called `wp_cache_set_last_changed`, allowing for developers to cache invalidate when last changed value is changed. 

Props tillkruess, spacedmonkey, peterwilsoncc, mukesh27, johnjamesjacoby. 
Fixes #57905.
Built from https://develop.svn.wordpress.org/trunk@55702


git-svn-id: http://core.svn.wordpress.org/trunk@55214 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-02 11:26:24 +00:00
spacedmonkey
4bdeb57ac5 Taxonomy: Remove redundant call to get_term in wp_queue_posts_for_term_meta_lazyload.
In [55252] the function `wp_queue_posts_for_term_meta_lazyload` was refactored to use `wp_cache_get_multiple`. This refactor included a call to `get_term`. However, calling get_term calls `sanitize_term`, which sanitizes all fields in a term. The full term object is not needed in this context as term meta only needs to the term id, which is already in the function. Saving calls to `sanitize_term` will improve performance of this function. 

Props spacedmonkey, joemcgill, mukesh27. 
Fixes #57966.
Built from https://develop.svn.wordpress.org/trunk@55701


git-svn-id: http://core.svn.wordpress.org/trunk@55213 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-02 10:57:24 +00:00
John Blackbourn
f14f3ba995 Docs: All sorts of improvements and corrections to function and hook docs.
See #57840

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


git-svn-id: http://core.svn.wordpress.org/trunk@55206 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-04-27 23:15:17 +00:00
Sergey Biryukov
0c5a04d541 Coding Standards: Use strict comparison where strtolower() is involved.
Follow-up to [649], [7736], [18821], [19444], [20886], [20893], [23303], [55642], [55652], [55653], [55654].

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


git-svn-id: http://core.svn.wordpress.org/trunk@55189 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-04-22 15:19:22 +00:00
spacedmonkey
469d8a5e24 Taxonomy: Always lazily load term meta.
In [34529] introduced lazy loading of term meta. However, this was only in the context of `WP_Query`. Other parts of the codebase, like `WP_Term_Query` did not lazily load term meta. In this change, calls to `update_termmeta_cache` are now replaced with `wp_lazyload_term_meta`, that instead of priming term meta caches, just adds them to the queue to be primed it ever called. This results in far less database queries, as there a number of places where term meta is being primed unnecessarily and never used. Adding everything to the term meta queue, also means that if term meta is used, that is all loaded in a single database / cache call.

Props spacedmonkey, mukesh27, peterwilsoncc. 
Fixes #57645.
Built from https://develop.svn.wordpress.org/trunk@55671


git-svn-id: http://core.svn.wordpress.org/trunk@55183 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-04-21 09:24:22 +00:00
Sergey Biryukov
bdfe3d5a46 Coding Standards: Use strict comparison where count() is involved.
Follow-up to [1636], [6974], [8114], [10322], [13326], [14760], [18006], [18541], [19743], [23249], [24115], [33359].

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


git-svn-id: http://core.svn.wordpress.org/trunk@55154 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-04-10 12:56:21 +00:00
Sergey Biryukov
a415951b8f Docs: Document default values for optional parameters in wp_insert_attachment().
This adds the missing mentions of default value for the `$file` and `$parent_post_id` parameters.

Follow-up to [2921], [3092], [3303], [3851], [6155], [6379], [8669], [15590], [28788], [38408], [49936], [55021].

Props wpfy.
Fixes #58043.
Built from https://develop.svn.wordpress.org/trunk@55617


git-svn-id: http://core.svn.wordpress.org/trunk@55129 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-04-02 13:01:23 +00:00
spacedmonkey
7dde8c4440 Posts, Post Types: Use WP_Query internally in get_pages.
Convert `get_pages` to use `WP_Query` internally. Using WP_Query means that a lot of code has been removed however existing parameters supported by get_pages are transformed in to query arguments. The custom caching solution found in the old version of this function is replaced with the caching found in WP_Query (added in [53941]). This change adds consistency to the codebase, as improvements and changes to `WP_Query` will filter down to the `get_pages` function. 

Props mikeschinkel, spacedmonkey, nacin, scribu, filosofo, jane, garyc40, markoheijnen, grandslambert, kevinB, wlindley, dbernar1, atimmer, mdawaffe, helen, benjibee, johnbillion, peterwilsoncc, costdev, flixos90, joemcgill.
Fixes #12821.
Built from https://develop.svn.wordpress.org/trunk@55569


git-svn-id: http://core.svn.wordpress.org/trunk@55081 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-03-21 12:49:18 +00:00
spacedmonkey
1bf93a87a4 Cache API: Introduce new queries cache groups.
Give developers more control over how query caches are handled within an object caches. Now all caches that cache the result of a query, are cached in a group that is suffixed with -queries. Developers can use these groups, to add custom cache invalidation rules or to make them none persistent.

Props spacedmonkey, owi, tillkruess, skithund, peterwilsoncc, flixos90, sergeybiryukov, mukesh27.
Fixes #57625.
Built from https://develop.svn.wordpress.org/trunk@55526


git-svn-id: http://core.svn.wordpress.org/trunk@55048 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-03-10 16:30:03 +00:00
Andrew Ozz
e9d290a104 Media: Revert the addition of a $size parameter to get_attached_file().
Reverts [55199], [55202], and [55217] but keeps the updated docs.

Props: flixos90, joedolson, azaozz.
Fixes: #51780.
Built from https://develop.svn.wordpress.org/trunk@55437


git-svn-id: http://core.svn.wordpress.org/trunk@54970 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-03-01 00:36:24 +00:00
Dominik Schilling
6d0eaf9674 Taxonomy: Rename temporary variable in wp_queue_posts_for_term_meta_lazyload().
This ensures the `$term_ids` variable only contains term IDs and is not filled with full term objects due to deprecated term caching.

Introduced in [55252].

Props skithund, Chouby, joemcgill, flixos90, ocean90.
Fixes #57150.
Built from https://develop.svn.wordpress.org/trunk@55401


git-svn-id: http://core.svn.wordpress.org/trunk@54934 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-21 21:04:17 +00:00
Sergey Biryukov
1553e3fa00 Coding Standards: Rename $post_ID variable to $post_id in various files.
The `$post_ID` variable is [546f59c678/WordPress/Sniffs/NamingConventions/ValidVariableNameSniff.php (L54) technically allowed in WPCS], as there is a global of the same name that needs to remain for backward compatibility. However, this name is mostly a remnant of legacy code, and switching to `$post_id` where appropriate brings more consistency with the rest of core.

Additionally, this commit resolves a few WPCS warnings in core:
{{{
Variable "$post_IDs" is not in valid snake_case format
}}}

This affects:
* Function parameters in:
 * `add_meta()`
 * `post_preview()`
 * `WP_Embed::delete_oembed_caches()`
 * `WP_Embed::cache_oembed()`
 * `wp_get_post_cats()`
 * `wp_set_post_cats()`
 * `wp_unique_post_slug()`
 * `wp_set_post_categories()`
 * `wp_check_post_hierarchy_for_loops()`
 * `wp_add_trashed_suffix_to_post_name_for_trashed_posts()`
 * `wp_filter_wp_template_unique_post_slug()`
 * `wp_xmlrpc_server::add_enclosure_if_new()`
 * `wp_xmlrpc_server::attach_uploads()`
 * `wp_xmlrpc_server::mt_getTrackbackPings()`
* Internal variables in:
 * `wp_ajax_inline_save()`
 * `wp_ajax_set_post_thumbnail()`
 * `wp_ajax_get_post_thumbnail_html()`
 * `edit_post()`
 * `bulk_edit_posts()`
 * `wp_write_post()`
 * `WP_Embed::shortcode()`
 * `wp_insert_post()`
 * `wp_xmlrpc_server::_insert_post()`
 * `wp_xmlrpc_server::blogger_getPost()`
 * `wp_xmlrpc_server::blogger_newPost()`
 * `wp_xmlrpc_server::blogger_editPost()`
 * `wp_xmlrpc_server::blogger_deletePost()`
 * `wp_xmlrpc_server::mw_getPost()`
 * `wp_xmlrpc_server::mw_newPost()`
 * `wp_xmlrpc_server::mw_editPost()`
 * `wp_xmlrpc_server::mt_getPostCategories()`
 * `wp_xmlrpc_server::mt_setPostCategories()`
 * `wp_xmlrpc_server::mt_publishPost()`
 * `wp_xmlrpc_server::pingback_ping()`
* Hook parameters in:
 * `oembed_ttl`
 * `embed_oembed_html`
 * `wp_insert_post_parent`
 * `add_trashed_suffix_to_trashed_posts`
 * `pre_post_update`
 * `edit_attachment`
 * `attachment_updated`
 * `add_attachment`
 * `edit_post_{$post->post_type}`
 * `edit_post`
 * `post_updated`
 * `save_post_{$post->post_type}`
 * `save_post`
 * `wp_insert_post`
 * `pre_wp_unique_post_slug`
 * `wp_unique_post_slug`
 * `xmlrpc_call_success_blogger_newPost`
 * `xmlrpc_call_success_blogger_editPost`
 * `xmlrpc_call_success_blogger_deletePost`
 * `xmlrpc_call_success_mw_newPost`
 * `xmlrpc_call_success_mw_editPost`

Note: The name change only affects variable names and DocBlocks.

The change does not affect the `$post_ID` global still used in a few places.

Follow-up to [51399], [52958], [53723], [53729], [55190], [55308], [55334].

Props mahekkalola, tanjimtc71, SergeyBiryukov.
Fixes #57692.
Built from https://develop.svn.wordpress.org/trunk@55365


git-svn-id: http://core.svn.wordpress.org/trunk@54898 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-19 15:05:22 +00:00
spacedmonkey
63e73fb860 Taxonomy: Implement wp_cache_get_multiple in wp_queue_posts_for_term_meta_lazyload.
In [47938] the `wp_cache_get_multiple` function was added to core. This function allows for multiple cache keys to be received from cache in a single function call. `wp_queue_posts_for_term_meta_lazyload` function does many calls to cache. To get taxonomy relationship for multiple posts and get all terms. Replace calls to `get_object_term_cache` with calls to `wp_cache_get_multiple` and `_prime_term_caches`. This improves performance on sites that implement the `wp_cache_get_multiple` in their object caching drop-in. 

Props spacedmonkey, ocean90, SergeyBiryukov, costdev, flixos90, joemcgill, 10upsimon. 
Fixes #57150.
Built from https://develop.svn.wordpress.org/trunk@55252


git-svn-id: http://core.svn.wordpress.org/trunk@54785 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 12:10:18 +00:00
joedolson
4efd5d5623 Media: Pass $size argument to get_attached_file filter.
Pass the new `$size` argument on `get_attached_file()` to `get_attached_file` filter. Follow up to [55199].
 
Props SergeyBiryukov, joedolson.
Fixes #51780.
Built from https://develop.svn.wordpress.org/trunk@55217


git-svn-id: http://core.svn.wordpress.org/trunk@54750 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-03 19:25:21 +00:00
spacedmonkey
203ba0cc28 Query: Revert [55169].
Revert [55169] and mark #56689 as wontfix. `get_page_by_path` can not use `WP_Query`, as is results in fatel errors for those using `get_page_by_path` in the `pre_get_posts` action or `posts_pre_query` filter. This sadly means that `WP_Query` can never be used in `get_page_by_path`.

Props spacedmonkey, iandunn, mukesh27, joemcgill, adamsilverstein, otto42. 
See #56689.
Built from https://develop.svn.wordpress.org/trunk@55215


git-svn-id: http://core.svn.wordpress.org/trunk@54748 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-03 16:17:21 +00:00
Peter Wilson
592be344b4 Posts, Post Types: Deprecate get_page_by_title() in favour of WP_Query.
Formally deprecate `get_page_by_title()`. In its current form the function is unpredictable in that it may return a result that leads to a 404 error and will return different results depending on the database version/engine combination used.

It is recommended developers use `WP_Query` instead:

{{{
$query = new WP_Query(
 array(
  'post_type' => 'page',
  'title'     => 'Sample Page',
 )
);
}}}


Props TimothyBlynJacobs, costdev, mukesh27, spacedmonkey, peterwilsoncc.
Fixes #57041.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54740 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-03 03:58:16 +00:00
Sergey Biryukov
94ede5b18c Docs: Improve the DocBlock for get_attached_file().
Includes:
* Using 3-digit format for the `@since` tag.
* Minor wording updates and formatting corrections.

Follow-up to [3203], [4612], [6379], [8203], [24983], [29090], [55199].

See #51780, #56792.
Built from https://develop.svn.wordpress.org/trunk@55202


git-svn-id: http://core.svn.wordpress.org/trunk@54735 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-03 00:47:19 +00:00
joedolson
848a832fa0 Media: Add argument to get_attached_file() for subsizes.
Add a `$size` argument to `get_attached_file()` to simplify getting the path to an intermediate image size.
 
Props paulschreiber, audrasjb, Mista-Flo.
Fixes #51780.
Built from https://develop.svn.wordpress.org/trunk@55199


git-svn-id: http://core.svn.wordpress.org/trunk@54732 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-02 23:40:16 +00:00
spacedmonkey
449fdda55f Query: Use WP_Query in get_page_by_path.
Replace raw database queries in `get_page_by_path` with a call to `WP_Query` class. This has a number of benefits, including improved caching and priming of post caches. To maintain backwards compatibility, this function calls `WP_Query` to gets all matching posts of all post statuses.  

Props spacedmonkey, peterwilsoncc, costdev, 
Fixes #56689.
Built from https://develop.svn.wordpress.org/trunk@55169


git-svn-id: http://core.svn.wordpress.org/trunk@54702 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-31 16:56:12 +00:00
audrasjb
06010c2795 Docs: Remove unused post_modified and post_modified_gmt params from wp_insert_post() docblock.
Props dshanske, mehulkaklotar.
Fixes #57473.
See #56792.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54613 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-01-16 20:39:10 +00:00
Sergey Biryukov
835378abe1 Code Modernization: Rename parameters that use reserved keywords in phpunit/includes/class-wp-unittest-factory-for-attachment.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 `$parent` parameter to `$parent_post_id` in `WP_UnitTest_Factory_For_Attachment::create_upload_object()`.
* Amends the `$parent_post` parameter in `wp_insert_attachment()` and `WP_REST_Revisions_Controller::get_parent()` for consistency.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938], [54943], [54944], [54945], [54946], [54947], [54948], [54950], [54951], [54952], [54956], [54959], [54960], [54961], [54962], [54964], [54965], [54969], [54970], [54971], [54972], [54996], [55000], [55011], [55013], [55014], [55015], [55016], [55017], [55020].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@55021


git-svn-id: http://core.svn.wordpress.org/trunk@54554 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-30 02:38:17 +00:00
Sergey Biryukov
4ffd8b005e Code Modernization: Rename parameters that use reserved keywords in wp-includes/post.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 `$object` parameter to `$data_object` in `_get_custom_object_labels()`.
* Renames the `$parent` parameter to `$parent_post` in `wp_insert_attachment()`.

Follow-up to [52946], [52996], [52997], [52998], [53003], [53014], [53029], [53039], [53116], [53117], [53137], [53174], [53184], [53185], [53192], [53193], [53198], [53203], [53207], [53215], [53216], [53220], [53230], [53232], [53236], [53239], [53240], [53242], [53243], [53245], [53246], [53257], [53269], [53270], [53271], [53272], [53273], [53274], [53275], [53276], [53277], [53281], [53283], [53284], [53285], [53287], [53364], [53365], [54927], [54929], [54930], [54931], [54932], [54933], [54938], [54943], [54944], [54945], [54946], [54947], [54948], [54950], [54951], [54952], [54956], [54959], [54960].

Props jrf, aristath, poena, justinahinon, SergeyBiryukov.
See #56788.
Built from https://develop.svn.wordpress.org/trunk@54961


git-svn-id: http://core.svn.wordpress.org/trunk@54513 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-13 00:03:15 +00:00
audrasjb
01102b3d6e Docs: Improve various globals documentation, as per documentation standards.
Props upadalavipul.
See #57069, #56792.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54505 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-09 11:54:13 +00:00
Dominik Schilling
15d01c9235 Query: Account for primed post caches without primed post meta/term caches.
In [54352] `update_post_caches()` was replaced by `_prime_post_caches()` to reduce excessive object cache calls. That's because `_prime_post_caches()` checks first if post IDs aren't already cached. Unfortunately this becomes an issue if a post itself is cached but not the meta/terms.
To fix this regression, `_prime_post_caches()` now always calls `update_postmeta_cache()` and `update_object_term_cache()` depending on the arguments passed to it. Both functions internally check whether IDs are already cached so the fix from [54352] remains in place.

Props peterwilsoncc, spacedmonkey, ocean90.
Fixes #57163.
Built from https://develop.svn.wordpress.org/trunk@54894


git-svn-id: http://core.svn.wordpress.org/trunk@54446 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-29 20:29:11 +00:00
Sergey Biryukov
3ba44120d0 Coding Standards: Always use parentheses when instantiating an object.
Note: This will be enforced by WPCS 3.0.0.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54443 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-29 15:51:14 +00:00
Sergey Biryukov
25ea9680ae Docs: Update various DocBlocks and inline comments per the documentation standards.
Includes minor formatting edits for consistency.

Follow-up to [53/tests], [12179], [12946], [35288], [37884], [38810], [38928], [46596], [48131], [52955], [53548], [53813], [53873], [54118], [54316], [54420], [54421], [54803].

See #56792.
Built from https://develop.svn.wordpress.org/trunk@54855


git-svn-id: http://core.svn.wordpress.org/trunk@54407 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-17 18:15:19 +00:00
Sergey Biryukov
260276583c Docs: Update wp_count_posts and wp_count_attachments filter descriptions.
This aims to match the wording generally used for other filters as per the documentation standards.

Follow-up to [25554], [25578], [25579], [53456].

See #56792.
Built from https://develop.svn.wordpress.org/trunk@54854


git-svn-id: http://core.svn.wordpress.org/trunk@54406 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-17 17:07:15 +00:00
Peter Wilson
0f7fcc2863 Posts, Post Types: Revert get_page_by_title()'s use of WP_Query.
Revert to legacy database query in `get_pages_by_title()`. Due to the lack of `orderby` clause in the previous database query, it is not possible to gain consistent results by converting the function to a `WP_Query` wrapper.

Reverts [54271, 54242, 54234].

Props Bjorn2404, 10upsimon, dilipbheda, mukesh27, spacedmonkey, TimothyBlynJacobs, rjasdfiii, stentibbing, pbiron, pento.
Fixes #57039, #56991.
See #57041.


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


git-svn-id: http://core.svn.wordpress.org/trunk@54334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-10 00:46:16 +00:00
Peter Wilson
113838ed78 Query: Prevent ID only queries erroring when starting the loop.
Ensure only full post objects are passed to `update_post_author_caches()` when called within `WP_Query::the_post()`. This prevents an error when starting the Loop for Queries initiated with a subset of fields or IDs only.

Props konyoldeath, dd32, lozula, TimothyBlynJacobs, spacedmonkey, mxbclang, peterwilsoncc.
Fixes #56948.


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


git-svn-id: http://core.svn.wordpress.org/trunk@54323 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-09 00:59:12 +00:00
antpb
1d4fa825b8 Media: Reverts get_attached_file() changes for normalized Windows paths.
Based on feedback from network storage configurations there was a noticed slowdown due to the usage of the `path_join()` function. This needs more time to find a workaround.

Follow-up to [53934].
Props mreishus, SergeyBiryukov, desrosj, mikeschroder.
Reverts [53934].
See #56924.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54264 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-10-28 15:18:11 +00:00
audrasjb
b7f48d4cb4 Media: Refactor search by filename within the admin.
Props vortfu, xknown, peterwilsoncc, paulkevan.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54079 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-10-17 11:19:11 +00:00
Peter Wilson
336517fab3 Posts, Post types: Prevent get_page_by_title() parsing query twice.
In `get_page_by_title()` access the populated `WP_Query::posts` property directly rather than via the `WP_Query::get_posts()` method. This removes unnecessary reprocessing of the query.

Follow up to [54234].

Props david.binda, mukesh27, spacedmonkey.
Fixes #56721.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53936 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-10-04 03:33:10 +00:00
Sergey Biryukov
6746d64fd4 Code Modernization: Fix null to non-nullable deprecations in wp_xmlrpc_server::mw_newPost().
The `wp_xmlrpc_server::mw_newPost()` method creates a new post via `wp_insert_post()`, but the default/fallback values used in the function were not in line with the default/fallback values used in the `wp_insert_post()` function.

The `wp_insert_post()` function does a `wp_parse_args()` (array merge) of the received arguments with the defaults. If any of the received arguments are `null`, this would overwrite the default value, as seen in [https://3v4l.org/bfVlv array_merge() example], and lead to "passing null to non-nullable" deprecation notices on PHP 8.1 for certain arguments.

This commit:
* Ensures that all arguments are defined before they are `compact()`'ed together to the arguments array.
* Verifies that the default/fallback value of the arguments as set within the `wp_xmlrpc_server::mw_newPost()` method are the same as the default/fallback values used in the `wp_insert_post()` function.
* Verifies that arguments which do not have a default/fallback value defined in the `wp_insert_post()` function are handled correctly.
 * This was not the case for `$post_name`, which would previously already get an empty string default value in the `wp_xmlrpc_server::mw_newPost()` function, but then in the `wp_insert_post()` function, this would prevent the slug generation from being activated. Fixed now by setting the default in the `wp_xmlrpc_server::mw_newPost()` function to `null`.
 * The `page_template` argument was handled, but not documented in the `wp_insert_post()` function. The argument is now documented in the `wp_insert_post()` function DocBlock. Note: There are more than likely several other potential arguments missing from that list, but verifying the whole list is outside the scope of this particular commit.

Includes minor simplifications, such as:
* Setting a default ahead of an `if`, instead of in an `else` clause (as long as no function call is needed to set the default).
* Removing the unnecessary logic duplication in the `$post_status` switch.
* Using a combined concatenation + assignment operator for adding `$post_more`.

Fixes various errors along the lines of:
{{{
1) Tests_XMLRPC_mw_editPost::test_draft_not_prematurely_published
strpos(): Passing null to parameter #1 ($haystack) of type string is deprecated

/var/www/src/wp-includes/formatting.php:2497
/var/www/src/wp-includes/class-wp-hook.php:308
/var/www/src/wp-includes/plugin.php:205
/var/www/src/wp-includes/post.php:2835
/var/www/src/wp-includes/post.php:2720
/var/www/src/wp-includes/post.php:4066
/var/www/src/wp-includes/class-wp-xmlrpc-server.php:5616
/var/www/tests/phpunit/tests/xmlrpc/mw/editPost.php:315

...

23) Tests_XMLRPC_mw_editPost::test_draft_not_prematurely_published
json_decode(): Passing null to parameter #1 ($json) of type string is deprecated

/var/www/src/wp-includes/kses.php:2074
/var/www/src/wp-includes/class-wp-hook.php:307
/var/www/src/wp-includes/plugin.php:205
/var/www/src/wp-includes/post.php:2835
/var/www/src/wp-includes/post.php:2720
/var/www/src/wp-includes/post.php:4066
/var/www/src/wp-includes/class-wp-xmlrpc-server.php:5615
/var/www/tests/phpunit/tests/xmlrpc/mw/editPost.php:315
/var/www/vendor/bin/phpunit:123
}}}

Follow-up to [1563], [4793], [7900], [16824], [19848], [40677], [51968].

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


git-svn-id: http://core.svn.wordpress.org/trunk@53879 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-27 02:00:09 +00:00
John Blackbourn
f7dc68f99a Docs: Updates and corrections to various inline docs added in 6.1.
See #55646

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


git-svn-id: http://core.svn.wordpress.org/trunk@53843 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-21 20:24:12 +00:00
Peter Wilson
2d21751903 Posts, Post Types: Fix WP_Query parameter used by get_page_by_title().
Fixes the call to `WP_Query` within `get_page_by_title()` by using the correct title parameter, `title`.

Modify the `orderby` parameter to prioritize the oldest published date over the smallest post ID. This ensures the behaviour matches that of the previous version of `get_page_by_title()`.

The tests have been modified to include a populated post table to ensure the posts returned are matched by design rather than coincidence.

Follow up to [54234].

Props dd32, timothyblynjacobs, peterwilsoncc.
Fixes #56609.
See #36905.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53830 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-21 05:29:09 +00:00
John Blackbourn
c117e5ae74 Docs: Various improvements and corrections to inline docs.
See #55646

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


git-svn-id: http://core.svn.wordpress.org/trunk@53826 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-20 20:32:09 +00:00
audrasjb
5dcad0a618 Media: Add caching to wp_count_attachments().
This changeset adds caching to `wp_count_attachments()`, for better consistency with `wp_count_posts()`.

Props jeherve, antpb, mukesh27, robinwpdeveloper, costdev.
Fixes #55227.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53814 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-20 14:22:09 +00:00
Peter Wilson
4f748ac3fa Posts, Post types: Cache get_page_by_title().
Convert `get_page_by_title()` to a `WP_Query` wrapper to take advantage of the object caching built in to the latter.

Add dedicated unit tests for the function `get_page_by_title()`.

Props spacedmonkey, boonebgorges, igmoweb, pcfreak30, pbearne.
Fixes #36905.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53793 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-20 01:15:11 +00:00
Pascal Birchler
7973933ad6 Date/Time: Cast extracted strings to integers in wp_resolve_post_date().
`wp_resolve_post_date()` extracts year/month/day from a post date (which is a string) and passes it to `wp_checkdate` (and from there to `checkdate()`), which requires `int`s.

Casting the strings to integers avoids PHP notices due to incorrect argument types.

Props hilayt24.
Fixes #54186
Built from https://develop.svn.wordpress.org/trunk@54126


git-svn-id: http://core.svn.wordpress.org/trunk@53685 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-11 21:59:09 +00:00
Adam Silverstein
4b5968aa9b Media: revert the multi-mime feature.
This feature isn't quite ready to land.

Reverts r53786, r53848, r53847, r53845, r53751.

Props flixos90, azaozz, dd32.
See #55443.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53644 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-06 21:13:12 +00:00
Peter Wilson
ba9dd1d7d7 Cache API, Docs: Remove private delegation from cache priming functions.
Remove the private delegation from the following cache priming functions for various object types:

- `_prime_post_caches()`
- `_prime_term_caches()`
- `_prime_comment_caches()`
- `_prime_network_caches()`
- `_prime_site_caches()`
- `_get_non_cached_ids() `

Plugins and themes are now encouraged to use these functions to improve the performance of their code by reducing the number of database queries.

Props robinwpdeveloper, desrosj, SergeyBiryukov, mukesh27, costdev.
Fixes #56386.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53503 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-26 01:03:14 +00:00
antpb
0406a3ffd7 Media: Account for Windows when normalizing file paths.
Previously, Windows paths in the `path_is_absolute` function resulted in incorrect URIs. This patch adjusts for forward slashes and adds tests for the `get_attached_file` function.
Props Whissi, SergeyBiryukov, desrosj, stevenlinx, birgire, davidbaumwald, costdev, peterwilsoncc, audrasjb, hellofromTonya, johnbillion.
Fixes #36308.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53493 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-23 19:59:14 +00:00
John Blackbourn
20edeb6e09 Posts, Post Types: Prevent categories from being overwritten when updating a post using wp_insert_post().
This prevents existing category relationships being overridden with the default category when none is provided in the post data.

Props markoheijnen, leewillis77, desrosj

Fixes #19954

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


git-svn-id: http://core.svn.wordpress.org/trunk@53442 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 20:00:10 +00:00
John Blackbourn
77bf28a1b7 Docs: Miscellaneous inline documentation improvements.
See #55646

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


git-svn-id: http://core.svn.wordpress.org/trunk@53437 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 14:11:08 +00:00
John Blackbourn
1d4e72c798 Docs: Correct and improve the documented types for various functions and hooks.
See #55646

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


git-svn-id: http://core.svn.wordpress.org/trunk@53436 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-11 14:03:09 +00:00
audrasjb
301ac6bf38 Docs: Provide a more accurate @return type for get_pages() function.
Props malthert, audrasjb, johnbillion, jigar-bhanushali.
Fixes #56330.
See #55646.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53396 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-05 05:46:10 +00:00
desrosj
0d62f02303 Posts, Post Types: Change variable name in wp_set_post_terms() for clarity.
This changes the `$tags` variable used within `wp_set_post_terms()` to `$terms`.

While the default for the `$taxonomy` argument is `post_tag`, the function can be used to assign terms to a post for any taxonomy. When a different taxonomy is passed, `$tags` is an inaccurate name and could be confusing.

Props hilayt24, costdev, SergeyBiryukov, krishaweb, desrosj.
Fixes #56331.
Built from https://develop.svn.wordpress.org/trunk@53825


git-svn-id: http://core.svn.wordpress.org/trunk@53384 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 14:09:23 +00:00
Sergey Biryukov
ae807463ac Posts, Post Types: Check if the post type exists in wp_insert_post().
This avoids an `Attempt to read property "cap" on null` PHP warning when checking an unregistered post type's `publish_posts` capability to disallow contributors setting the post slug for pending posts.

Follow-up to [9055], [42380].

Props Chouby, mukesh27, rafiahmedd, SergeyBiryukov.
Fixes #55877.
Built from https://develop.svn.wordpress.org/trunk@53771


git-svn-id: http://core.svn.wordpress.org/trunk@53330 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-24 13:26:12 +00:00
Adam Silverstein
71ca314193 Media: enable generating multiple mime types for image uploads; specifically WebP versions for JPEG images by default.
This changeset adds the capability for core media uploads to generate sub sized images in more than a single mime type. The output formats for each mime type can be controlled through a filter. WebP is used as an additional output format for JPEG images by default to improve front end performance.

When generating additional mime types, only images which are smaller than the respective original are retained. By default, additional mime type images are only generated for the built-in core image sizes and any custom sizes that have opted in.

Image meta is updated with a new 'sources' array containing file details for each mime type. Each image size in the 'sizes' array also gets a new 'sources' array that contains the image file details for each mime type.

This change also increases image upload retries to accommodate additional image sizes. It also adds a `$mime_type` parameter to the `wp_get_missing_image_subsizes` function and filter.

This change adds three new filters to enable full control of secondary mime image generation and output:

* A new filter `wp_image_sizes_with_additional_mime_type_support` that filters the sizes that support secondary mime type output. Developers can use this to control the output of additional mime type sub-sized images on a per size basis.
* A new filter `wp_upload_image_mime_transforms` that filters the output mime types for a given input mime type. Developers can use this to control generation of additional mime types for a given input mime type or even override the original mime type.
* A new filter `wp_content_image_mimes` which controls image mime type output selection and order for frontend content. Developers can use this to control the mime type output preference order for content images. Content images inserted from the media library will use the available image versions based on the order from this filter.

Thanks to the many contributors who helped develop, test and give feedback on this feature.

A haiku to summarize:

Upload a JPEG
Images of all sizes
Output as WebPs

Props flixos90, MatthiasReinholz, studiolxv, markhowellsmead, eatingrules, pbiron, mukesh27, joegrainger, mehulkaklotar, tweetythierry, akshitsethi, peterwilsoncc, eugenemanuilov, mitogh, shetheliving, clarkeemily, codekraft, mikeschroder, clorith, kasparsd, spacedmonkey, trevorpfromsandee, jb510, scofennellgmailcom, seedsca, cagsmith, karinclimber, dainemawer, baxbridge, grapplerulrich, sobatkras, chynnabenton, tonylocalword, barneydavey, kwillmorth, garymatthews919, olliejones, imarkinteractive, jeffpaul, feastdesignco, webbeetle, masteradhoc.

See #55443.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53310 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-21 18:03:13 +00:00
Sergey Biryukov
69a8ecce33 Coding Standards: Rename $comment_post_ID and $comment_author_IP variables in various files.
This fixes two WPCS warnings:
* `Variable "$comment_post_ID" is not in valid snake_case format`
* `Variable "$comment_author_IP" is not in valid snake_case format`

While matching the database fields of the same name, these variables did not follow the WordPress coding standards, and are now renamed to address that.

Note: The name change only affects internal variables and parameters for a few actions receiving a comment post ID:

* `edit_comment`
* `comment_id_not_found`
* `comment_closed`
* `comment_on_trash`
* `comment_on_draft`
* `comment_on_password_protected`
* `pre_comment_on_post`

The change does not affect parameters for functions receiving an array of comment data:

* `wp_insert_comment()`
* `wp_new_comment()`
* `wp_update_comment()`
* `wp_handle_comment_submission()`

The associated array keys still match the database fields: `comment_post_ID` and `comment_author_IP`.

Follow-up to [1706], [2894], [8720], [28427], [28437], [28457], [34799], [53720],

See #55647, #56244.
Built from https://develop.svn.wordpress.org/trunk@53723


git-svn-id: http://core.svn.wordpress.org/trunk@53282 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-19 16:19:11 +00:00
Sergey Biryukov
1069ac4afd Posts, Post Types: Standardize on $post parameter name where appropriate.
This renames the `$post_id` or `$id` parameters to `$post` for functions that accept a post ID or post object:

* `get_sample_permalink()`
* `get_sample_permalink_html()`
* `wp_check_post_lock()`
* `wp_set_post_lock()`
* `get_the_tags()`
* `comment_class()`
* `get_comment_class()`
* `get_comments_link()`
* `get_comments_number()`
* `comments_number()`
* `get_comments_number_text()`
* `comments_open()`
* `pings_open()`
* `comment_form()`
* `do_trackbacks()`
* `pingback()`
* `post_permalink()`
* `get_post_permalink()`
* `get_edit_post_link()`
* `edit_post_link()`
* `get_delete_post_link()`
* `post_class()`
* `get_post_class()`
* `the_attachment_link()`
* `wp_get_attachment_link()`
* `wp_list_post_revisions()`
* `check_and_publish_future_post()`
* `add_ping()`
* `get_pung()`
* `get_to_ping()`
* `wp_get_post_revisions()`
* `wp_get_post_revisions_url()`

Additionally, `$revision_id` is renamed to `$revision` in:

* `wp_restore_post_revision()`
* `wp_delete_post_revision()`

Includes minor documentation improvements for consistency and code layout fixes for better readability.

Follow-up to [1599], [1794], [2881], [3303], [3851], [5302], [6633], [6716], [6985], [7103], [7149], [7747], [8011], [8638], [8643], [8695], [9138], [9273], [11425], [11922], [11956], [12284], [12810], [12923], [13023], [13171], [25567], [27156], [27473], [28558], [28602], [33659], [38852], [47276], [47366], [48622], [49544], [49597], [52095].

See #56243, #55647.
Built from https://develop.svn.wordpress.org/trunk@53715


git-svn-id: http://core.svn.wordpress.org/trunk@53274 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-18 17:37:17 +00:00
Andrew Ozz
8091de83b5 Media:
- Deprecate `wp_get_attachment_thumb_file()`.
- Make `wp_get_attachment_thumb_url()` an alias of `wp_get_attachment_image_url()`. This fixes it to return the proper thumbnail URL and fall back to returning the URL to `image_meta['thumb']` if only that exists.

Props: markhowellsmead, mukesh27, csesumonpro, SergeyBiryukov, mikeschroder, killua99, joemcgill, mashukushibiki, mfgmicha, swissspidy, romulodl, nacin, JoshuaAbenazer, wonderboymusic, lonnylot, azaozz.
Built from https://develop.svn.wordpress.org/trunk@53685


git-svn-id: http://core.svn.wordpress.org/trunk@53244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-07 23:32:11 +00:00
Aaron Jorbin
a457e3498e Editor: Universalize functions for checking block editor status.
`use_block_editor_for_post_type` and `use_block_editor_for_post` can be very useful in more contexts than wp-admin, especially when a site is in transition. For example, you may want to do things on init that are different.

Neither function depends on other functions that are available only in wp-admin (other than use_block_editor_for_post() relying on use_block_editor_for_post_type() and an admin-referrer check that's historically gated by a query variable and now also gated by is_admin), therefore  moving them to wp-includes seems both feasible and beneficial

Props ethitter, jorbin.
Fixes #51819.


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


git-svn-id: http://core.svn.wordpress.org/trunk@53148 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-06-23 18:48:13 +00:00
Sergey Biryukov
b8290da037 Docs: Improve documentation for WP_Image_Editor::save() and related functions.
Includes:
* Documenting the returned array using hash notation.
* Adding a `@since` note for the `$filesize` value being included in the returned array.

This affects:
 * `wp_generate_attachment_metadata()`
 * `wp_get_attachment_metadata()`
 * `WP_Image_Editor::save()`
 * `WP_Image_Editor_GD::save()` and `::_save()`
 * `WP_Image_Editor_Imagick::save()` and `::_save()`

Follow-up to [22094], [22619], [52837], [53546].

See #55646.
Built from https://develop.svn.wordpress.org/trunk@53547


git-svn-id: http://core.svn.wordpress.org/trunk@53136 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-06-21 11:18:17 +00:00
John Blackbourn
721877d3d2 I18N: Correct and improve inline docs and tests for functionality related to nooped plurals.
See #55646, #55652

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


git-svn-id: http://core.svn.wordpress.org/trunk@53132 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-06-20 22:57:16 +00:00
Sergey Biryukov
84a8194200 REST API: Some documentation and test improvements for update_post_parent_caches():
* Make the function description more specific, for consistency with `update_post_author_caches()`.
* Add missing `@covers` tags for the unit test.

Follow-up to [53506].

See #55593.
Built from https://develop.svn.wordpress.org/trunk@53507


git-svn-id: http://core.svn.wordpress.org/trunk@53096 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-06-15 13:19:10 +00:00
spacedmonkey
2c8a6170af REST API: Prime caches for post parents in post REST API controller.
Prime caches for all post parents in the post REST API controller using the `_prime_post_caches` function. Post parent objects are required as part of the `check_read_permission` method’s permission check in post REST API controller. 

Props spacedmonkey, furi3r, peterwilsoncc, mitogh, madpixels. 
Fixes #55593.
Built from https://develop.svn.wordpress.org/trunk@53506


git-svn-id: http://core.svn.wordpress.org/trunk@53095 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-06-15 10:43:10 +00:00
Sergey Biryukov
a29c6663fd Docs: Use typed array notation in some post function DocBlocks:
* `wp_queue_posts_for_term_meta_lazyload()`
* `_prime_post_caches()`

See #55646.
Built from https://develop.svn.wordpress.org/trunk@53484


git-svn-id: http://core.svn.wordpress.org/trunk@53073 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-06-10 15:22:11 +00:00
Sergey Biryukov
9e01bd8adc Query: Some documentation and test improvements for update_post_author_caches():
* Make the descriptions for `update_post_author_caches()` and `update_post_caches()` more specific.
* Move the unit test into its own file, for consistency with `update_post_cache()` tests. This also allows for using shared fixtures in case more tests are added in the future.

Follow-up to [53482].

See #55716.
Built from https://develop.svn.wordpress.org/trunk@53483


git-svn-id: http://core.svn.wordpress.org/trunk@53072 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-06-10 15:17:10 +00:00
spacedmonkey
2237f67458 Prime users cache in WP_Query and post REST API controller.
For a call to `WP_Query` or a post REST API request that contains posts from multiple authors, call the `cache_users` function, to ensure that all user data for post authors is primed in 
a single database query. This results in far fewer database queries on multiple author sites. 

Props spacedmonkey, timothyblynjacobs, peterwilsoncc.
Fixes #55716.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53071 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-06-10 13:39:11 +00:00
audrasjb
a6539b8cfb Docs: Use third-person singular verbs for method descriptions in wp-includes/post.php, as per docs standards.
Props whaze.
See #55646.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53045 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-06-02 10:55:11 +00:00
Sergey Biryukov
f2a7f4a387 I18N: Use consistent context for the "Add New" string when referring to media.
This replaces the only instance of the `add new media` context with `file`, used in other instances of the string.

Follow-up to [9198], [10680], [21948].

Props benjgrolleau, tobifjellner, SergeyBiryukov.
Fixes #55876.
Built from https://develop.svn.wordpress.org/trunk@53453


git-svn-id: http://core.svn.wordpress.org/trunk@53042 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-05-31 18:39:10 +00:00
John Blackbourn
0d46464f83 Docs: Various docblock corrections.
See #54729

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


git-svn-id: http://core.svn.wordpress.org/trunk@52889 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-28 09:49:16 +00:00
Peter Wilson
7082f4dc84 Posts, Post Types: Fix option validation in stick_post().
Normalize an invalid `sticky_posts` option to an empty array within `stick_post()`. This fixes a bug in which an unexpected option value would prevent new posts from being made sticky.

Follow up to [50380].

Props azouamauriac, denishua, kajalgohel, sergeybiryukov, costdev.
Fixes #55176.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52827 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-21 06:04:15 +00:00
Peter Wilson
74dcee85d0 Docs: Improve doc blocks for hooks added in [53126].
Fix a variable name and provide examples of the hook names.

Follow up to [53126].

Props dlh, pbiron.
Fixes #53212.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52759 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-13 03:04:10 +00:00
Peter Wilson
a009192299 Posts, Post Types/Taxonomies: Add object type specific registration filters.
Add post type and taxonomy specific registration argument hooks. 

Introduces the filters `register_{$post_type}_post_type_args` and `register_{$taxonomy}_taxonomy_args`. Introduces the actions `registered_post_type_{$post_type}` and `registered_taxonomy_{$taxonomy}`.

Props pbiron, dlh, davidbaumwald, hellofromTonya, milana_cap.
Fixes #53212.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52715 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-11 05:11:02 +00:00
Sergey Biryukov
9fb5112732 Docs: Add missing description for $pagenow global in various functions.
See #54729, #55499.
Built from https://develop.svn.wordpress.org/trunk@53060


git-svn-id: http://core.svn.wordpress.org/trunk@52649 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-04 18:26:06 +00:00
Peter Wilson
b8b35c78b7 Posts, Post Types; Taxonomy: Translate default labels once.
Improve the translation of post type and taxonomy labels by caching the translations during runtime. To account for internationalisation plugins, the runtime cache is cleared as the post types/taxonomies are reinitiated on `change_local` hook.

The same property and methods are added to both `WP_Post_Type` and `WP_Taxonomy`:

* `$default_labels`: for storing the translated strings at runtime
* `get_default_labels()`: for getting the default labels, these are translated on the first run and stored in the new property.
* `reset_default_labels()`: to clear the runtime cache and force a re-translation of the default labels

Props Chouby, nacin, SergeyBiryukov, Rarst, chriscct7, ocean90, audrasjb, costdev.
Fixes #26746.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52647 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-04 03:50:07 +00:00
Peter Wilson
dc07d3ca67 Posts, Post Types: Set post filter in update_post_cache().
Ensure the post cache is primed with raw sanitized data. This resolves an inconsistency between how posts retrieved via `get_post()` vs `WP_Query` are cached.

This prevents `sanitize_post( $post, 'raw' )` being run multiple times on a cached post. This can happen over 20 times per post on some page loads so avoiding this will provide a noticeable performance boost.

Props Cybr, SergeyBiryukov, peterwilsoncc, hellofromTonya, costdev.
Fixes #50567.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52631 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-04-01 03:18:05 +00:00
audrasjb
223cda987f Administration: Replace contracted verb forms for better consistency.
This changeset replaces contracted verb forms like `doesn't`, `can't`, or `isn't` with non-contracted forms like `does not`, `cannot`, or `is not`, for better consistency across the WordPress administration. It also updates some corresponding unit tests strings.

Props Presskopp, socalchristina, aandrewdixon, francina, SergeyBiryukov, JeffPaul, audrasjb, hellofromTonya.
Fixes #38913.
See #39176.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52567 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-22 16:25:03 +00:00
spacedmonkey
bbf017e550 Media: Store attachment’s file size in metadata.
Store the file size of all newly uploaded attachments, as part of the metadata stored in post meta. Storing file size means, developers will not have to resort to doing `filesize` function calls, that can be time consuming on assets on offloaded to services like Amazon’s S3. 

This change also introduces a new helper function called, `wp_filesize`. This is a wrapper around the `filesize` php function, that adds some helpful filters and ensures the return value is an integer.

Props Cybr, Spacedmonkey, SergeyBiryukov, johnwatkins0, swissspidy, desrosj, joemcgill, azaozz, antpb, adamsilverstein, uday17035. 
Fixes #49412. 


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


git-svn-id: http://core.svn.wordpress.org/trunk@52426 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-10 13:10:02 +00:00
audrasjb
631f08096b Docs: Correct return type for get_post_custom().
Props chouby, audrasjb.
Fixes #55249.
See #54729.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52384 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-24 21:26:02 +00:00
hellofromTonya
9ac43b6ade Editor: Grant only admins access to the "Navigation Menus" UI for block and non-block themes.
Restricts and grants access to only admin roles for the Navigation Menu UI screen, i.e. either directly through the URL wp-admin/edit.php?post_type=wp_navigation or via the Navigation block's "Manage menu" option (in the block's toolbar).

It resolves 2 issues:

- For non-block themes, fixes the issue where admins could not access the UI.
- For block themes, restricts access to only admin roles, i.e. non-admins no longer have access to the UI.

Non-admins will receive the "Sorry, you are not allowed to edit posts in this post type" error message.

Follow-up [52069], [52145], [52330], [52400].

Props ironprogrammer, costdev, noisysocks, talldanwp, hellofromTonya, manfcarlo, pyrobd.
Fixes #54889.
Built from https://develop.svn.wordpress.org/trunk@52755


git-svn-id: http://core.svn.wordpress.org/trunk@52344 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-17 15:11:01 +00:00
spacedmonkey
a4026420cc Cache: Use wp_cache_*_multiple() in core functions.
Implement the `wp_cache_add_multiple`, `wp_cache_set_multiple` and `wp_cache_delete_multiple` in a number of core functions after they were introduced in [52700]

Props: spacedmonkey, adamsilverstein, flixos90, mitogh.
Fixes: #55029.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52296 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-11 18:51:59 +00:00
Sergey Biryukov
7d9b54b131 Posts, Post Types: Pass the $update parameter to wp_insert_post_data and wp_insert_attachment_data filters.
This makes it easier to determine in a callback function whether this is an existing post being updated or not.

Follow-up to [8635], [8702], [27130], [27138], [28106], [28788], [47633].

Props nhadsall, mukesh27.
Fixes #46228.
Built from https://develop.svn.wordpress.org/trunk@52691


git-svn-id: http://core.svn.wordpress.org/trunk@52280 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-08 12:24:02 +00:00
Sergey Biryukov
84f61343d4 Docs: Fix typo in the is_post_status_viewable() function description.
Follow-up to [50130].

Props rafiahmedd.
Fixes #55068.
Built from https://develop.svn.wordpress.org/trunk@52670


git-svn-id: http://core.svn.wordpress.org/trunk@52259 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-03 21:25:02 +00:00
audrasjb
ca9b189085 Editor: Remove standard post type UI for templates and template parts.
In [52158] the standard post type UI was added back for templates and template parts, because these features had been temporarily removed from the site editor in the rush to get 5.9 ready for December. Since 5.9 these features were properly added back to the site editor, the `show_ui` values for these post types should be returned back to `false`.

Follow-up to [52158].

Props manfcarlo, audrasjb.
Fixes #54908.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52257 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-03 09:03:04 +00:00
davidbaumwald
a5c45366cb Options, Meta APIs: Correct some inline docs for update_post_meta and delete_post_meta.
In `update_post_meta` and `delete_post_meta`, code was added to fetch the parent post if these functions were called for a revision post ID.  In [9252], the code was apparently copied from `add_post_meta`, and the inline comment describing the new block of code was not updated to mention either "updated" or "deleted" respectively.  This change corrects the comment in both functions to reflect the current action instead of "added".

Props thelovekesh, rehanali.
Fixes #54835.
Built from https://develop.svn.wordpress.org/trunk@52660


git-svn-id: http://core.svn.wordpress.org/trunk@52249 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-01 17:12:03 +00:00
desrosj
77a972838c Formatting: Correctly encode ASCII characters in post slugs.
Props zieladam, whyisjake, xknown, peterwilsoncc, desrosj, iandunn.
Built from https://develop.svn.wordpress.org/trunk@52457


git-svn-id: http://core.svn.wordpress.org/trunk@52049 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-01-06 17:10:00 +00:00
hellofromTonya
770e631dfc Editor: Add 'edit_theme_options' capabilities to wp_navigation post type.
Adds `'edit_theme_options'` capabilities top restrict Navigation permission.

Partial backport from Gutenberg https://github.com/WordPress/gutenberg/pull/37454.

Follow-up to [52069], [52145].

Props spacedmonkey, get_dave, hellofromTonya.
See #54487.
Built from https://develop.svn.wordpress.org/trunk@52400


git-svn-id: http://core.svn.wordpress.org/trunk@51992 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-21 04:26:00 +00:00
audrasjb
1309e62457 Posts, Post Types: Add missing translation context on FSE related post types labels.
This makes it easier for translators to identify the context of each label. This change also brings consistency with other built-in post types.

Follow-up to [52145], [52069], [52062], [52041], [51003].

Props audrasjb, hellofromTonya.
Fixes #54611.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51960 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-14 09:09:01 +00:00
noisysocks
935058d178 Update @wordpress packages
Update packages to include these bug fixes from Gutenberg:

- Image block: Set image display to grid when no alignment sent to properly align caption on resize
- Update and align template descriptions
- Site Editor - prevent loading state from showing the admin menu.
- Add client side routing for Site Editor
- Navigation: Add clearance for appender in submenus.
- Fix CSS Custom Properties for presets in the site editor
- Add/navigation blocks post processing after migration from menu items
- Allow selector ordering to ensure theme.json root selector margin takes precedence 
- Do not remove theme presets if defaults are hidden
- Format library: fix unsetting highlight color
- FSE: Fix template resolution to give precedence to child theme PHP templates over parent theme block templates with equal specificity
- ColorPalette: Improving accessibility and visibility
- Update: Make the color popover on the gradient picker appear as expected
- Site Editor: Display a notice if export fails
- Fix docs and function naming for gallery block registration in PHP
- Switch to addEventListener for load event in the navigation block view script
- Fix mistake in _remove_theme_attribute_in_block_template_content
- Better synchronisation between Gutenberg and Core code
- Move the block page templates hook into compat/5.9 folder
- Moves to the template loader hooks and functions into lib/compat folder
- Refactor the gutenberg_is_fse_theme function to use wp_is_block_theme
- Site Editor: Update support doc URL in Welcome Guide
- Global Styles: Add Welcome Guide toggle
- Hide remove control point when removing would break gradient control
- Don't request the deprecated navigation areas endpoint outside of the Gutenberg plugin
- Image: Fix resizer controls being hidden in Safari when switching between alignments
- Remove Navigation Menus from WP Admin sidebar
- Site Editor: Hide the block appender in the Template Part editor
- Site Editor: Use server definition for the Template Areas
- Synchronize wp_is_block_theme and block-templates block support with Core
- E2E: Retry login again after a bad nonce request to prevent intermittent test failures 
- Fix theme requirement validation with WP 5.8
- Fix WP 5.9 check for conditionally running code
- Fix post comment form input width
- Border Style Control: Update styling for consistency with border width control
- Fix form-submit styles by adding button classes to the submit-button in post-comments block
- Site Editor: Fix edit template part link in header dropdown
- Move duotone palette to the bottom of global styles gradients
- Fix how appearanceTools works
- Move WP 5.9 wp-admin menus compatibility code to lib/compat folder
- Revert "Site Editor: Set the <title> on the list page to be same as the CPT name"
- Site Editor: Document Actions: add SR text to heading 1
- Do not register global styles CPT in WordPress 5.9
- Global Styles: Move the 'Edit colors' button to a standard menu item
- Fix styles for previews and patterns
- Site Editor: Fix failing E2E test
- Templates: Search for old template names in the parent theme too
- Remove 4 instances of 'gutenberg' text domain from WordPress core
- Fix content loss when ungrouping template parts or reusable blocks
- Simplify the RESET_BLOCK action to fix template part focus mode content loss
- [Global Styles]: Make Blocks section more distinguishable
- Only use block markup for comment form button when using a block theme
- Navigation: Fix vertical alignment of page list in modal.
- Fix: ToggleGroupControl active state
- Remove gutenberg_ prefix from @wordpress/block-library

Props ocean90, oandregal, hellofromtonya, youknowriad.
See #54487.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51956 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-14 01:57:26 +00:00
hellofromTonya
f70fb51f99 Themes: Better names for WP_Theme::is_block_theme() and wp_is_block_theme() and make wp_is_block_theme() a wrapper.
This commit renames the following method and function to better represent block theme terminology:

* `WP_Theme::is_block_based()` to `WP_Theme::is_block_theme()`
* `wp_is_block_template_theme()` to `wp_is_block_theme()`

It also changes `wp_is_block_theme()` to be a helper wrapper (sugar syntax) for `wp_get_theme()->is_block_theme();`. Why? To ensure both the method and function behave the same, to help Gutenberg maintain WordPress cross-version compatibility, and to make it less cumbersome to port changes from Gutenberg to Core.

Follow-up to [52069], [52247], [52279].

Props antonvlasenko, costdev, hellofromTonya, noisysocks.
Fixes #54550.
Built from https://develop.svn.wordpress.org/trunk@52330


git-svn-id: http://core.svn.wordpress.org/trunk@51922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-07 00:02:02 +00:00
noisysocks
e4b553a201 Update @wordpress packages
Update packages to include these bug fixes from Gutenberg:

- Update Pattern block category and add documentation
- Fix non existent menu handling in nav block
- Make Reusable blocks available in the Site Editor
- Add caching to WP_Theme_JSON_Resolver_Gutenberg::get_user_data_from_custom_post_type()
- theme.json: add appearanceTools flag to opt-in into appearance UI controls
- Update the block theme folders to templates and parts
- Remove reference to gutenberg_, swap with wp_
- Use table layout in templates list screen
- Update featured image placeholder graphic.
- [Inserter]: Adjust order of theme blocks and reorder inserter items
- Implement suitable fallback for Nav block on front end of site when no menu selected
- Toggle Group Control: add tooltip
- Use first non-empty Nav post as primary fallback for Nav block
- Change .nvmrc and documentation for Node.js version (LTS to 14.18.1)
- Update: Migrate global styles user database data on the rest endpoint
- Update global styles public API
- Update: Rename user preset origin to custom
- Try always generating navigation post title
- Show all templates and template parts on the site editor list screens
- Highlight "Site" in the navigation panel
- Fix template part slug generation when creating through the block placeholder
- [Block Library - Post Title]: Fix render error when setting Page to homepage
- Add 'Clear customizations' button to template list page
- Gallery v1: Allow clicks within replace media placeholder state
- Site Editor: Set the <title> on the list page to be same as the CPT name
- Gallery: Fix stuck image size options loader
- Cover: Fix undo trap
- Add success and error snackbars to the templates list page
- Fix: theme colors cannot override defaults
- Fix: Color palette is not being stored
- Add elements support to the typography panel in global styles
- Make links plural in global styles
- Add: Gradient palette editor
- Update some small style regressions in the template list
- Add: Transparency support on global styles colors
- Fix: apply by slug on all origins
- Render empty Nav block if no fallback block can be utilised
- Allow filtering of Nav block fallback
- Fix Nav block fallback DB query to match on full block grammar start tag
- Remove unstable max pages attribute from Nav block
- DateTimePicker: set PM hours correctly
- Update delete template button
- Site Editor: Template list add rename action
- Fix Nav block editing wrong entity on creation of new Menu
- [REST] Restore the missing double slash in the ID received by /templates
- Add icons to navigation sidebar items
- Update function names for the public global styles API functions
- Templates Controller: Add missing 'is_custom' prop
- Rename gutenberg_ to wp_ for some functions that land in WordPress 5.9
- [Block Library - Template Part]:Remove support for conversion to Reusable block
- Global Styles: Call "palettes" and not "color palettes" on panel label
- Add button text when no colors found
- Update: Global Styes: Count all color palette origins on the palette counter
- Rename navigationMenuId to ref
- Offset the parent iframe when computing Popover position 
- Fix: Failing PHPUnit test
- Show theme, plugin or author in Added By column with appropriate icon or avatar
- Add origin and author to template rest api

See #54487.
Props talldanwp, mamaduka, oandregal.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51867 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-30 00:24:27 +00:00
noisysocks
121c824ccd Update @wordpress packages
Update packages to include these bug fixes from Gutenberg:

- FSE: Add welcome guide
- Update theme styles for the code block
- Add feature flag to toggle the new site editor sidebar
- Add templates list page for site editor
- Cover Block: Fix default background dim
- E2E: Add more Cover block tests
- Cover Block: Fix regressions
- Post Comments Form: ensure typography styles are applied to child elements
- Navigation: Fix space-between
- Fix background colours in nested submenus.
- Fix duplicate custom classnames in navigation submenu block
- Fix colour rendering in Navigation overlay
- Fix: Add ability to opt out of Core color palette V2
- Change @package to WordPress in block-library
- Make the core color palette opt-in for themes with not theme.json
- Remove textdomain from calendar block
- Page List block: fix space before href attribute
- Try: Let Featured Image block inherit dimensions, look like a placeholder
- [Global Styles]: Add block icon next to blocks list
- Page List: Use core entities instead of direct apiFetch
- Site Editor: Stabilize export endpoint
- Fix mobile horizontal scrollbar.
- Multi-entity save: Only set site entity to pending if really saving
- Add page list to navigation direct insert conditions
- Implement "Add New" for templates list in Site Editor
- Post Featured Image: Remove withNotices HOC
- Fix page list missing button styles when set to open on click.
- Make appender fixed position to avoid jumps in the UI
- Color UI component: reorder palettes and update names (core by defaults, user by custom)
- Remove the Styles link in Site Editor
- GlobalStyles sidebar: do not show default palette if theme opts-out
- Only render the site editor canvas when the global styles are ready.
- Global Styles: rename core origin key to default for presets
- Clarify i18n context for PostTemplateActions's "New" label
- Revert erroneous native editor package version bumps
- Try: Hide the columns inserter in pattern previews.
- Fix site editor region navigation
- Update navigation sidebar responsiveness
- Add _wp_array_set and _wp_to_kebab_case to 5.8 compat
- Make user able to change all color palette origins
- Site Editor: Update hrefs to not specifically refer to themes.php?page=gutenberg-edit-site
- Site Editor: Validate the postType query argument
- Navigation: Scale submenu icon.
- Move the theme editor under tools for FSE themes
- Deprecate navigation areas

See #54487.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51824 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-23 05:40:38 +00:00
desrosj
9d86fba4db Docs: Remove instances of the “eg.” abbreviation in favor of “example” or “for example”.
See #53330.
Built from https://develop.svn.wordpress.org/trunk@52215


git-svn-id: http://core.svn.wordpress.org/trunk@51807 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-19 14:44:01 +00:00
Peter Wilson
ab78f7561a Posts, Post Types: Use global post as the default for wp_get_post_parent_id().
Convert the `$post` parameter of `wp_get_post_parent_id()` to optional, defaulting to the current global post object when called within the loop.

Props danielpost, davidbaumwald, SergeyBiryukov, birgire, audrasjb, hellofromTonya, TimothyBlynJacobs.
Fixes #48358.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51786 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-17 03:25:06 +00:00
noisysocks
40cd53a573 Editor: Fix how the Site Editor is linked to
- Add 'Edit site' to the top admin bar.
- Link to the Template and Template Part CPTs.
- Add deep link to the Global Styles UI.

Follows [52069].
See #54337.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51750 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-15 03:43:59 +00:00
noisysocks
93d4851bbf Editor: Add Navigation Area infrastructure
Copies Navigation Area infrastrucutre from lib/navigation.php in Gutenberg. This
allows a Navigation block to be associated with a particular area which persists
when switching theme.

Props antonvlasenko, mamaduka, spacedmonkey.
See #54337.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-12 03:55:01 +00:00
desrosj
d77367a962 General: Minor fixes to Global Style related code.
Follow up to [52041,52049-52052,52054,52106,52108-52110].

Props swisspidy, TobiasBg, spacedmonkey, kebbet, oandregal.
See #54336.
Built from https://develop.svn.wordpress.org/trunk@52128


git-svn-id: http://core.svn.wordpress.org/trunk@51720 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-10 19:56:00 +00:00
desrosj
b6d67c1519 Docs: Avoid using “CPT” instead of “custom post type”.
Additionally, when referring to built in Core post types, “custom” is unnecessary.

This also adds a period to the end of the `wp_global_styles` post type description.

Follow up to [38829], [51003], [52041], [52049], [52062].

See #53399, #54335, #54336.
Built from https://develop.svn.wordpress.org/trunk@52110


git-svn-id: http://core.svn.wordpress.org/trunk@51702 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-10 14:18:06 +00:00
desrosj
b1996cbec4 i18n: Add missing translation wrapper for the Global Styles post type description.
Follow up to [52041].

See #54336.
Built from https://develop.svn.wordpress.org/trunk@52109


git-svn-id: http://core.svn.wordpress.org/trunk@51701 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-10 14:07:00 +00:00