Commit Graph

859 Commits

Author SHA1 Message Date
davidbaumwald
133c4e2e50 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.
Built from https://develop.svn.wordpress.org/trunk@50641


git-svn-id: http://core.svn.wordpress.org/trunk@50253 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-04-02 15:49:05 +00:00
Sergey Biryukov
d5a6a1ab44 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.
Built from https://develop.svn.wordpress.org/trunk@50565


git-svn-id: http://core.svn.wordpress.org/trunk@50178 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-03-23 13:55:03 +00:00
Sergey Biryukov
63fba77ec7 Docs: Fix typo in pre_term_link filter description.
See #52628.
Built from https://develop.svn.wordpress.org/trunk@50562


git-svn-id: http://core.svn.wordpress.org/trunk@50175 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-03-22 19:19:09 +00:00
Sergey Biryukov
cb55990e50 Docs: Add missing @since tags for item_link and item_link_description post type and taxonomy labels.
Follow-up to [50527].

See #52688.
Built from https://develop.svn.wordpress.org/trunk@50529


git-svn-id: http://core.svn.wordpress.org/trunk@50142 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-03-13 10:25:06 +00:00
gziolo
f27c179afc 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.


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


git-svn-id: http://core.svn.wordpress.org/trunk@50140 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-03-12 13:35:09 +00:00
John Blackbourn
52679edbff 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

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


git-svn-id: http://core.svn.wordpress.org/trunk@50118 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-03-07 12:32:09 +00:00
Sergey Biryukov
1db4b029c3 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.
Built from https://develop.svn.wordpress.org/trunk@50389


git-svn-id: http://core.svn.wordpress.org/trunk@50000 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-19 14:31:08 +00:00
Sergey Biryukov
a8d455a78f Docs: Use typed array notation in the update_post_term_count_statuses filter DocBlock.
Follow-up to [50169].

See #38843.
Built from https://develop.svn.wordpress.org/trunk@50231


git-svn-id: http://core.svn.wordpress.org/trunk@49892 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-05 19:13:09 +00:00
antpb
a2fb85da68 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.

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


git-svn-id: http://core.svn.wordpress.org/trunk@49848 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-02 21:06:05 +00:00
Sergey Biryukov
81462ca73e 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.
Built from https://develop.svn.wordpress.org/trunk@50120


git-svn-id: http://core.svn.wordpress.org/trunk@49799 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-02-01 14:13:00 +00:00
John Blackbourn
a0d0c27eed 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

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


git-svn-id: http://core.svn.wordpress.org/trunk@49795 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-31 23:14:59 +00:00
Sergey Biryukov
5c663524c2 Docs: In various @return tags, list the expected type first, instead of false.
Follow-up to [46696], [47060], [49926], [49927], [49929].

See #51800.
Built from https://develop.svn.wordpress.org/trunk@49963


git-svn-id: http://core.svn.wordpress.org/trunk@49664 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-15 20:08:07 +00:00
John Blackbourn
2be70e8aa4 Taxonomy: Correct and clarify documentation for the return types of term query functions.
See #51800, #38266

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


git-svn-id: http://core.svn.wordpress.org/trunk@49646 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-08 15:24:07 +00:00
Sergey Biryukov
7ced0efbf4 Docs: Use more consistent descriptions for void|false return values.
See #51800.
Built from https://develop.svn.wordpress.org/trunk@49935


git-svn-id: http://core.svn.wordpress.org/trunk@49634 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-05 16:48:07 +00:00
Sergey Biryukov
37662df05e 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.
Built from https://develop.svn.wordpress.org/trunk@49929


git-svn-id: http://core.svn.wordpress.org/trunk@49628 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-04 17:18:04 +00:00
John Blackbourn
dfe1f9b322 Docs: Promote many bool types to true or false where only that value is used.
See #51800

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


git-svn-id: http://core.svn.wordpress.org/trunk@49626 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-01-03 22:04:04 +00:00
John Blackbourn
bf83c368fd Docs: Various docblock improvements.
See #51800

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


git-svn-id: http://core.svn.wordpress.org/trunk@49513 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-12-10 23:59:03 +00:00
John Blackbourn
42fcfa5b3d Docs: Various docblock corrections.
See #51800

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


git-svn-id: http://core.svn.wordpress.org/trunk@49512 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-12-10 23:53:07 +00:00
Sergey Biryukov
52d2b07600 Docs: Fix typo in references to WP_Error in some DocBlocks.
See #51800.
Built from https://develop.svn.wordpress.org/trunk@49769


git-svn-id: http://core.svn.wordpress.org/trunk@49492 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-12-08 11:51:05 +00:00
John Blackbourn
f4cda1b62f Docs: Upgrade more parameters in docblocks to used typed array notation.
See #51800, #41756

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


git-svn-id: http://core.svn.wordpress.org/trunk@49416 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-11-24 21:27:05 +00:00
Sergey Biryukov
aab7112b09 Docs: Use more specific type in parameter descriptions for in_category() and is_object_in_term().
This better aligns with `is_category()` and other conditional tags and their `WP_Query` counterpart methods.

Follow-up to [47402].

Props princeahmed.
Fixes #51825.
Built from https://develop.svn.wordpress.org/trunk@49669


git-svn-id: http://core.svn.wordpress.org/trunk@49392 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-11-19 15:20:05 +00:00
Sergey Biryukov
801152b9d7 Docs: Fix typo in wp_get_object_terms filter DocBlock.
Follow-up to [49597].

See #50768.
Built from https://develop.svn.wordpress.org/trunk@49612


git-svn-id: http://core.svn.wordpress.org/trunk@49350 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-11-16 17:28:08 +00:00
John Blackbourn
170ca32007 Docs: Various docblock corrections and improvements.
See #50768

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


git-svn-id: http://core.svn.wordpress.org/trunk@49335 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-11-14 16:35:06 +00:00
Sergey Biryukov
a2d42351c5 Text Changes: Unify various "Back to..." vs. "Return to..." vs. "Go to..." strings.
Standardize on "Go to..." as a more appropriate option for most cases.

Props garrett-eclipse, kharisblank, audrasjb, ramiy, valentinbora.
Fixes #47235.
Built from https://develop.svn.wordpress.org/trunk@49539


git-svn-id: http://core.svn.wordpress.org/trunk@49277 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-11-09 10:53:10 +00:00
Peter Wilson
c8d5bc3c50 Taxonomy: Revert Light-weight/partial term counts.
Partial revert of [49141], [49171], [49316].

All functional changes are removed, appropriate term counting unit tests are retained.

See #40351.

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


git-svn-id: http://core.svn.wordpress.org/trunk@49210 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-30 04:59:08 +00:00
Peter Wilson
6c92704e10 Taxonomy: Fix values passed to actions in wp_modify_term_count_by_now().
Replace the `WP_Taxonomy` object with the taxonomy slug in the values passed to the actions `edit_term_taxonomy` and `edited_term_taxonomy` within `wp_modify_term_count_by_now()`.

Follow up to [49141], [49171].
Props Chouby, lcyh78.
Fixes #40351.


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


git-svn-id: http://core.svn.wordpress.org/trunk@49078 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-26 23:07:06 +00:00
Sergey Biryukov
0e3147c40e Coding Standards: Replace alias PHP functions with the canonical names.
Using the canonical function name for PHP functions is strongly recommended, as aliases may be deprecated or removed without (much) warning.

This replaces all uses of the following:
* `join()` with `implode()`
* `sizeof()` with `count()`
* `is_writeable()` with `is_writable()`
* `doubleval()` with a `(float)` cast

In part, this is a follow-up to #47746.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48955 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-18 17:27:06 +00:00
Peter Wilson
fa5a6c8622 Taxonomy: Improve performance of term recounting database queries.
When modifying terms assigned to an object, replace full term recounts with incrementing/decrementing the count as appropriate. This provides a significant performance boost on sites with a high number of term/object relationships and/or posts.

Introduces the functions `wp_increment_term_count()`, `wp_decrement_term_count()`, `wp_modify_term_count_by()` and `wp_modify_term_count_by_now()` for updating the term count.

Introduces the function `_wp_prevent_term_counting()` for preventing double counting on posts that are about to transition.

Adds the parameter `update_count_by_callback` to `register_taxonomy()` to allow developers to use a custom callback for incrementing or decrementing a term count.

Props boonebgorges, davidbaumwald, hellofromTonya, johnbillion, lcyh78, mattoperry, peterwilsoncc, rebasaurus, whyisjake.
Fixes #40351.


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


git-svn-id: http://core.svn.wordpress.org/trunk@48903 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-14 00:51:06 +00:00
Sergey Biryukov
897f004a9c General: Replace older-style PHP type conversion functions with type casts.
This improves performance, readability, and consistency throughout core.

* `intval()` → `(int)`
* `strval()` → `(string)`
* `floatval()` → `(float)`

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


git-svn-id: http://core.svn.wordpress.org/trunk@48870 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-10-08 21:15:13 +00:00
Sergey Biryukov
4f8f42747f Code Modernization: Correct the check for parent argument in wp_insert_term() and wp_update_term().
PHP 8 changes the way string to number comparisons are performed: https://wiki.php.net/rfc/string_to_number_comparison

In particular, checking if a non-empty, non-numeric string is greater than zero in PHP 8 evaluates to `true`, not `false`.

For `wp_insert_term()`, this resulted in a "Parent term does not exist" error for a non-numeric string, instead of discarding the value.

By explicitly casting the value to `int`, we make sure to compare both values as numbers, rather than a string and a number.

Follow-up to [29196], [29830], [29867].

See #50913.
Built from https://develop.svn.wordpress.org/trunk@49043


git-svn-id: http://core.svn.wordpress.org/trunk@48805 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-25 00:04:04 +00:00
John Blackbourn
d0a32c5111 Docs: Various docblock corrections and improvements.
See #50768
Built from https://develop.svn.wordpress.org/trunk@48941


git-svn-id: http://core.svn.wordpress.org/trunk@48703 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-09-04 20:41:07 +00:00
Sergey Biryukov
5fc75503e4 Docs: Update the description for the $legacy parameter of wp_count_terms() for consistency with get_terms().
Follow-up to [48840].

See #36399.
Built from https://develop.svn.wordpress.org/trunk@48843


git-svn-id: http://core.svn.wordpress.org/trunk@48605 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-08-23 00:08:06 +00:00
Felix Arntz
5918f7e11d Taxonomy: Allow for wp_count_terms( $args ) signature, making passing a taxonomy optional.
This brings `wp_count_terms()` in line with other taxonomy functions such as `get_terms()` which technically no longer require a taxonomy. Similar to the previously modified functions, no deprecation warning is triggered when using the legacy signature.

Fixes #36399.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-08-21 22:32:06 +00:00
Sergey Biryukov
1f85e7484f Docs: Consistently use third-person singular verbs for various filter descriptions, per the documentation standards.
See #50768.
Built from https://develop.svn.wordpress.org/trunk@48782


git-svn-id: http://core.svn.wordpress.org/trunk@48544 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-08-11 00:34:08 +00:00
John Blackbourn
782f05d2c5 Docs: Various fixes and improvements to inline documentation.
See #49572
Built from https://develop.svn.wordpress.org/trunk@48695


git-svn-id: http://core.svn.wordpress.org/trunk@48457 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-30 19:14:03 +00:00
Sergey Biryukov
3da046e1bc Taxonomy: Rename the default_taxonomy_$taxonomy option key to default_term_$taxonomy.
This better reflects the purpose of the option.

Follow-up to [48356], [48480].

See #43517.
Built from https://develop.svn.wordpress.org/trunk@48665


git-svn-id: http://core.svn.wordpress.org/trunk@48427 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-28 15:42:07 +00:00
Sergey Biryukov
38e6367808 Coding Standards: Reformat a condifion for default taxonomy terms in map_meta_cap() for better readability.
Follow-up to [48356], [48480].

See #43517.
Built from https://develop.svn.wordpress.org/trunk@48664


git-svn-id: http://core.svn.wordpress.org/trunk@48426 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-28 14:42:04 +00:00
Sergey Biryukov
5f6d6a79e8 Docs: Document that various metadata functions return false for an invalid ID.
Props salcode.
See #40519.
Built from https://develop.svn.wordpress.org/trunk@48658


git-svn-id: http://core.svn.wordpress.org/trunk@48420 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-28 10:15:04 +00:00
Sergey Biryukov
b31a5f7569 Docs: Correct documentation for wp_insert_term().
The function is used for adding a new term, not updating an existing one.

Props audrasjb, bmartinent.
Fixes #50753.
Built from https://develop.svn.wordpress.org/trunk@48600


git-svn-id: http://core.svn.wordpress.org/trunk@48362 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-24 12:19:05 +00:00
Sergey Biryukov
faf85323a6 Docs: Correct some documentation for wp_update_term().
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48599


git-svn-id: http://core.svn.wordpress.org/trunk@48361 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-24 12:04:08 +00:00
Sergey Biryukov
d936f2c959 Docs: Miscellaneous DocBlock corrections.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48591


git-svn-id: http://core.svn.wordpress.org/trunk@48353 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-23 21:55:04 +00:00
John Blackbourn
9bc7d0a776 Docs: Another pass at some inline docs fixes mostly made by PHPCBF.
See #49572, #50744
Built from https://develop.svn.wordpress.org/trunk@48590


git-svn-id: http://core.svn.wordpress.org/trunk@48352 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-23 21:11:05 +00:00
Sergey Biryukov
49a9cede70 Taxonomy: Make some adjustments to handling default terms for custom taxonomies:
* Move default term assignment from `wp_set_object_terms()` to `wp_insert_post()`.
* Make sure the passed taxonomy list overwrites the existing list if not empty.
* Remove the default term option on `unregister_taxonomy()`.
* Prevent deletion of the default term in `wp_delete_term()`.

Props enrico.sorcinelli, TimothyBlynJacobs.
See #43517.
Built from https://develop.svn.wordpress.org/trunk@48480


git-svn-id: http://core.svn.wordpress.org/trunk@48249 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-14 16:41:03 +00:00
whyisjake
6542769c56 Coding standards: Fix a few phpcs errors to get tests passing.
See [48356], #43517.

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


git-svn-id: http://core.svn.wordpress.org/trunk@48127 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-07 03:55:02 +00:00
whyisjake
49d23a2bbe Taxonomy: Add support for default terms for custom taxonomies.
The new default_term argument is added to `register_taxonomy()` allowing a user to define the default term `name` and optionally `slug` and `description`. 

Fixes #43517.

Props enrico.sorcinelli, SergeyBiryukov, desrosj, davidbaumwald, whyisjake.


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


git-svn-id: http://core.svn.wordpress.org/trunk@48125 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-07 00:55:03 +00:00
Sergey Biryukov
de751a91db Taxonomy: Introduce saved_term and saved_{$taxonomy} actions to complement created_term and created_{$taxonomy}.
This allows for hooking into both the create and update events with a single callback, in the same way that is already possible for posts via the `save_post` and `save_post_{$post->post_type}` actions.

Props dlh.
Fixes #48416.
Built from https://develop.svn.wordpress.org/trunk@48314


git-svn-id: http://core.svn.wordpress.org/trunk@48083 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-07-05 11:13:03 +00:00
Sergey Biryukov
347e831768 Docs: Improve documentation for the $prev_value parameter and return result of various metadata update functions.
Props stevenlinx.
Fixes #50502. See #49572.
Built from https://develop.svn.wordpress.org/trunk@48214


git-svn-id: http://core.svn.wordpress.org/trunk@47983 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-29 21:22:09 +00:00
Sergey Biryukov
58ad216087 Docs: Improve documentation for optional parameters per the documentation standards.
See #49572.
Built from https://develop.svn.wordpress.org/trunk@48197


git-svn-id: http://core.svn.wordpress.org/trunk@47966 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-28 11:49:02 +00:00
Sergey Biryukov
cb9c2ae83f Taxonomy: Make sure update_object_term_cache() caches all terms that were not already cached.
Due to an unintended `break` instruction from a previous iteration, the function cached only one term in each taxonomy.

Follow-up to [48055].

Props Chouby.
Fixes #50352.
Built from https://develop.svn.wordpress.org/trunk@48187


git-svn-id: http://core.svn.wordpress.org/trunk@47956 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-26 22:31:08 +00:00
Sergey Biryukov
b16368c268 Docs: Remove @staticvar tags from core.
The tag was supported in phpDocumentor 1.x, but is no longer supported in 2.x and 3.x.

Usage of static variables is considered an internal implementation detail and has no information value for someone reading the docs.

Props alishanvr, jrf.
Fixes #50426.
Built from https://develop.svn.wordpress.org/trunk@48109


git-svn-id: http://core.svn.wordpress.org/trunk@47878 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2020-06-20 12:40:12 +00:00