Commit Graph

909 Commits

Author SHA1 Message Date
Sergey Biryukov
6e59ccc47e Coding Standards: Rename the remaining $cat_ID variables to $cat_id.
This resolves a few WPCS warnings:
{{{
Variable "$cat_ID" is not in valid snake_case format, try "$cat_i_d"
}}}

Affected functions:
* `wp_delete_category()`
* `get_category_rss_link()`
* `get_catname()`

Follow-up to [836], [2068], [2551], [2695], [6365], [10959], [52958], [55190].

Fixes #56754.
Built from https://develop.svn.wordpress.org/trunk@55334


git-svn-id: http://core.svn.wordpress.org/trunk@54867 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-14 15:46:18 +00:00
Sergey Biryukov
1e3c221043 Docs: Remove the legacy example of passing a taxonomy to get_terms().
As of WordPress 4.5, taxonomies should be passed to `get_terms()` via the `taxonomy` argument in the `$args` array:
{{{
$terms = get_terms( array(
    'taxonomy'   => 'post_tag',
    'hide_empty' => false,
) );
}}}

The legacy way of passing a taxonomy via the function's first parameter was still mentioned in the documentation, causing some confusion.

This commit updates the function documentation to better highlight the currently recommended approach.

Follow-up to [36614].

Props ramon-fincken, sabernhardt, SergeyBiryukov.
Fixes #57380.
Built from https://develop.svn.wordpress.org/trunk@55018


git-svn-id: http://core.svn.wordpress.org/trunk@54551 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-27 12:23:15 +00:00
Sergey Biryukov
c178ececac Code Modernization: Rename parameters that use reserved keywords in wp-includes/taxonomy.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 `$object_type` in `get_object_taxonomies()`.
* Renames the `$parent` parameter to `$parent_term` in:
 * `term_exists()`
 * `wp_check_term_hierarchy_for_loops()`

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].

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


git-svn-id: http://core.svn.wordpress.org/trunk@54544 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-21 14:36:18 +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
eb68614e2e Coding Standards: Declare $wp_taxonomies global at the top of unregister_taxonomy().
This brings some consistency with how the global is declared in other taxonomy functions.

Follow-up to [36243], [38747], [54794].

See #57058.
Built from https://develop.svn.wordpress.org/trunk@54810


git-svn-id: http://core.svn.wordpress.org/trunk@54362 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-11 12:39:13 +00:00
audrasjb
c64cc7959e Docs: Improve globals documentation in unregister_taxonomy() and wp_term_is_shared().
Props upadalavipul, mukesh27.
Fixes #57058. 
See #56792.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-11-10 17:16:12 +00:00
audrasjb
f4521ee2a1 Docs: Improve wp_get_object_terms() return type.
Props dd32, audrasjb, desrosj, mukesh27.
Fixes #56327.
See #55646.

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


git-svn-id: http://core.svn.wordpress.org/trunk@54000 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-10-10 12:30:16 +00:00
John Blackbourn
0974640a7c Taxonomy: Standardise the format used to describe arguments passed to actions and filters inside wp_insert_term() and wp_update_term().
Props SergeyBiryukov, mboynes

Fixes #55441

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


git-svn-id: http://core.svn.wordpress.org/trunk@53825 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-20 18:53:09 +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
John Blackbourn
85306e1fd6 Taxonomy: Introduce the is_term_publicly_viewable() function.
This is the taxonomy term counterpart to the `is_post_publicly_viewable()` function. Although the logic for terms is more straight forward this serves the same purpose as introducing the corresponding function for posts -- to centralise and reduce the logic needed to validate a term and determine if it's publicly viewable.

Props peterwilsoncc, costdev, johnbillion

Fixes #56215

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


git-svn-id: http://core.svn.wordpress.org/trunk@53452 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-13 22:44:09 +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
50e3e21cb2 Docs: Clarify that register_taxonomy() only accepts lowercase values for the $taxonomy parameter.
This brings consistency with docblock used in `register_post_type()`.

Props audrasjb, bengreeley, dipakparmar443.
Fixes #56352
See #55646.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53432 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-10 13:54:12 +00:00
audrasjb
60d0586c27 Docs: Various docblock fixes in Core Taxonomy API, as per docs standards.
See #55646.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53430 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-09 10:41:10 +00:00
audrasjb
f63d34e3e3 Taxonomy: Prevent non string taxonomy names generating warnings or errors.
This changeset adds an `is_string( $taxonomy )` check to the condition in `taxonomy_exists()`, to ensure `false` is returned when the `$taxonomy` is not a string.

Follow-up to [35718].

Props costdev, peterwilsoncc, mukesh27.
Fixes #56338.
See #56336.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53428 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-09 10:23:13 +00:00
John Blackbourn
79db573265 Docs: Various corrections and improvements to inline documentation.
See #55646

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


git-svn-id: http://core.svn.wordpress.org/trunk@53386 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-08-04 14:52:11 +00:00
Peter Wilson
1ace1a4d2b Taxonomy: Retain default term option when unregistering taxos.
No longer delete the default term option in `unregister_taxonomy()` to improve database performance.

Since taxonomies are registered at runtime and can't be unregistered unless they're already registered, prior to this 
change the option was created and deleted on each request.

Deleting the option should occur on a one-time opperation such as plugin deactivation.

Follow up to [48480].

Props dlh.
Fixes #54472.

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


git-svn-id: http://core.svn.wordpress.org/trunk@53228 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-06 05:11:12 +00:00
John Blackbourn
d50fbb4469 Taxonomy: Pass the $args parameter to all actions and filters in wp_insert_term() and wp_update_term().
This allows actions and filters to access potentially useful contextual information when terms are inserted and updated.

Props mboynes

Fixes #55441

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


git-svn-id: http://core.svn.wordpress.org/trunk@53186 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-07-01 19:09:14 +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
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
Sergey Biryukov
746f1146c9 Docs: Use third-person singular verbs for function descriptions in wp-includes/taxonomy.php, per the documentation standards.
See #54729.
Built from https://develop.svn.wordpress.org/trunk@52992


git-svn-id: http://core.svn.wordpress.org/trunk@52581 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-25 16:53:01 +00:00
Sergey Biryukov
05dfeab45e Docs: Adjust the term_exists_default_query_args filter docs per the documentation standards.
Follow-up to [52987].

See #55439.
Built from https://develop.svn.wordpress.org/trunk@52991


git-svn-id: http://core.svn.wordpress.org/trunk@52580 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-25 16:48:01 +00:00
spacedmonkey
e0570e5753 Taxonomy: Introduce term_exists_default_query_args filter.
In [52921] `term_exists` was converted to use `get_terms`. This change adds a filter called `term_exists_default_query_args` 
to the `term_exists` function to allow developers to modify the arguments passed to `get_terms` before the query is run.

Props Chouby, Spacedmonkey, peterwilsoncc.
Fixes #55439.



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


git-svn-id: http://core.svn.wordpress.org/trunk@52576 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-24 10:26:06 +00:00
spacedmonkey
4c23c2f079 Taxonomy: Use get_terms instead of a database lookup in term_exists().
Replace raw SQL queries to the terms table, with a call to the `get_terms` function. Using `get_terms` means that `term_exists` is now cached. For developers using `term_exists` where cache invalidation is disabled, such as importing, a workaround was added to ensure that queries are uncached. 

Props Spacedmonkey, boonebgorges, flixos90, peterwilsoncc. 
Fixes #36949. 

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


git-svn-id: http://core.svn.wordpress.org/trunk@52510 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-11 11:07:05 +00:00
Peter Wilson
1b72380e10 Taxonomy: Improve code quality within _prime_term_caches().
Remove the second parameter on the call to `update_term_cache()` from within the function `_prime_term_caches()`. The since deprecated parameter of the former was at one point a string, never a boolean.

Props david.binda, SergeyBiryukov, azouamauriac.
Fixes #55162.


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


git-svn-id: http://core.svn.wordpress.org/trunk@52419 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-08 04:25:06 +00:00
audrasjb
e6e88f4a2b Docs: Correct the indentation in delete_term_relationships filter.
See #54673.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52415 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-03-07 12:57:05 +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
spacedmonkey
db603605ac Taxonomy: Remove cache expiry limitation in WP_Term_Query.
Remove the one day expiry limitation from query caches found in the `WP_Term_Qurery` class. Removing this limitation means that the caches will remain in object caching, as long as possible. Ensure that all term / taxonomy cache clear functions invalidate query caches, by deleting the last_changed value in the terms cache group. 

Props spacedmonkey, adamsilverstein, boonebgorges, tillkruess, dlh, flixos90.
Fixes #54511.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52258 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-02-03 17:43:06 +00:00
Sergey Biryukov
56d10309d0 Database: Add missing AS after INNER JOIN in some queries.
While `AS` is an optional keyword in SQL, it is commonly considered best practice to include it for better readability and compatibility. This also makes the queries more consistent with other queries using aliases in core.

Follow-up to [6359], [30238].

Props costdev, domainsupport.
Fixes #54769.
Built from https://develop.svn.wordpress.org/trunk@52553


git-svn-id: http://core.svn.wordpress.org/trunk@52143 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-01-11 04:12:05 +00:00
audrasjb
286e4fa9b0 Taxonomy: Typo correction in context used for the navigation link block title.
This change fixes a wrong translation context on the navigation link block title.

Follow-up to [50527].

Props Chouby.
Fixes #54566.

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


git-svn-id: http://core.svn.wordpress.org/trunk@52127 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-01-07 11:21:04 +00:00
Sergey Biryukov
6cb050d878 Docs: Capitalize "ID", when referring to a post ID, term ID, etc. in a more consistent way.
Follow-up to [48104].

See #53399.
Built from https://develop.svn.wordpress.org/trunk@52357


git-svn-id: http://core.svn.wordpress.org/trunk@51949 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-12 14:54:00 +00:00
John Blackbourn
39bff93b6b Docs: Various inline documentation corrections and improvements.
See #53399

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


git-svn-id: http://core.svn.wordpress.org/trunk@51924 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-07 12:20:02 +00:00
John Blackbourn
9a982b4ae8 Docs: Various docblock corrections.
See #53399

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


git-svn-id: http://core.svn.wordpress.org/trunk@51891 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-12-01 12:17:00 +00:00
John Blackbourn
c9746ab584 Docs: Various corrections and improvements relating to types used in inline documentation.
See #53399

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


git-svn-id: http://core.svn.wordpress.org/trunk@51796 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-18 13:50:05 +00:00
Sergey Biryukov
9ac09f5a67 Taxonomy: Clarify the taxonomy labels for customizing the field descriptions on Edit Tags screen:
* Update the label names to make it clear that these descriptions are not for the term name or slug itself, but for the Name, Slug, Parent, and Description fields:
 * `name_field_description`
 * `slug_field_description`
 * `parent_field_description`
 * `desc_field_description`
* Update the array structure to make it clear that the default values for these labels are the same for both hierarchical and non-hierarchical taxonomies, with the exception of `parent_field_description`.
* Add documentation and a `@since` note for the new labels.

Follow-up to [52094].

Fixes #43060.
Built from https://develop.svn.wordpress.org/trunk@52163


git-svn-id: http://core.svn.wordpress.org/trunk@51755 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-15 16:45:01 +00:00
davidbaumwald
dd80fd488b Taxonomy: Document that the get_terms filter can have null for $taxonomies.
The `get_terms` filter currently documents that the filter passes an array as both the first and second parameters, which is normally true, except that the second can be `null` when not specified.  This change updates the filter's docblock to indicate that the second parameter can also be of a `null` type.

Props dd32, audrasjb, mukesh27.
Fixes #54222.
Built from https://develop.svn.wordpress.org/trunk@52131


git-svn-id: http://core.svn.wordpress.org/trunk@51723 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-10 21:11:00 +00:00
Peter Wilson
37c02eb5fe Taxonomy: Change some static strings to registration labels.
Add additional label options to `register_taxonomy()` to allow developers further flexibility for customizing the edit taxonomy screen.

Props mclaurent, swissspidy, johnbillion, jeremyescott, theMikeD, jeremyfelt, dontgo2sleep, SergeyBiryukov, audrasjb, Boniu91.
Fixes #43060.


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


git-svn-id: http://core.svn.wordpress.org/trunk@51686 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-10 00:46:00 +00:00
TimothyBlynJacobs
e2d4385a4f REST API: Introduce Menu management endpoints.
This commit introduces the `/wp/v2/menus`, `/wp/v2/menu-items` and `/wp/v2/menu-locations` REST API endpoints. These endpoints are fully available to users with the `edit_theme_options` capability, but can be read by any user who can edit a REST API available post type.

The `nav_menu` taxonomy and `nav_menu_item` post type now map their capabilities to the `edit_theme_options` primitive capability. This allows developers to provide more fine-grained access control. However, if a developer is currently dynamically removing the `edit_theme_options` capability using `map_meta_cap`, they should use the `user_has_cap` filter instead.

The `wp_update_nav_menu_item()` function has been adjusted to return an error if saving the menu item post or assigning the menu item to a menu generate an error.

Lastly, a new menu item type is introduced, `block`, that can be used to store a Block as a menu item.

Props andraganescu, antonvlasenko, dingo_d, dlh, isabel_brison, kadamwhite, Mamaduka, NateWr, noisysocks, peterwilsoncc, ryelle, schlessera, soean, Spacedmonkey, talldanwp, TimothyBlynJacobs, tobifjellner, westonruter, wpscholar, zieladam.
Fixes #40878.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51671 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-09 19:00:01 +00:00
noisysocks
f05f235042 Editor: Add block theme infrastructure
Adds the required infrastructure to render block-based themes. This is sourced
from the Gutenberg plugin.

Fixes #54335.
Props bernhard-reiter, youknowriad, ntsekouras, hellofromtonya.

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


git-svn-id: http://core.svn.wordpress.org/trunk@51654 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-08 23:10:59 +00:00
jorgefilipecosta
0b4ecc9b23 Add: wp_global_styles custom post type.
This commit adds the wp_global_styles custom post type following the same approach used to add other core custom post types. It also updates the wp_theme taxonomy to include the wp_global_styles post type.
The post type is registered in the same way it is on the plugin we just adapt the location for the core.

See #54336.
Props oandregal.
Built from https://develop.svn.wordpress.org/trunk@52041


git-svn-id: http://core.svn.wordpress.org/trunk@51633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-08 14:26:00 +00:00
Sergey Biryukov
b855ffec3f Docs: Add a @since note for the rest_namespace argument of register_post_type() and register_taxonomy().
Use 3-digit, x.x.x-style semantic versioning for `@since` tags of the `$rest_namespace` property in `WP_Post_Type` and `WP_Taxonomy`.

Add a `@since` note to `WP_REST_Taxonomies_Controller::get_item_schema()` for the `visibility` and `rest_namespace` properties.

The `rest_base` property was also added after the method was initially introduced, but that happened during the same release cycle, so it doesn't need a separate `@since` note.

Follow-up to [38832], [39191], [42729], [51959], [51961], [51962], [51964].

See #53399.
Built from https://develop.svn.wordpress.org/trunk@51965


git-svn-id: http://core.svn.wordpress.org/trunk@51554 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-01 14:31:00 +00:00
TimothyBlynJacobs
c0995319f4 REST API: Support custom namespaces for taxonomies.
While a taxonomy can define a custom route by using the rest_base argument, a namespace of wp/v2 was assumed. This commit introduces support for a rest_namespace argument.

A new rest_get_route_for_taxonomy_items function has been introduced and the rest_get_route_for_term function updated to facilitate getting the correct route for taxonomies.

For maximum compatibility sticking with the default wp/v2 namespace is recommended until the API functions see wider use.

Props spacedmonkey.
Fixes #54267.
See [51962].

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


git-svn-id: http://core.svn.wordpress.org/trunk@51553 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-11-01 03:27:55 +00:00
John Blackbourn
41995176f6 Docs: Miscellaneous inline documentation improvements, including:
* Document the post statuses global as an array of `stdClass` objects
* Document the taxonomies global as an array of `WP_Taxonomy` objects
* Document the return value of the post count functions as `stdClass` objects
* Fix some typos

See #53399

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


git-svn-id: http://core.svn.wordpress.org/trunk@51478 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-04 20:44:02 +00:00
John Blackbourn
ae9eae8f64 Docs: Document some more common names for dynamic hooks and standardise the phrasing used.
Fixes #53581

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


git-svn-id: http://core.svn.wordpress.org/trunk@51444 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-21 18:21:00 +00:00
hellofromTonya
243e75eb41 Code Modernization: Fix null to non-nullable deprecation in term_exists().
The `term_exists()` function expects a string or an integer for the `$term` parameter. It validates for integer, but not for string or `null`.

One of the pre-existing test cases, passed `null` to the function, leading to a `trim(): Passing null to parameter #1 ($string) of type string is deprecated` notice on PHP 8.1.

Fixed now by doing a cursory check on the variable at the start of the function and bowing out early in case the `$term` is `null`.

The issue was discovered via and is already covered by the `Tests_TermExists::test_term_exists_unknown()` test method.

Follow-up to [15220]. [38716].

Props jrf, hellofromTonya.
See #53635.
Built from https://develop.svn.wordpress.org/trunk@51796


git-svn-id: http://core.svn.wordpress.org/trunk@51403 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-10 15:03:57 +00:00
Sergey Biryukov
c5d96d88a3 Docs: Сlarify that term_id is a valid value for the $field parameter of get_term_by().
As `term_id` is the actual property name of the `WP_Term`, it should appear first and we should make it more clear that `id` and `ID` are aliases.

Follow-up to [6254], [25334], [38677], [47865], [47870].

Props gazchap, audrasjb.
Fixes #54065.
Built from https://develop.svn.wordpress.org/trunk@51731


git-svn-id: http://core.svn.wordpress.org/trunk@51337 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-05 11:06:59 +00:00
John Blackbourn
efaf4a8938 Docs: Add and correct examples of common names for various dynamic hooks.
See #53581

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


git-svn-id: http://core.svn.wordpress.org/trunk@50936 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-07-03 21:42:59 +00:00
youknowriad
4ae0e4220f Block Editor: Introduce block templates for classic themes.
With this patch, users will be able to create custom block based templates
and assign them to specific pages/posts.

Themes can also opt-out of this feature

Props bernhard-reiter, carlomanf.
Fixes #53176.

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


git-svn-id: http://core.svn.wordpress.org/trunk@50612 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-25 14:20:57 +00:00
Sergey Biryukov
893beee31e General: Ensure consistent type for integer properties of WP_Post, WP_Term, and WP_User.
Previously, these properties could be unexpectedly converted to strings in some contexts.

This applies to the following functions:

* `sanitize_post_field()`
* `sanitize_term_field()`
* `sanitize_user_field()`

and the following properties:

* `WP_Post::ID`
* `WP_Post::post_parent`
* `WP_Post::menu_order`
* `WP_Term::term_id`
* `WP_Term::term_taxonomy_id`
* `WP_Term::parent`
* `WP_Term::count`
* `WP_Term::term_group`
* `WP_User::ID`

Props grantmkin, SergeyBiryukov.
Fixes #53235. See #52995.
Built from https://develop.svn.wordpress.org/trunk@50935


git-svn-id: http://core.svn.wordpress.org/trunk@50544 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-19 22:11:56 +00:00
John Blackbourn
bdaca9bffc Docs: Miscellaneous docblock updates.
See #52628

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


git-svn-id: http://core.svn.wordpress.org/trunk@50437 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-05-07 20:16:00 +00:00