Commit Graph

475 Commits

Author SHA1 Message Date
Sergey Biryukov
3ad1c8897c Correct 'show_in_menu' parameter description in register_taxonomy().
fixes #27943.
Built from https://develop.svn.wordpress.org/trunk@28241


git-svn-id: http://core.svn.wordpress.org/trunk@28069 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-02 11:29:13 +00:00
Andrew Nacin
6ca804ee76 Avoid infinite recursion in get_term_children() when a term is incorrectly a parent of itself.
props kovshenin.
fixes #27123.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27671 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-29 06:08:15 +00:00
Drew Jaynes
4bd2c5ce85 Inline documentation for hooks in wp-includes/taxonomy.php.
Props kpdesign for some minor language tweaks.
Fixes #27505.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27661 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-28 21:29:13 +00:00
Drew Jaynes
da19fc531c Better standardize parameter value types in PHPDocs where both a post ID or WP_Post would be acceptable.
Covers cases where previously only `int` or `int|object` types were notated.

Props coffee2code for the original patch.
See #20495.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27318 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-08 19:32:16 +00:00
Scott Taylor
c353fa41a2 In get_terms(), leverage get_term_children() over _get_term_children() when making sure to show empty terms that have children in a hierarchical taxonomy while avoiding duplicates.
Adds unit test for `child_of` param. Adjusts unit tests for `get_terms()`.

See [27108] and [27125].
Props SergeyBiryukov.
Fixes #27123.


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


git-svn-id: http://core.svn.wordpress.org/trunk@27304 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-07 19:29:16 +00:00
Scott Taylor
3556e565b3 get_term_children() returns an array of IDs, not objects. The docs have been updated to reflect this.
Fixes #27312.


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


git-svn-id: http://core.svn.wordpress.org/trunk@27303 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-03-07 19:16:15 +00:00
Andrew Nacin
d24a109288 Revert [27115] and let cache backends handle the stripping of spaces in cache keys as necessary.
microtime() returns greater precision than microtime(true).

see #27000, #23448, #26903, #14485.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27153 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-26 22:05:13 +00:00
Drew Jaynes
cb8951b0b3 Remove all @package and @subpackage PHPDoc tags not at the file- or class-levels in core.
See #27200.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27119 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-25 17:14:14 +00:00
Scott Taylor
c1dbe9ab77 Remove extraneous type-casting in wp_get_object_terms().
Props OriginalEXE.
Fixes #27133.


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


git-svn-id: http://core.svn.wordpress.org/trunk@27046 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-17 21:56:12 +00:00
Scott Taylor
5a43c3324d Partially revert [27101], [27102], [27141], and [27142]. Those commits introduced new functions to sync up cache invalidation events. The current commit alters existing internals.
"The cache invalidation with static was introduced in r9102 with version 2.7. Multisite wasn't in core back then, so something like switch_to_blog() wasn't a concern, but now it breaks if you switch the blog in between calls to clean_term_cache."

This solution is simpler. All unit tests pass. Removes unnecessary tests linked to removed functions.

Props kovshenin.
Fixes #14485, #22526.


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


git-svn-id: http://core.svn.wordpress.org/trunk@27029 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-11 16:50:13 +00:00
Scott Taylor
6a626ab231 Reuse the terms cache group for taxonomy cache invalidation.
See #22526, #14485, [27101], [27102].


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


git-svn-id: http://core.svn.wordpress.org/trunk@27009 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-09 17:42:11 +00:00
Drew Jaynes
f481bcd2db Improve inline documentation for several 'last_changed'-related functions introduced in [27101] and [27102].
Functions include:
* `get_taxonomy_last_changed()`
* `set_taxonomy_last_changed()`
* `post_taxonomy_is_fresh()`
* `taxonomy_hierarchy_is_fresh()`

Fixes #22526, #14485.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27008 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-09 02:02:12 +00:00
Scott Taylor
75d8688f60 When a term_id matches in _get_term_children(), recurse through its children until there is no more depth in the hierarchy. Since get_terms() return terms with a count of 0 when their children are not empty, we must return all children so that get_terms() can check their count.
In [27108], #26903 was fixed, but only because we were using the example in the ticket, leaving out infinite depth for hierarchical taxonomies.

Adds unit tests, including `Tests_Term_getTerms::test_get_terms_seven_levels_deep()`.

Fixes #26903. Again.


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


git-svn-id: http://core.svn.wordpress.org/trunk@26992 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-07 19:53:12 +00:00
Andrew Nacin
084a7b50cd Use a float for last_changed microtime cache values.
microtime() by default returns a string with a space, which isn't allowed for keys in some cache backends.

props _jameslee, drozdz.
fixes #27000. see #23448.

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


git-svn-id: http://core.svn.wordpress.org/trunk@26982 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-07 08:14:12 +00:00
Scott Taylor
c2b712e3b9 In get_terms(), don't set automatically hierarchical to false when parent => 0 is passed. The default value for parent is ''.
In `_get_term_children()`, don't skip a top-level term without first including its children in the returned term list. Ironically, the call to `_get_term_children()` in `get_terms()` has a comment stating `"Make sure we show empty categories that have children."`, but it didn't work if you were retrieving top-level categories only.

All unit tests pass. Added a unit test based on the use case described in this ticket.

Fixes #26903.


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


git-svn-id: http://core.svn.wordpress.org/trunk@26975 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-06 17:45:12 +00:00
Scott Taylor
5d03d8eb50 Regenerate the term hierarchy cache ({taxonomy}_children) when it is out of sync with the passed taxonomy's last_changed value.
Introduces `taxonomy_hierarchy_is_fresh()`, which is only called in `_get_term_hierarchy()`. The taxonomy's `last_changed` value is checked against the value of `wp_cache_get( 'hierarchy_last_changed', $taxonomy )`.

Adds a unit test - `Tests_Term:test_hierachy_invalidation()`.

See [27101], which makes this type of cache invalidation possible.
Fixes #14485.


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


git-svn-id: http://core.svn.wordpress.org/trunk@26971 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-06 01:58:14 +00:00
Scott Taylor
578dbcd9f5 Add cache invalidation when updating a term, example: create a category, assign it to a post, edit the category. Currently, the post's term cache is not updated. When updating terms in a given taxonomy, invalidate the object term caches linked to that taxonomy.
Introduce `get_taxonomy_last_changed()`, `set_taxonomy_last_changed()`, and `post_taxonomy_is_fresh()`.

`post_taxonomy_is_fresh()` is only called in `get_object_term_cache()` - at which point the taxonomy's `last_changed` value is checked against the post's `{$taxonomy}_last_changed` value.

`set_taxonomy_last_changed()` is called whenever directory database queries are made that insert new terms or affect existing terms.

Fixes #22526.


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


git-svn-id: http://core.svn.wordpress.org/trunk@26970 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-02-06 01:41:12 +00:00
Scott Taylor
a6b3bced06 get_comment(), wp_get_post_revision(), and get_term() all used to return by reference. Because of this, $null was set to null so the return value would be a variable where applicable. This has not been necessary since [21792], so the $nulls have been removed.
Props toszcze.
Fixes #24768.


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


git-svn-id: http://core.svn.wordpress.org/trunk@26930 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-29 06:46:12 +00:00
Drew Jaynes
d13198db3a Add inline documentation for the 'show_admin_column' argument added to register_taxonomy() in 3.5.
Also adds a 'show_admin_column' value to the defaults array.

Props johnbillion.
Fixes #26707.

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


git-svn-id: http://core.svn.wordpress.org/trunk@26793 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-01-07 02:13:10 +00:00
Drew Jaynes
cd8cedc40d First there were two, and now there are three -- in the @since versions that came before and that shall be. And so it will be, says nacin.
Props JustinSainton, SergeyBiryukov, DrewAPicture.
Fixes #26713.

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


git-svn-id: http://core.svn.wordpress.org/trunk@26754 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-24 18:57:12 +00:00
Andrew Nacin
804be8b332 Be specific in term_exists error messages in wp_insert_term() as to what already exists (name, or name and slug).
props ericmann, SergeyBiryukov.
fixes #15741.

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


git-svn-id: http://core.svn.wordpress.org/trunk@26436 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-02 23:06:11 +00:00
Scott Taylor
ff6233b9c5 Fix lingering reference problem in wp_get_object_terms() by not setting the foreach'd vars to a reference. Adds unit test.
Props stephenharris.
Fixes #26339.


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


git-svn-id: http://core.svn.wordpress.org/trunk@26404 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-12-02 00:00:10 +00:00
Sergey Biryukov
bf6f02320a A negative term parent value should be sanitized to 0, not 1. Fix a regression in sanitize_term_field() caused by [26010].
props mattheu for initial patch.
fixes #25852.
Built from https://develop.svn.wordpress.org/trunk@26028


git-svn-id: http://core.svn.wordpress.org/trunk@25958 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-06 23:41:09 +00:00
Scott Taylor
cefafee3d3 Cast proper fields to int when returning from wp_get_object_terms(). Add term_taxonomy_id and object_id to the list in sanitize_term() and sanitize_term_field().
Fixes #17646. Adds unit tests.
Props simonwheatley, dd32, kovshenin.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25941 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-11-05 01:19:11 +00:00
Helen Hou-Sandí
7fa704d972 Allow passing false for the meta_box_cb arg in register_taxonomy() to turn off the meta box display entirely. fixes #21543.
Built from https://develop.svn.wordpress.org/trunk@25948


git-svn-id: http://core.svn.wordpress.org/trunk@25907 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-27 16:29:09 +00:00
Andrew Nacin
bba2a414a2 Fix the exclude_tree argument in get_terms(), which fixes the exclude argument in wp_list_categories().
This was a 3.7 regression caused by [25162].

props dd32.
see #25710 for trunk.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25892 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-10-26 15:04:11 +00:00
Andrew Nacin
1d269541e2 Introduce register_taxonomy_for_object_type().
props leewillis77.
fixes #11058.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25513 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-24 02:54:08 +00:00
Andrew Nacin
377cf11bfb Pass $taxonomies to two more filters in get_terms().
props johnbillion.
fixes #18754.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25493 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-23 18:39:09 +00:00
Andrew Nacin
5febb6045f Introduce a meta_box_cb argument for register_taxonomy().
The specified callback function is used as the meta box callback for the taxonomy.

props garyc40, helen.
fixes #14206.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25489 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-23 17:12:10 +00:00
Scott Taylor
ae4cf7665a Add @access private to _get_custom_object_labels(), which was already implied by the dangling underscore. Cast $labels to array in get_taxonomy_labels() and _get_custom_object_labels().
Props nacin, foofy.
Fixes #16310.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25473 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-21 17:44:09 +00:00
Scott Taylor
2d323d43e1 Ensure that terms with a post count of 0 are not returned in wp_count_terms() when hide_empty => true. Adds unit test which ensures that wp_count_terms() returns 0.
Props markjaquith.
Fixes #15919.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25471 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-21 16:48:10 +00:00
Drew Jaynes
00ca46973c Clarify error handling and special cases in the wp_insert_term() phpdoc block.
props lgedeon, SergeyBiryukov. See #22801.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25419 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-19 16:09:10 +00:00
Sergey Biryukov
8d2764fbd3 Update inline documentation for wp_insert_term().
props DrewAPicture.
fixes #22801.
Built from https://develop.svn.wordpress.org/trunk@25489


git-svn-id: http://core.svn.wordpress.org/trunk@25410 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-19 01:57:10 +00:00
Scott Taylor
6ea9e9692d Use wp_parse_args() again for $args['rewrite'] in register_taxonomy().
Props SergeyBiryukov.
Fixes #23668.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25404 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-18 20:39:09 +00:00
Scott Taylor
072b0f2128 Use reset() to access the first element of an array, don't assume there is an item at index 0.
See #25282.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25323 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-12 05:09:09 +00:00
Scott Taylor
6fb5ef65c0 Avoid a notice by casting $args['rewrite'] to array() before adding a slug property and running array_merge().
Fixes #23668.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25313 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-11 17:17:11 +00:00
Scott Taylor
cb982c66ac Don't call sanitize_title_with_dashes( $taxonomy ) in register_taxonomy() unless $args['rewrite']['slug'] is empty.
Props SergeyBiryukov.
Fixes #23668.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25297 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-11 00:09:10 +00:00
Scott Taylor
7c2e7f8995 Add term_taxonomy_id to available fields in get_term_by(). Adds unit test.
Props jchristopher.
Fixes #21651.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25296 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-11 00:02:08 +00:00
Scott Taylor
d041c830bc Avoid database error when include or exclude is not really a term_id. Adds more unit tests.
Props kovshenin.
Fixes #11823.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25225 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-05 17:15:09 +00:00
Scott Taylor
6895dc9f8e Introduce description__like arg to get_terms(). Make description__like and name__like perform LIKEs with a wildcard on both sides of passed string. Previously, strings had to match the beginning of the name, so searching for burrito in This is a burrito would fail. Adds unit tests.
Props aaroncampbell for the original patch, 5 years ago.
Fixes #8214.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25211 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-09-04 19:41:08 +00:00
Scott Taylor
7c1ea6c95c No need to re-map the return values of wp_parse_id_list() to int.
See #22074, #11823.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25145 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-29 18:54:09 +00:00
Scott Taylor
29952baa41 Search term name and slug when the search arg is passed to get_terms(). Adds unit test.
Props wojtek.szkutnik.
Fixes #13992.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25143 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-29 16:50:09 +00:00
Scott Taylor
4b449d38b4 Improve the include / exclude SQL generation in get_terms() by using IN and NOT IN where applicable. Adds unit tests for include / exclude.
Props sirzooro, duck_.

Fixes #11823.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25141 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-29 16:24:09 +00:00
Scott Taylor
2f2f50c659 Support id=>name and id=>slug values for fields arg in get_terms(). Adds unit tests.
Props mikeschinkel.

Fixes #13661.


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


git-svn-id: http://core.svn.wordpress.org/trunk@25140 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-29 15:19:10 +00:00
Andrew Nacin
732f176943 Pass $taxonomies to the get_terms_orderby filter.
props johnbillion.
fixes #18754.

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


git-svn-id: http://core.svn.wordpress.org/trunk@25122 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-27 21:06:09 +00:00
Dominik Schilling
8688857816 Introduce show_in_menu for register_taxonomy.
Accepts boolean: true to show, false to hide. If not set, the default is inherited from show_ui.

fixes #20930.
Built from https://develop.svn.wordpress.org/trunk@25133


git-svn-id: http://core.svn.wordpress.org/trunk@25113 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-26 22:35:10 +00:00
Dominik Schilling
357f52eed7 Improve inline docs for register_post_type() and register_taxonomy().
* register_taxonomy: Use the same doc format for the associative array arg as used for register_post_type()
* register_taxonomy: Improve docs for _builtin, capabilities, hierarchical and rewrite args
* register_taxonomy: Use the same order in $defaults as in docblock
* register_taxonomy: Replace is_null with null ===, to be consistent
* register_post_type: Use the same order in $defaults as in docblock
* register_post_type: Improve docs for @uses and default fallbacks
And while we're on it: Whitespaces.

fixes #25150.
Built from https://develop.svn.wordpress.org/trunk@25130


git-svn-id: http://core.svn.wordpress.org/trunk@25110 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-26 20:24:08 +00:00
Scott Taylor
a97dfd3009 Use reset() to grab the first taxonomy in an array, not by numerical index. Cleans up whitespace. Props webord, nbachiyski. Fixes #23506.
Built from https://develop.svn.wordpress.org/trunk@25108


git-svn-id: http://core.svn.wordpress.org/trunk@25090 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-23 21:29:10 +00:00
Scott Taylor
22c59d9c45 Check term_id against the $term object, not the non-existent var $args. Props rboren. Fixes #12729.
Built from https://develop.svn.wordpress.org/trunk@25106


git-svn-id: http://core.svn.wordpress.org/trunk@25088 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-08-23 21:05:09 +00:00
Andrew Nacin
ac1f98d4ce Add description argument to register_taxonomy().
props aaronholbrook.
fixes #24808.



git-svn-id: http://core.svn.wordpress.org/trunk@24833 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-28 23:01:56 +00:00