Commit Graph

467 Commits

Author SHA1 Message Date
Peter Wilson
b1b59d27a0 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@53170 602fd350-edb4-49c9-b593-d223f7449a82
2022-04-13 03:02:43 +00:00
Peter Wilson
affb0bcb0c 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@53126 602fd350-edb4-49c9-b593-d223f7449a82
2022-04-11 05:09:53 +00:00
Peter Wilson
3cd1a741a0 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@53058 602fd350-edb4-49c9-b593-d223f7449a82
2022-04-04 03:48:08 +00:00
Sergey Biryukov
31a155c91f Docs: Use third-person singular verbs for function descriptions in wp-includes/taxonomy.php, per the documentation standards.
See #54729.

git-svn-id: https://develop.svn.wordpress.org/trunk@52992 602fd350-edb4-49c9-b593-d223f7449a82
2022-03-25 16:51:06 +00:00
Sergey Biryukov
d72bcea816 Docs: Adjust the term_exists_default_query_args filter docs per the documentation standards.
Follow-up to [52987].

See #55439.

git-svn-id: https://develop.svn.wordpress.org/trunk@52991 602fd350-edb4-49c9-b593-d223f7449a82
2022-03-25 16:46:42 +00:00
Jonny Harris
3ba117a8ab 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.




git-svn-id: https://develop.svn.wordpress.org/trunk@52987 602fd350-edb4-49c9-b593-d223f7449a82
2022-03-24 10:24:52 +00:00
Jonny Harris
34d46cd501 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. 


git-svn-id: https://develop.svn.wordpress.org/trunk@52921 602fd350-edb4-49c9-b593-d223f7449a82
2022-03-11 11:05:02 +00:00
Peter Wilson
87844a6eb2 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@52830 602fd350-edb4-49c9-b593-d223f7449a82
2022-03-08 04:23:34 +00:00
Jb Audras
a66f7ef477 Docs: Correct the indentation in delete_term_relationships filter.
See #54673.


git-svn-id: https://develop.svn.wordpress.org/trunk@52826 602fd350-edb4-49c9-b593-d223f7449a82
2022-03-07 12:55:57 +00:00
Jonny Harris
deafd1193c 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@52707 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-11 18:50:08 +00:00
Jonny Harris
acfcea4cba 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@52669 602fd350-edb4-49c9-b593-d223f7449a82
2022-02-03 17:41:46 +00:00
Sergey Biryukov
6dc3ff47d2 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@52553 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-11 04:10:03 +00:00
Jb Audras
d831c042d6 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@52537 602fd350-edb4-49c9-b593-d223f7449a82
2022-01-07 11:19:08 +00:00
Sergey Biryukov
9e4f967968 Docs: Capitalize "ID", when referring to a post ID, term ID, etc. in a more consistent way.
Follow-up to [48104].

See #53399.

git-svn-id: https://develop.svn.wordpress.org/trunk@52357 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-12 14:51:34 +00:00
John Blackbourn
ba518c2d86 Docs: Various inline documentation corrections and improvements.
See #53399


git-svn-id: https://develop.svn.wordpress.org/trunk@52332 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-07 12:18:50 +00:00
John Blackbourn
08efcf0cb8 Docs: Various docblock corrections.
See #53399


git-svn-id: https://develop.svn.wordpress.org/trunk@52299 602fd350-edb4-49c9-b593-d223f7449a82
2021-12-01 12:15:21 +00:00
John Blackbourn
9932b46595 Docs: Various corrections and improvements relating to types used in inline documentation.
See #53399


git-svn-id: https://develop.svn.wordpress.org/trunk@52204 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-18 13:48:43 +00:00
Sergey Biryukov
7a82c00961 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@52163 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-15 16:43:29 +00:00
David Baumwald
1e785fa0c3 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@52131 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-10 21:09:30 +00:00
Peter Wilson
6fc6730d4f 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.



git-svn-id: https://develop.svn.wordpress.org/trunk@52094 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-10 00:44:49 +00:00
Timothy Jacobs
aae0000cef 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@52079 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-09 18:58:59 +00:00
Robert Anderson
39e33bed83 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@52062 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-08 23:09:53 +00:00
jorgefilipecosta
7bbee20833 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@52041 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-08 14:24:02 +00:00
Sergey Biryukov
175ad4c91c 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@51965 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-01 14:29:42 +00:00
Timothy Jacobs
2cd084aeb0 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].


git-svn-id: https://develop.svn.wordpress.org/trunk@51964 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-01 03:26:06 +00:00
John Blackbourn
4bf908449a 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


git-svn-id: https://develop.svn.wordpress.org/trunk@51885 602fd350-edb4-49c9-b593-d223f7449a82
2021-10-04 20:42:54 +00:00
John Blackbourn
d7b91f9da6 Docs: Document some more common names for dynamic hooks and standardise the phrasing used.
Fixes #53581


git-svn-id: https://develop.svn.wordpress.org/trunk@51837 602fd350-edb4-49c9-b593-d223f7449a82
2021-09-21 18:19:19 +00:00
Tonya Mork
9abf35cfa7 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@51796 602fd350-edb4-49c9-b593-d223f7449a82
2021-09-10 15:02:07 +00:00
Sergey Biryukov
a52bc208ba 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@51731 602fd350-edb4-49c9-b593-d223f7449a82
2021-09-05 11:05:58 +00:00
johnbillion
5383af8483 Docs: Add and correct examples of common names for various dynamic hooks.
See #53581


git-svn-id: https://develop.svn.wordpress.org/trunk@51327 602fd350-edb4-49c9-b593-d223f7449a82
2021-07-03 21:41:02 +00:00
Riad Benguella
ea49625d59 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.


git-svn-id: https://develop.svn.wordpress.org/trunk@51003 602fd350-edb4-49c9-b593-d223f7449a82
2021-05-25 14:19:14 +00:00
Sergey Biryukov
110f132f7e 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.

git-svn-id: https://develop.svn.wordpress.org/trunk@50935 602fd350-edb4-49c9-b593-d223f7449a82
2021-05-19 22:10:58 +00:00
John Blackbourn
0a3a3c5119 Docs: Miscellaneous docblock updates.
See #52628


git-svn-id: https://develop.svn.wordpress.org/trunk@50828 602fd350-edb4-49c9-b593-d223f7449a82
2021-05-07 20:14:22 +00:00
David Baumwald
3bb06ce10b Docs: Clarify return results for a non-existing ID in metadata functions.
[48658] documented that various metadata functions return false for an invalid ID. However, that does not clarify what an invalid ID is: a non-numeric, zero, or negative value. This change adds the clarification in all relevant metadata function docblocks.

Props icopydoc, SergeyBiryukov, davidkryzaniak, audrasjb.
Fixes #51797.

git-svn-id: https://develop.svn.wordpress.org/trunk@50641 602fd350-edb4-49c9-b593-d223f7449a82
2021-04-02 15:47:34 +00:00
Sergey Biryukov
accdb47ffb Taxonomy: Use a consistent check for the $rewrite['hierarchical'] parameter.
This avoids a "Trying to access array offset on value of type bool" PHP warning in `get_term_link()` if the `$rewrite` parameter of `register_taxonomy()` is set as `false`.

Props Tkama, SergeyBiryukov.
Fixes #52882.

git-svn-id: https://develop.svn.wordpress.org/trunk@50565 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-23 13:53:50 +00:00
Sergey Biryukov
ccb4474b4a Docs: Fix typo in pre_term_link filter description.
See #52628.

git-svn-id: https://develop.svn.wordpress.org/trunk@50562 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-22 19:17:45 +00:00
Sergey Biryukov
1446948f95 Docs: Add missing @since tags for item_link and item_link_description post type and taxonomy labels.
Follow-up to [50527].

See #52688.

git-svn-id: https://develop.svn.wordpress.org/trunk@50529 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-13 10:23:56 +00:00
Greg Ziółkowski
380d0445e8 Editor: Make block type aware of variations
Currently block variations are only defined on the client. In some cases, creating block variations on the server can be very useful, especially when needed data is not exposed in the REST APIs.

Related to https://github.com/WordPress/gutenberg/pull/29095.

Props: gwwar, timothyblynjacobs.
Fixes: #52688.



git-svn-id: https://develop.svn.wordpress.org/trunk@50527 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-12 13:33:21 +00:00
John Blackbourn
fa05e5e733 Docs: Add examples of possible names for various hooks whose name contains a dynamic portion.
This provides greater discoverability of such hooks in search results on the Code Reference site as well as increased clarity when reading the source.

See #50734, #52628


git-svn-id: https://develop.svn.wordpress.org/trunk@50505 602fd350-edb4-49c9-b593-d223f7449a82
2021-03-07 12:30:38 +00:00
Sergey Biryukov
d1c40e9a3d Taxonomy: Optimize wp_delete_term() for large object counts without a default term.
When deleting a term, it has to be removed individually from each object it's connected to, which can take some significant time when there are a lot of objects.

By calling `wp_remove_object_terms()` when no default term is required, we can skip the terms fetch/diff step and significantly speed up the deletion process.

Props dd32.
Fixes #52549.

git-svn-id: https://develop.svn.wordpress.org/trunk@50389 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-19 14:29:29 +00:00
Sergey Biryukov
a07d734d77 Docs: Use typed array notation in the update_post_term_count_statuses filter DocBlock.
Follow-up to [50169].

See #38843.

git-svn-id: https://develop.svn.wordpress.org/trunk@50231 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-05 19:11:15 +00:00
Anthony Burchell
422c2c4ad2 Taxonomy: Add filter for post statuses when updating term count.
This adds a filter that allows `$post_statuses` to be modified in term count.

Props GunGeekATX, adamsilverstein, davecpage, nwjames, hellofromTonya, audrasjb, peterwilsoncc, TimothyBlynJacobs.
Fixes #38843.


git-svn-id: https://develop.svn.wordpress.org/trunk@50169 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-02 21:04:58 +00:00
Sergey Biryukov
e1001678a6 Posts, Post Types: Introduce "Filter by date" and "Filter by category" as post type and taxonomy labels, respectively.
This provides a more consistent location for these strings and allows for reusing them in other places without hardcoding them in the markup.

Props nicolalaserra, audrasjb, johnjamesjacoby, SergeyBiryukov.
Fixes #42421.

git-svn-id: https://develop.svn.wordpress.org/trunk@50120 602fd350-edb4-49c9-b593-d223f7449a82
2021-02-01 14:11:57 +00:00
John Blackbourn
66567d3191 Taxonomy: Declare and document the sort and args properties of the WP_Taxonomy class.
These properties have been in use since 2.5 and 2.6 but were never added as actual properties on the class. This fixes that.

Props gunnard, SergeyBiryukov

Fixes #52142


git-svn-id: https://develop.svn.wordpress.org/trunk@50116 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-31 23:13:50 +00:00
Sergey Biryukov
fbab01c8ce Docs: In various @return tags, list the expected type first, instead of false.
Follow-up to [46696], [47060], [49926], [49927], [49929].

See #51800.

git-svn-id: https://develop.svn.wordpress.org/trunk@49963 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-15 20:06:50 +00:00
John Blackbourn
cf68c90021 Taxonomy: Correct and clarify documentation for the return types of term query functions.
See #51800, #38266


git-svn-id: https://develop.svn.wordpress.org/trunk@49947 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-08 15:22:17 +00:00
Sergey Biryukov
5c82078df7 Docs: Use more consistent descriptions for void|false return values.
See #51800.

git-svn-id: https://develop.svn.wordpress.org/trunk@49935 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-05 16:46:02 +00:00
Sergey Biryukov
715daf875a Docs: In various @return tags, list the expected type first, instead of false or WP_Error.
Follow-up to [46696], [47060], [49926], [49927].

See #51800.

git-svn-id: https://develop.svn.wordpress.org/trunk@49929 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-04 17:16:43 +00:00
John Blackbourn
679ccc35e6 Docs: Promote many bool types to true or false where only that value is used.
See #51800


git-svn-id: https://develop.svn.wordpress.org/trunk@49927 602fd350-edb4-49c9-b593-d223f7449a82
2021-01-03 22:02:13 +00:00
John Blackbourn
37f8276a18 Docs: Various docblock improvements.
See #51800


git-svn-id: https://develop.svn.wordpress.org/trunk@49790 602fd350-edb4-49c9-b593-d223f7449a82
2020-12-10 23:57:29 +00:00