Commit Graph

785 Commits

Author SHA1 Message Date
Drew Jaynes
31f150080a Docs: Standardize references to "meta box" or "meta boxes" as two distinct words throughout core documentation per the core spelling guide.
See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37970 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-10 00:56:28 +00:00
Sergey Biryukov
139387b7e5 Docs: Use 3-digit, x.x.x-style semantic versioning for _doing_it_wrong(), _deprecated_function(), _deprecated_argument(), and _deprecated_file() throughout core.
Props metodiew.
Fixes #36495.
Built from https://develop.svn.wordpress.org/trunk@37985


git-svn-id: http://core.svn.wordpress.org/trunk@37926 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-07-06 12:40:29 +00:00
Boone Gorges
4f264b6d07 Add a note about uniqueness to the doc block for get_term_by().
`get_term_by()` always returns a single term, even when more than one term
matches the query parameters. The new note warns developers to use
`get_terms()` when such ambiguity may result.

Fixes #36878.
Built from https://develop.svn.wordpress.org/trunk@37656


git-svn-id: http://core.svn.wordpress.org/trunk@37622 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-08 04:08:27 +00:00
Boone Gorges
57e5e7fd79 Taxonomy: No, really, don't pass results of 'count' query through 'get_terms' filter.
[37623] used the wrong parameter name (count=true instead of fields=count).

For greater flexibility and forward compatibility with other potential changes
to the return value of `get_terms()`, we now do a looser check: any non-array
value is excluded from the filter.

Fixes #36992.
Built from https://develop.svn.wordpress.org/trunk@37634


git-svn-id: http://core.svn.wordpress.org/trunk@37602 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-04 12:20:28 +00:00
Boone Gorges
f6980a5fd7 Taxonomy: Don't pass results of 'count' query through 'get_terms' filter.
Use of the 'get_terms' filter was consolidated in [37572], with the
introduction of `WP_Term_Query`. At that time, the result of 'count=true'
queries began being filtered by 'get_terms'. This breaks existing 'get_terms'
callbacks, which often assume that the returned value will be an array or a
`WP_Error` object.

Props JustinSainton.
Fixes #36992.
Built from https://develop.svn.wordpress.org/trunk@37623


git-svn-id: http://core.svn.wordpress.org/trunk@37591 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-02 14:38:29 +00:00
Boone Gorges
0d4aa4df6c Remove unused variable from get_terms().
Missed in [37572]. See #35381.

Props JustinSainton.
See #36992.
Built from https://develop.svn.wordpress.org/trunk@37622


git-svn-id: http://core.svn.wordpress.org/trunk@37590 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-06-02 14:29:29 +00:00
Boone Gorges
477f6346eb Ensure that get_terms() can accept querystring-style arguments.
Prior to [37572], arguments passed to `get_terms()` were passed immediately
through `wp_parse_args()`, which made it possible to pass arguments as a
querystring (`hide_empty=0`) rather than an array
(`array( 'hide_empty' => false )`). [37572] moved default argument parsing
into `WP_Term_Query`, while assuming that arguments passed to `get_terms()`
would be formatted as an array.

To provide compatibility, we now parse all args passed to `get_terms()` into
an array before processing.

See #35381.
Built from https://develop.svn.wordpress.org/trunk@37599


git-svn-id: http://core.svn.wordpress.org/trunk@37567 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-31 12:54:29 +00:00
Boone Gorges
e64aa77090 Don't clear object relationship caches on term update.
Since [37573], object relationship caches (`{$taxonomy}_relationships`)
contain term IDs rather than term objects. See #36814. As such, it's no longer
necessary to clear these caches when a term is updated; none of the data that's
changed on update (name, description, count, etc) is stored in the relationship
cache.

Fixes #36251.
Built from https://develop.svn.wordpress.org/trunk@37593


git-svn-id: http://core.svn.wordpress.org/trunk@37561 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-30 04:11:27 +00:00
Drew Jaynes
9feb4113a2 Docs: Remove unnecessary backtick-escaping around two function references in the DocBlock for get_object_term_cache().
Known classes, methods, and functions are now auto-linked and formatted in the Code Reference. :-)

See [37573]. See #36814.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37546 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-26 15:22:27 +00:00
Boone Gorges
d904eeb08a Pass the proper values to get_terms action.
* `$term_query` should be passed.
* Second and third params should come from the `$term_query->query_vars` array, so that they're fully parsed.

These changes were missed in [37572].

Props flixos90, sebastian.pisula.
See #35381.
Fixes #36951.
Built from https://develop.svn.wordpress.org/trunk@37576


git-svn-id: http://core.svn.wordpress.org/trunk@37544 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-26 14:56:29 +00:00
Boone Gorges
253686fae6 Store only term IDs in object term relationships caches.
Previously, objects containing all data about a term were stored in each
object's term cache. Besides being wasteful, this approach caused invalidation
issues, as when a modified term count required a flush for all objects
belonging to the term.

Backward compatibility is maintained for plugins that continue to put object
data directly into the `{$taxonomy}_relationships` cache bucket.

Fixes #36814.
Built from https://develop.svn.wordpress.org/trunk@37573


git-svn-id: http://core.svn.wordpress.org/trunk@37541 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-26 04:50:27 +00:00
Boone Gorges
df0c758e22 Introduce WP_Term_Query and use in get_terms().
`WP_Term_Query` is modeled on existing query classes, such as those used
for comments and users. It provides a more consistent structure for generating
term queries, and should make it easier to add new functionality in the future.

Props flixos90, boonebgorges.
See #35381.
Built from https://develop.svn.wordpress.org/trunk@37572


git-svn-id: http://core.svn.wordpress.org/trunk@37540 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-26 04:33:30 +00:00
Boone Gorges
267cc99293 Fix termmeta pre-fetching in wp_get_object_terms().
[34529] introduced logic intended to prime the termmeta cache for certain
values of the `fields` parameter. There were a few bugs:

* The `all_with_object_id` param was misspelled.
* `term_id` was used instead of `ids`.
* The values being passed to `update_termmeta_cache()` in the case where `fields=ids` was not correct.

All of these would result in a failure to pre-fetch termmeta in some cases.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37535 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-25 18:44:29 +00:00
Drew Jaynes
9193013158 Docs: Apply inline @see tags to hooks referenced in DocBlocks in a variety of wp-includes/* files.
Applying these specially-crafted `@see` tags allows the Code Reference parser to recognize and link these elements as actions and filters.

Fixes #36921.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37512 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-23 19:02:28 +00:00
Drew Jaynes
ee2fb51f3a Docs: Standardize filter docs in wp-includes/taxonomy.php to use third-person singular verbs per the inline documentation standards for PHP.
See #36913.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37474 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-22 18:32:53 +00:00
Drew Jaynes
b1804afeaf Docs: Standardize on 'backward compatibility/compatible' nomenclature in core inline docs.
Also use 'back-compat' in some inline comments where backward compatibility is the subject and shorthand feels more natural.

Note: 'backwards compatibility/compatibile' can also be considered correct, though it's primary seen in regular use in British English.

Props ocean90.
Fixes #36835.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37397 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-13 18:41:31 +00:00
Drew Jaynes
fe3b007fdd Docs: Remove inline @see tags from function, class, and method references in inline docs.
Known functions, classes, and methods are now auto-linked in Code Reference pages following #meta1483.

Note: Hook references are still linked via inline `@see` tags due to the unlikelihood of reliably matching for known hooks based on a RegEx pattern.

See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37308 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-05-02 04:00:28 +00:00
Nikolay Bachiyski
b4d97cc8a7 Taxonomies: make sure taxonomy functions work correctly with taxonomy names with special characters
The codex says that taxonomy names "should only contain lowercase letters and the underscore character", but that's not enforced. It's too late to enforce it, since some plugins haven't been following it and the official phpdoc doesn't mention this restriction.

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


git-svn-id: http://core.svn.wordpress.org/trunk@37100 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-30 17:13:28 +00:00
Drew Jaynes
c29baeb9b8 Docs: Improve changelog entries added for the delete_term and delete_{$taxonomy} actions in [36080] and a third entry added for the clean_term_cache action in [36399]
See #35213, #35611. See #35986.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36930 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-10 22:07:27 +00:00
Drew Jaynes
f83488a058 Docs: Improve the summary and return description in the DocBlock for unregister_taxonomy(), introduced in [36243].
See #35227. See #35986.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36929 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-10 22:02:26 +00:00
Boone Gorges
e032560e6b Correct @return annotation for wp_set_object_terms() and related functions.
The return value is an array of term taxonomy IDs, not term IDs.

Fixes #36182.
Built from https://develop.svn.wordpress.org/trunk@36896


git-svn-id: http://core.svn.wordpress.org/trunk@36864 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-03-09 16:17:28 +00:00
John Blackbourn
d0044e1644 Docs: Improve the description of the get_object_taxonomies() function. Uncertainty has no place in documentation.
See #32246

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


git-svn-id: http://core.svn.wordpress.org/trunk@36679 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-25 21:25:25 +00:00
Dominik Schilling
e5ea82d81a Spelling: Standardize on "front end"/"back end" (noun) and "front-end"/"back-end" (adjective).
Props obrienlabs, thewanderingbrit.
Fixes #34887.
Built from https://develop.svn.wordpress.org/trunk@36709


git-svn-id: http://core.svn.wordpress.org/trunk@36676 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-25 12:53:27 +00:00
Boone Gorges
b694240cd9 Improve 'offset' calculation when querying for hierarchical terms.
When querying for terms in hierarchical taxonomies, `get_terms()` initially
queries for all matching terms, and then trims the located results based on the
`$number` and `$offset` arguments passed to the function. See #8832. However,
a flaw in the original logic meant that results were failing to be trimmed
properly in cases where `$offset` exceeds the total number of matching terms;
in these cases, we should force an empty array.

Props danielbachhuber.
Fixes #35935.
Built from https://develop.svn.wordpress.org/trunk@36691


git-svn-id: http://core.svn.wordpress.org/trunk@36658 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-24 19:13:26 +00:00
Boone Gorges
c5b77145a8 Docs: Improve description of get_term() return value.
Props sebastian.pisula.
Fixes #35919.
Built from https://develop.svn.wordpress.org/trunk@36634


git-svn-id: http://core.svn.wordpress.org/trunk@36601 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-23 16:48:25 +00:00
Boone Gorges
3f7441d674 Allow get_terms() to fetch terms regardless of taxonomy.
`get_terms()` has historically required that a taxonomy be specified when
querying terms. This requirement is related to the fact that terms could
formerly be shared between taxonomies, making `$taxonomies` critical for
disambiguation. Since terms can no longer be shared as of 4.4, it'
s desirable to be able to query for terms regardless of what taxonomy they're in.

Because it's now optional to pass taxonomies, it's no longer necessary to have
`$taxonomies` as the first (and required) parameter for `get_terms()`. The new
function signature is `get_terms( $args )`, where 'taxonomy' can (optionally) be
passed as part of the `$args` array. This syntax is more consistent with
functions like `get_users()` and `get_posts()`.

We've maintained backward compatibility by always giving precedence to the old
argument format. If a second parameter is detected, or if it's detected that
the first parameter is a list of taxonomy names rather than an `$args` array,
`get_terms()` will parse the function arguments in the legacy fashion.

Props flixos90, swissspidy, DrewAPicture, boonebgorges.
Fixes #35495.
Built from https://develop.svn.wordpress.org/trunk@36614


git-svn-id: http://core.svn.wordpress.org/trunk@36581 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-22 22:17:26 +00:00
Boone Gorges
fce93c4771 In get_terms(), assemble WHERE conditions in an array instead of concatenating.
This method is more reliable when adding new `WHERE` conditions.

See #35495.
Built from https://develop.svn.wordpress.org/trunk@36598


git-svn-id: http://core.svn.wordpress.org/trunk@36565 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-20 20:04:26 +00:00
Boone Gorges
84350eb6b6 Add changelog entry for publicly_queryable argument in register_taxonomy().
Missed in [36525].

Fixes #34491.
Built from https://develop.svn.wordpress.org/trunk@36564


git-svn-id: http://core.svn.wordpress.org/trunk@36531 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-17 22:04:32 +00:00
Boone Gorges
48b8ea78da Introduce publicly_queryable taxonomy argument.
Taxonomies registered as `publicly_queryable` can be queried as taxonomy
archives.

If not provided explicitly, the value of `publicly_queryable` is inherited
from `public`.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36492 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-13 03:51:26 +00:00
Boone Gorges
0e27fdcc47 Bail from get_term() if a filter returns an object that is not a WP_Term.
This prevents fatal errors in certain cases.

Props tmuikku.
Fixes #35808.
Built from https://develop.svn.wordpress.org/trunk@36516


git-svn-id: http://core.svn.wordpress.org/trunk@36483 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-12 14:26:27 +00:00
Boone Gorges
dae31f7d95 Remove unused variable from get_terms().
Unused since [31284].

Props TimothyBlynJacobs.
Fixes #35784.
Built from https://develop.svn.wordpress.org/trunk@36508


git-svn-id: http://core.svn.wordpress.org/trunk@36475 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-11 04:33:29 +00:00
Boone Gorges
fe1dd15126 Allow get_terms() results to ordered by metadata.
The `$orderby` parameter of `get_terms()` now accepts the following values,
related to term meta:

* 'meta_value'
* 'meta_value_num'
* the value of the `$meta_key` parameter
* any key from the `$meta_query` array

This brings order-by-meta support for terms in line with post, comment, and
user queries.

As a byproduct of these improvements, `$meta_key` and `$meta_value` parameters
have been introduced to `get_terms()`. They interact with `$meta_query` in the
same way as in `WP_Query` and other query classes.

Props jadpm, eherman24.
Fixes #34996.
Built from https://develop.svn.wordpress.org/trunk@36485


git-svn-id: http://core.svn.wordpress.org/trunk@36452 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-02-06 04:42:26 +00:00
Boone Gorges
ced24390f9 Normalize 'clean_term_cache' docs formatting after [36399].
Built from https://develop.svn.wordpress.org/trunk@36400


git-svn-id: http://core.svn.wordpress.org/trunk@36367 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-26 02:19:26 +00:00
Boone Gorges
32e5795042 Pass $clean_taxonomy param to 'clean_term_cache' action.
Props spacedmonkey.
Fixes #35611.
Built from https://develop.svn.wordpress.org/trunk@36399


git-svn-id: http://core.svn.wordpress.org/trunk@36366 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-26 02:18:26 +00:00
Drew Jaynes
3fc149d9ee Docs: Fix parameter documentation ordering in the hook docs for the register_taxonomy_args filter.
See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36358 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-25 17:11:27 +00:00
Sergey Biryukov
6699b761e1 Docs: Remove redundant PHP tags from get_object_taxonomies() description.
Props dotancohen.
Fixes #35553.
Built from https://develop.svn.wordpress.org/trunk@36377


git-svn-id: http://core.svn.wordpress.org/trunk@36344 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-22 02:41:26 +00:00
Boone Gorges
60a9f41315 Don't double-escape the 'name' param in get_terms().
[32353] changed the way the 'name' param in `get_terms()` is sanitized, by
running it through `sanitize_term_field( 'name' )` before performing the SQL
query. An unintentional side effect of this change was that the string is
double-escaped: once by `wp_filter_kses()`, and once by `esc_sql()`. The
double-escaping was causing 'name' queries to fail when the param contained
apostrophes or other escaped characters.

Fixes #35493.
Built from https://develop.svn.wordpress.org/trunk@36348


git-svn-id: http://core.svn.wordpress.org/trunk@36315 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-19 04:10:25 +00:00
Boone Gorges
d5bc0fe493 Populate term cache with proper clone of term objects.
[34999] modified the cache strategy for terms in the context of
`wp_get_object_terms()`. As part of these changes, the `object_id` property of
term objects had to be unset before being cached. To avoid modifying passed-by-
reference terms, `update_term_cache()` attempted to make a copy of the terms
passed to the function; however, it failed to use the `clone` keyword, and thus
only created a reference instead of a copy.

Props berengerzyla.
Fixes #35462.
Built from https://develop.svn.wordpress.org/trunk@36323


git-svn-id: http://core.svn.wordpress.org/trunk@36290 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-15 19:35:26 +00:00
Boone Gorges
909470db67 Don't reset index keys when trimming results of term queries.
`array_slice()` must be told to preserve keys when the query results exceed the
limit specified the 'number' parameter, so that `id=>parent` and other
id-indexed return value formats don't get mangled.

Props fantasyworld, wpdelighter.
Fixes #35382.
Built from https://develop.svn.wordpress.org/trunk@36252


git-svn-id: http://core.svn.wordpress.org/trunk@36219 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-10 04:06:25 +00:00
Pascal Birchler
2e4210e209 Taxonomy: Use Invalid taxonomy instead of Invalid Taxonomy for error strings.
Built from https://develop.svn.wordpress.org/trunk@36244


git-svn-id: http://core.svn.wordpress.org/trunk@36211 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-09 15:16:25 +00:00
Pascal Birchler
710501dc53 Taxonomy: Introduce unregister_taxonomy().
This new function can be used to completely unregister non built-in taxonomies.

Fixes #35227.
Built from https://develop.svn.wordpress.org/trunk@36243


git-svn-id: http://core.svn.wordpress.org/trunk@36210 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-09 14:58:26 +00:00
Boone Gorges
0e0c6a7ee7 Ensure 'description' is a string in wp_insert_term().
Passing `'description' => null` when creating a term can cause MySQL notices,
as the description column in the terms table does not allow for null values.
We correct this by intepreting a `null` description as an empty string.

Props TimothyBlynJacobs.
Fixes #35321.
Built from https://develop.svn.wordpress.org/trunk@36214


git-svn-id: http://core.svn.wordpress.org/trunk@36181 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2016-01-07 03:32:28 +00:00
Boone Gorges
eefe6b0779 Force non-public taxonomies to have a query_var of false.
[35333] implemented `public=false` for taxonomies. The implementation prevented
non-public taxonomies from having their archives accessed via query_var during
a normal request. But it didn't prevent non-public taxonomies from registering
their query vars in the `$wp_taxonomies` global. The latter implementation
details causes problems specifically when a taxonomy is registered with
`query_var=true`; for public taxonomies, `register_taxonomy()` translates this
into a query_var equivalent to the taxonomy name, but in the case of non-public
taxonomies, the query_var was set to the boolean itself. The boolean then
causes problems when using non-strict comparison to filter taxonomy objects by
query_var, as when using `get_taxonomies()`.

This changeset addresses the issue by forcing the query_var property of
non-public taxonomies to `false`.

Fixes #35089.
Built from https://develop.svn.wordpress.org/trunk@36108


git-svn-id: http://core.svn.wordpress.org/trunk@36073 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-27 16:41:27 +00:00
Konstantin Obenland
8c72912432 Taxonomy: Pass object ids to delete_* actions.
Allows for more targeted updates to affected posts in callbacks.
Disambiguates `$objects` variable and amends unit tests.

Fixes #35213.

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


git-svn-id: http://core.svn.wordpress.org/trunk@36045 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-23 23:44:26 +00:00
Boone Gorges
303efba1ec Respect $_wp_suspend_cache_invalidation in clean_object_term_cache().
Props mwidmann.
Fixes #35208.
Built from https://develop.svn.wordpress.org/trunk@36076


git-svn-id: http://core.svn.wordpress.org/trunk@36041 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-23 19:29:28 +00:00
Boone Gorges
e638f72a9a Order terms by 'name' when populating object term cache.
[34217] removed the `ORDER BY` clause from `update_object_term_cache()`, for
improved performance. But this proved to cause problems in cases where users
were expecting the results of `get_the_terms()` to be ordered by 'name'. Let's
revert the change for the time being, and look into more disciplined ordering
in a future release.

Props afercia.
See #28922. Fixes #35180.
Built from https://develop.svn.wordpress.org/trunk@36056


git-svn-id: http://core.svn.wordpress.org/trunk@36021 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-22 01:51:28 +00:00
Boone Gorges
5d46c03508 Ensure get_terms() results are unique when using 'meta_query'.
The introduction of 'meta_query' to `get_terms()` in 4.4 made it possible for
`get_terms()` to erroneously return duplicate results. To address the issue,
we add the `DISTINCT` keyword to the SQL query when a 'meta_query' parameter
has been provided.

Props @jadpm.
Fixes #35137.
Built from https://develop.svn.wordpress.org/trunk@36003


git-svn-id: http://core.svn.wordpress.org/trunk@35968 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-18 17:44:25 +00:00
John Blackbourn
6bb33fb2f4 Add a missing @param doc to wp_update_term_count().
See #32246

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


git-svn-id: http://core.svn.wordpress.org/trunk@35871 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-14 02:04:26 +00:00
John Blackbourn
e059193943 Remove a redundant @param tag from the_taxonomies().
See #32246

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


git-svn-id: http://core.svn.wordpress.org/trunk@35870 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-14 02:02:27 +00:00
Sergey Biryukov
8ad27a1405 Docs: Improve documentation for wp_count_terms().
Props bordoni, swissspidy.
Fixes #34861.
Built from https://develop.svn.wordpress.org/trunk@35895


git-svn-id: http://core.svn.wordpress.org/trunk@35859 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-13 12:11:27 +00:00
Drew Jaynes
c06143270e Docs: Document the optional $args parameter in wp_delete_term() in the hash notation style.
Props slushman, swissspidy.
Fixes #34862.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35853 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-12-12 16:27:27 +00:00
Sergey Biryukov
bc1e479fd0 After [35718], update the location of some files in This filter is documented in docs.
Partially reverts [33954].

Fixes #33413.
Built from https://develop.svn.wordpress.org/trunk@35725


git-svn-id: http://core.svn.wordpress.org/trunk@35689 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-11-22 03:51:28 +00:00
Andrew Nacin
1579e45d41 Simplify the include graph after work to split out classes.
see #33413. More details there.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-11-20 07:24:30 +00:00
Boone Gorges
623e467712 Introduce WP_Term.
`get_term()` now returns a `WP_Term` object, instead of a `stdClass` object.
Cache support and sanitization filters for individual terms are now more
centralized. For example, `get_term_by()` is able to cast results of its query
to a `WP_Term` object by passing it through `get_term()`.

The `$taxonomy` parameter for `get_term()` is now optional, as terms ought to
be unique to a taxonomy (ie, shared terms no longer exist). In cases where
`get_term()` detects that the term matching the specified term_id is from the
wrong taxonomy, it checks to see if you've requested a shared term, and if so,
it splits the term. This is used only for fallback purposes.

The elimination of shared terms allows the caching strategy for terms to be
simplified. Individual terms are now cached in a single 'terms' bucket.

Props flixos90, boonebgorges, scribu, dipesh.kakadiya.
See #14162.
Built from https://develop.svn.wordpress.org/trunk@34997


git-svn-id: http://core.svn.wordpress.org/trunk@34962 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-10 01:59:29 +00:00
Drew Jaynes
24180ac754 Docs: Clarify the file header summary for wp-includes/taxonomy.php, the top-level file for the core Taxonomy API.
See #33413. See #33701.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34368 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-22 13:23:25 +00:00
Scott Taylor
fa0dc526f4 Taxonomy: move WP_Tax_Query into its own file. taxonomy.php loads the new files, so this is 100% BC if someone is loading taxonomy.php directly. New files created using svn cp.
Creates: 
`class-wp-tax-query.php` 
`taxonomy-functions.php` 

`taxonomy.php` contains only top-level code. Class file only contains the class. Functions file only contains functions.

See #33413.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33728 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-26 12:49:21 +00:00
Dion Hulse
4f8ce1c232 Term Splitting: Switch to a faster cron unschedule process to benefit sites with thousands of affected jobs. Fix the cron hook name in the failsafe rescheduler.
Props Otto42, dd32, peterwilsoncc
See #33423

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


git-svn-id: http://core.svn.wordpress.org/trunk@33695 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-25 04:32:21 +00:00
Drew Jaynes
ea4f27f519 Docs: Add better documentation for all accepted values for the fields argument in get_terms().
See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-23 17:40:24 +00:00
Boone Gorges
dc0e7671b0 In wp_delete_term(), the $deleted_term object passed to filters should be generated before term relationships are deleted.
This allows the `count` property to reflect the pre-delete state of affairs,
rather than always being 0.

Props nicholas_io.
Fixes #33485.
Built from https://develop.svn.wordpress.org/trunk@33711


git-svn-id: http://core.svn.wordpress.org/trunk@33678 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-22 19:43:26 +00:00
Boone Gorges
bc592af91f wp_update_term() should return a true integer for 'term_taxonomy_id'.
Props ipm-frommen.
Fixes #32876.
Built from https://develop.svn.wordpress.org/trunk@33652


git-svn-id: http://core.svn.wordpress.org/trunk@33619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-19 19:33:24 +00:00
Dion Hulse
25c5d372d3 Term Splitting: Fix a reversal of parameters to wp_schedule_single_event() introduced in [33621].
The existing invalid cron entries will not be purged automatically (as the 'timestamp' is never matched) so we do this ourselves.

Props mechter for noticing!
See #30261.
Fixes #33423 for trunk.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33613 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-19 11:31:26 +00:00
Boone Gorges
52a7082d11 Don't suspend cache invalidation when running term splitting batch routine.
`wp_suspend_cache_invalidation()` was originally added to increase performance,
but the switch to batch processing in [33615] mitigates serious performance
concerns.

As a precaution against timeouts, the batch size has been reduced from 20 to 10.

Props Chouby.
See #30261.
Built from https://develop.svn.wordpress.org/trunk@33619


git-svn-id: http://core.svn.wordpress.org/trunk@33586 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-15 19:25:26 +00:00
Boone Gorges
151d27369d Term splitting routine should be run in a separate process, triggered via wp-cron.
[32814] introduced a routine to split shared terms, which was run during the
regular WP database upgrade. This turned out to be problematic because plugins
are not loaded during the db upgrade (due to `WP_INSTALLING`), with the result
that plugins were not able to hook into the 'split_shared_term' action during
the bulk split. We work around this limitation by moving the term splitting
routine to a separate process, triggered by a wp-cron hook.

Props boonebgorges, Chouby, peterwilsoncc, pento, dd32.
Fixes #30261.
Built from https://develop.svn.wordpress.org/trunk@33615


git-svn-id: http://core.svn.wordpress.org/trunk@33582 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-14 03:59:26 +00:00
Boone Gorges
2c9e81349c When splitting a shared 'nav_menu' term, ensure that nav items and theme locations are retained.
Props boonebgorges, dd32.
Fixes #33187.
Built from https://develop.svn.wordpress.org/trunk@33611


git-svn-id: http://core.svn.wordpress.org/trunk@33578 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-08-12 14:07:26 +00:00
Drew Jaynes
137357b769 Fix formatting in the DocBlock for _split_shared_term().
See #32246. See #32891.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33210 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-13 21:57:24 +00:00
Boone Gorges
b1bd2e699d Don't allow $field param to be passed to get_term_link().
The new parameter creates inconsistencies in the signatures of the various
functions for fetching term links (`get_term_feed_link()`,
`get_edit_term_link()`, etc.).

Reverts [32553].

See #14156.
Built from https://develop.svn.wordpress.org/trunk@33022


git-svn-id: http://core.svn.wordpress.org/trunk@32993 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-07-01 12:54:25 +00:00
John Blackbourn
b5973e92ec Introduce a no_terms label for taxonomies. This label is used when indicating that there are no terms in the given taxonomy associated with an object.
Fixes #32150
Props afercia

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


git-svn-id: http://core.svn.wordpress.org/trunk@32904 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-25 00:16:27 +00:00
Boone Gorges
03be8647c5 Fix PHP notice in WP_Tax_Query::get_sql_for_clause().
Previously, the `$where` variable was not initialized, so that when an invalid
'operator' was passed, PHP would complain that `$where` was undefined.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32881 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-23 12:44:27 +00:00
Scott Taylor
5e994cd6a1 Customizer et al, use elseif in PHP, not else if.
This was corrected via brute force in [31090].

See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32845 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-19 22:01:25 +00:00
Boone Gorges
6105fca015 Add filters to wp_unique_term_slug().
This changeset adds two new filters:
* 'wp_unique_term_slug_is_bad_slug' lets developers control whether a test slug needs to be made unique, before the queries required to build a suffix are performed.
* 'wp_unique_term_slug' filters the output of the function.

These changes introduce parity with the filters in `wp_unique_post_slug()`.

Props coffee2code, bolo1988, boonebgorges.
Fixes #20783.
Built from https://develop.svn.wordpress.org/trunk@32837


git-svn-id: http://core.svn.wordpress.org/trunk@32808 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-18 13:20:26 +00:00
Boone Gorges
cf7e00ed9f Performance enhancements for _split_shared_term().
* Introduce a `$record` parameter, which defaults to true. When set to false, `_split_shared_term()` will not keep a record of split term data in wp_options. The judicious use of this flag can greatly improve performance when processing shared terms in batches.
* Allow term/tt objects to be passed to the `$term_id` and `$term_taxonomy_id` parameters. This has the potential to save database queries when the objects are already available.

See #30261.
Built from https://develop.svn.wordpress.org/trunk@32813


git-svn-id: http://core.svn.wordpress.org/trunk@32784 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-17 01:48:28 +00:00
Boone Gorges
e8ad0ff400 Filter out empty object_types in register_taxonomy_for_object_type().
This prevents weird edge bugs when registering an existing taxonomy with an
object type when the taxonomy was previously associated with no object types.

Fixes #32590.
Built from https://develop.svn.wordpress.org/trunk@32709


git-svn-id: http://core.svn.wordpress.org/trunk@32679 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-06-08 19:45:31 +00:00
Scott Taylor
4777433584 Add missing doc blocks to taxonomy.php.
Correct some `@return` values.
Some functions can `return new WP_Error` without setting it to a variable.
Some functions can return their `apply_filters(...)` call without first setting it to a variable.
`is_object_in_taxonomy()` can return its conditional instead of if/else true/false.
 
See #32444.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32597 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-27 22:00:25 +00:00
Boone Gorges
10dd80cc61 Introduced $field argument to get_term_link().
This new argument allows developers to specify which term field should be
matched by the value of the `$term` parameter (in particular, 'name' and
'term_taxonomy_id' are now supported).

Props sudar, mordauk.
Fixes #14156.
Built from https://develop.svn.wordpress.org/trunk@32553


git-svn-id: http://core.svn.wordpress.org/trunk@32523 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-23 18:29:26 +00:00
Boone Gorges
63eb910445 Respect $_wp_suspend_cache_invalidation in clean_term_cache().
Props tollmanz, rmccue.
Fixes #28743.
Built from https://develop.svn.wordpress.org/trunk@32498


git-svn-id: http://core.svn.wordpress.org/trunk@32468 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-12 20:14:26 +00:00
Drew Jaynes
674e47cc89 Fix a wide variety of syntactical, spacing, wording, and other issues in wp-includes/taxonomy.php.
See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32423 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-07 20:37:41 +00:00
Drew Jaynes
3050d96310 Ensure the optional parameter in get_object_taxonomies() is documented as such.
See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32422 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-07 20:37:17 +00:00
Drew Jaynes
b801f6f230 Add a description to the hook documentation for the created_$taxonomy action to clarify the dynamic portion of the hook name.
See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32421 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-07 20:36:53 +00:00
Drew Jaynes
948186df0b Add missing parameter descriptions to the created_term hook documentation.
Props dlh.
Fixes #32276.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32420 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-07 20:36:29 +00:00
Boone Gorges
5c65164ea8 Improve sanitization of 'name' param in get_terms().
Values of 'name' that contain db-encoded character on insert - like an
ampersand, which is HTML-encoded in the database - will only match if they go
through the same `sanitize_term_field()` routine.

Fixes #32248.
Built from https://develop.svn.wordpress.org/trunk@32353


git-svn-id: http://core.svn.wordpress.org/trunk@32324 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-05 11:14:28 +00:00
Drew Jaynes
a3b092843b Add a changelog entry for the $resource_type parameter added to the get_ancestors filter in 4.1.1.
Props dimadin.
See #31925.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32322 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-05 02:17:25 +00:00
Drew Jaynes
39064bac5e Ensure the optional parameters for get_taxonomies() are documented as such.
See #31800.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32320 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-05 02:05:24 +00:00
Drew Jaynes
6c9b20f94c Improve inline documentation in wp-includes/taxonomy.php.
* Adds missing `@since` versions
* Adds `@global` tags and descriptions to DocBlocks where appropriate

Props ChaseWiseman.
See #31800.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-05-05 02:01:25 +00:00
Boone Gorges
af6b4cba24 Remove duplicate semicolon introduced in [32326].
Built from https://develop.svn.wordpress.org/trunk@32327


git-svn-id: http://core.svn.wordpress.org/trunk@32298 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-29 12:58:24 +00:00
Boone Gorges
a20841bc36 Improve performance of loop detection in _get_term_children().
Using an array keyed by term_id allows us to use `isset()` rather than the
slower `in_array()`. In addition, it lets us avoid the use of `wp_list_pluck()`
on large arrays, and helps us to avoid arrays that are unnecessarily large due
to duplicate entries.

Fixes #32144 for trunk.
Built from https://develop.svn.wordpress.org/trunk@32326


git-svn-id: http://core.svn.wordpress.org/trunk@32297 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-29 12:56:25 +00:00
Sergey Biryukov
35c0c59123 Add missing word to wp_insert_term() error strings.
props dipesh.kakadiya.
fixes #32031.
Built from https://develop.svn.wordpress.org/trunk@32297


git-svn-id: http://core.svn.wordpress.org/trunk@32268 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-26 11:50:26 +00:00
Sergey Biryukov
55a1de9b4f wp_update_term() should check if get_term() returned null.
props dlh.
fixes #31954.
Built from https://develop.svn.wordpress.org/trunk@32117


git-svn-id: http://core.svn.wordpress.org/trunk@32096 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-13 01:21:27 +00:00
Drew Jaynes
d9bfc88b8d Fix a variety of inline documentation syntactical issues in wp-includes/taxonomy.php.
See #31888.

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


git-svn-id: http://core.svn.wordpress.org/trunk@32026 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-04-05 17:08:26 +00:00
Drew Jaynes
cedee3dd1c Supplement hook documentation for the get_terms_fields filter to more clearly explain the expected consequences of using it to modify the fields to select in a terms query.
Props boonebgorges.
Fixes #31174.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31834 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-20 20:11:26 +00:00
Boone Gorges
0b85f2f7b4 Ensure that the $exclusions parameter of 'list_terms_exclusions' filter is always a string.
Props fhwebcs.
Fixes #31681.
Built from https://develop.svn.wordpress.org/trunk@31813


git-svn-id: http://core.svn.wordpress.org/trunk@31795 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-18 18:23:26 +00:00
Boone Gorges
650ca95b95 In wp_insert_term(), allow a term with an existing name if a unique $slug has been provided.
`wp_insert_term()` protects against the creation of terms with duplicate names
at the same level of a taxonomy hierarchy. However, it's historically been
possible to override this protection by explicitly providing a value of `$slug`
that is unique at the hierarchy tier. This ability was broken in [31734], and
the current changeset restores the original behavior.

A number of unit tests are added and refactored in support of these changes.

See #17689 for discussion of a fix that was superceded by [31734]. This commit
retains the fix for the underlying bug described in that ticket.

See #31328.
Built from https://develop.svn.wordpress.org/trunk@31792


git-svn-id: http://core.svn.wordpress.org/trunk@31774 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-16 11:16:28 +00:00
Gary Pendergast
03ade8c011 Add emoji URL support, and Twemoji fallback for displaying slugs in wp-admin, when the browser doesn't natively support emoji.
Props pento, SergeyBiryukov and boonebgorges.

Fixes #31328


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


git-svn-id: http://core.svn.wordpress.org/trunk@31715 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-11 22:55:28 +00:00
Drew Jaynes
6486a233c0 Remove a duplicate mention of the default value for the $number argument in get_terms().
Props iandunn.
Fixes #31526.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31633 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-07 01:05:26 +00:00
Boone Gorges
3acf36fe48 Ensure that an array of object IDs is passed to the 'get_object_terms' filter.
Originally introduced in [31581].

Props doublesharp.
Fixes #18828.
Built from https://develop.svn.wordpress.org/trunk@31639


git-svn-id: http://core.svn.wordpress.org/trunk@31620 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-06 13:18:26 +00:00
Drew Jaynes
68bbc0e43d Correct the $number argument description in get_terms() to reflect that an empty string or 0 will return all possible results, not -1.
Previously, it was noted that -1 would return all possible results. However, as the value of `$number` is passed through `absint()`, -1 would actually be converted to 1, thereby producing unexpected results.

Props iandunn.
Fixes #31526.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31619 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-03-06 08:05:25 +00:00
Boone Gorges
3db78d6a24 Introduce 'get_object_terms' filter in wp_get_object_terms().
The existing 'wp_get_object_terms' filter accepts a parameter `$taxonomies`,
which is a list of taxonomy names formatted for direct use in a MySQL IN clause.
This formatting makes it difficult to make use of the taxonomy list in filter
callbacks. However, changing the parameters passed to the existing filter
raises backward compatibility concerns, so we introduce a new filter that
receives a structured `$taxonomy_array` parameter.

We also take this opportunity to correct and clean up some of the documentation
on the 'wp_get_object_terms' filter.

Props postpostmodern, doublesharp, wonderboymusic, nacin.
Fixes #18828.
Built from https://develop.svn.wordpress.org/trunk@31581


git-svn-id: http://core.svn.wordpress.org/trunk@31562 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-27 20:31:26 +00:00
Boone Gorges
0d9275930b Add 'orderby=description' support to get_terms().
This fixes an interface inconsistency in edit-tags.php, where Description
appears as a sortable column header.

Props neil_pie.
Fixes #31364.
Built from https://develop.svn.wordpress.org/trunk@31532


git-svn-id: http://core.svn.wordpress.org/trunk@31513 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-24 16:37:26 +00:00
Boone Gorges
e89d237b86 Pass taxonomy name, not object, to 'edit_term_taxonomy' and 'edited_term_taxonomy' actions.
These actions are fired in a number of different places, and in some cases
the tax name is passed, while in others the taxonomy object is passed. This
inconsistency made it difficult for plugins to use the `$taxonomy` value.

Props ipm-frommen.
Fixes #30999.
Built from https://develop.svn.wordpress.org/trunk@31525


git-svn-id: http://core.svn.wordpress.org/trunk@31506 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-23 21:08:26 +00:00
John Blackbourn
948f657ea3 Return a WP_Error if an empty name is provided when registering a taxonomy.
Fixes #31135
Props tyxla, MikeHansenMe

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


git-svn-id: http://core.svn.wordpress.org/trunk@31430 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-13 16:27:26 +00:00
Boone Gorges
44ac816aed Split shared taxonomy terms on term update.
When updating an existing taxonomy term that shares its `term_id` with
another term, we generate a new row in `wp_terms` and associate the updated
term_taxonomy_id with the new term. This separates the terms, such that
updating the name of one term does not change the name of any others.

In cases where a plugin or theme stores term IDs in the database, term splitting
can cause backward compatibility issues. The current changeset introduces
two utilities to aid developers with the transition. The `'split_shared_term'`
action fires when the split takes place, and should be used to catch changes in
term_id. In cases where `'split_shared_term'` cannot be used, the
`wp_get_split_term()` function gives developers access to data about terms
that have previously been split. Documentation for these functions, with
examples, can be found in the Plugin Developer Handbook. WordPress itself
stores term IDs in this way in two places; `_wp_check_split_default_terms()`
and `_wp_check_split_terms_in_menus()` are hooked to `'split_shared_term'` to
perform the necessary cleanup.

See [30241] for a previous attempt at the split. It was reverted in [30585]
for 4.1.0.

Props boonebgorges, mboynes.
See #5809.
Built from https://develop.svn.wordpress.org/trunk@31418


git-svn-id: http://core.svn.wordpress.org/trunk@31399 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-11 19:42:25 +00:00
Boone Gorges
669fa39005 Late escaping in get_terms() and WP_Tax_Query.
Props vortfu, dd32.
Built from https://develop.svn.wordpress.org/trunk@31367


git-svn-id: http://core.svn.wordpress.org/trunk@31348 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-08 01:59:24 +00:00
Sergey Biryukov
09c1d34b96 Remove unnecessary array_shift() usage in get_terms() for better performance.
props bswatson, VolodymyrC.
fixes #31182.
Built from https://develop.svn.wordpress.org/trunk@31365


git-svn-id: http://core.svn.wordpress.org/trunk@31346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-07 19:45:25 +00:00
Boone Gorges
7560f446f9 Use field-specific sanitization in WP_Tax_Query::transform_query().
When terms are entered into the database, term fields are sanitized with
`sanitize_term_field()`. To ensure that the `SELECT ... WHERE` queries in
`WP_Tax_Query::transform_query()` are not broken by overzealous sanitization,
`sanitize_term_field()` should be used in that case as well. This fixes a bug
where a tax_query using 'field=name' would fail if the 'terms' parameter
contained characters (like spaces) that were improperly removed by
`sanitize_title_for_query()`.

Fixes #27810.
Built from https://develop.svn.wordpress.org/trunk@31346


git-svn-id: http://core.svn.wordpress.org/trunk@31327 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-02-06 02:02:23 +00:00
Boone Gorges
abce542e5f Introduce 'show_in_quick_edit' parameter for register_taxonomy().
Setting 'show_in_quick_edit' to false when registering a custom taxonomy will
hide the taxonomy when editing posts using Quick Edit.

The new 'quick_edit_show_taxonomy' filter allows this behavior to be filtered
on a finer scale, as when you want a given taxonomy to be hidden for one post
type but not for others.

Props hlashbrooke.
Fixes #26948.
Built from https://develop.svn.wordpress.org/trunk@31307


git-svn-id: http://core.svn.wordpress.org/trunk@31288 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-30 19:18:23 +00:00
Boone Gorges
dcca015ffc Don't use term IDs for array indexes when caching object terms.
Uncached results pulled from `wp_get_object_terms()` are zero-indexed (ie 0,
1, 2...). As a result, `get_the_terms()` was returning a strictly different
array when pulling from the cache and when the cache was empty.

Props joshlevinson.
Fixes #31086.
Built from https://develop.svn.wordpress.org/trunk@31287


git-svn-id: http://core.svn.wordpress.org/trunk@31268 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-28 20:43:23 +00:00
Boone Gorges
e199d2420f Ensure that 'hierarchical' is respected in get_terms() when multiple taxonomies are passed.
Previously, attempts to descend the family tree of each term were done using
the first taxonomy in the `$taxonomies` array, with the result that terms not
belonging to that taxonomy were not found and their children not properly
parsed. We fix this bug by fetching each term's taxonomy with the SQL query,
and then using that taxonomy to get the correct children for each term.

Fixes #31118.
Built from https://develop.svn.wordpress.org/trunk@31285


git-svn-id: http://core.svn.wordpress.org/trunk@31266 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-26 19:04:21 +00:00
Boone Gorges
af6e0f5c55 Ensure that 'pad_counts' is not discarded when the first of multiple taxonomies passed to get_terms() is non-hierarchical.
See #31118.
Built from https://develop.svn.wordpress.org/trunk@31284


git-svn-id: http://core.svn.wordpress.org/trunk@31265 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-26 18:09:22 +00:00
Boone Gorges
acef0e2dcc In get_terms(), check hierarchy for all $taxonomies before bailing early from 'parent' or 'child_of'.
There is a pre-check in `get_terms()` that prevents an unnecessary database
query if the 'parent' or 'child_of' parameter is not found in the cached term
hierarchy (since a term without an index in the hierarchy cache has no
descendants). Previously, only the first item in the `$taxonomies` array was
being checked, with the result that an empty array was being erroneously
returned in cases where the 'parent' or 'child_of' term is in a subsequent
taxonomy.

See #31118.
Built from https://develop.svn.wordpress.org/trunk@31276


git-svn-id: http://core.svn.wordpress.org/trunk@31257 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-25 02:46:25 +00:00
Boone Gorges
43fceb39c0 Introduce 'childless' parameter to get_terms().
This new parameter allows developers to limit queried terms to terminal nodes -
ie, those without any descendants.

As part of the improvement, some internal logic in `get_terms()` has been
consolidated. Parameters that resolve to a NOT IN clause containing term IDs
('exclude', 'exclude_tree', and 'childless') are now parsed into a single
"exclusions" array before the SQL clause is generated.

Props theMikeD, horike.
Fixes #29839.
Built from https://develop.svn.wordpress.org/trunk@31275


git-svn-id: http://core.svn.wordpress.org/trunk@31256 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-24 18:48:23 +00:00
Boone Gorges
d45a650846 Introduce 'parent' parameter to wp_get_object_terms().
Props mikeschinkel.
Fixes #15675.
Built from https://develop.svn.wordpress.org/trunk@31270


git-svn-id: http://core.svn.wordpress.org/trunk@31251 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-23 14:57:22 +00:00
Boone Gorges
61f5f38dcd Better loop detection for _pad_term_counts().
The `$ancestors` check must be reset for each term in order for term counts
to be correct.

Fixes #20635.
Built from https://develop.svn.wordpress.org/trunk@31248


git-svn-id: http://core.svn.wordpress.org/trunk@31229 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-19 16:52:22 +00:00
Drew Jaynes
bee439858b Minor fix for inline doc syntax in a changelog entry for wp_get_object_terms().
See #28688.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31219 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-18 19:05:22 +00:00
Boone Gorges
a639c5905e Add @since annotation for 'orderby' values introduced in [31236].
See #28688.
Built from https://develop.svn.wordpress.org/trunk@31237


git-svn-id: http://core.svn.wordpress.org/trunk@31218 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-18 19:03:24 +00:00
Boone Gorges
42ec13030c Additional 'orderby' values for wp_get_object_terms().
Adds support for ordering by 'taxonomy', 'term_taxonomy_id', and 'parent'.

Props ChriCo.
Fixes #28688.
Built from https://develop.svn.wordpress.org/trunk@31236


git-svn-id: http://core.svn.wordpress.org/trunk@31217 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-18 18:57:23 +00:00
Boone Gorges
a245838c42 Correct wp_get_object_terms() documentation.
The 'orderby' parameter accepts a number of values that have never been
properly documented.
Built from https://develop.svn.wordpress.org/trunk@31232


git-svn-id: http://core.svn.wordpress.org/trunk@31213 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-17 20:39:23 +00:00
Boone Gorges
03512a2a02 Standardize the docblock for wp_get_object_terms().
The enumeration of the `$args` parameter has been moved from the long
description to an array hash associated with the proper `@param` attribute.
Built from https://develop.svn.wordpress.org/trunk@31231


git-svn-id: http://core.svn.wordpress.org/trunk@31212 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-17 20:09:47 +00:00
Scott Taylor
5458a4da21 wp_set_object_terms() takes $taxonomy as a string. Update @param.
See #30799.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31202 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-16 23:27:25 +00:00
Scott Taylor
eeda68bbda Fix some erroneous @param annotations.
See #30799.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31200 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-16 22:44:25 +00:00
Boone Gorges
35f3f7bf63 Bail out of hierarchy loops in _get_term_children().
This prevents infinite loops that lead to PHP nesting limit fatal errors.

Props boonebgorges, sgrant.
Fixes #24461.
Built from https://develop.svn.wordpress.org/trunk@31207


git-svn-id: http://core.svn.wordpress.org/trunk@31188 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-16 17:10:22 +00:00
Boone Gorges
991bfdebc1 Bail out of hierarchy loops in _pad_term_counts().
Taxonomy hierarchy loops should not occur naturally, but when they do, the
logic of `_pad_term_counts()` could result in infinite loops, leading to
timeouts. We avoid this by breaking when a loop is detected.

Fixes #20635.
Built from https://develop.svn.wordpress.org/trunk@31206


git-svn-id: http://core.svn.wordpress.org/trunk@31187 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-16 16:46:23 +00:00
Scott Taylor
fc843ce4d0 There are some random add_action() and add_filter() calls littered around some files in wp-includes/. These should be moved to wp-includes/default-filters.php with the rest of the registered hooks. It seems like this was the best practice for awhile and then we randomly stopped. This file loads way before any of the includes, so the hooks will be registered for any request that loads WordPress, even SHORTINIT - a lot of the hooks registered won't run anyways (that's already the case).
See #30947.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31149 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-12 16:40:23 +00:00
Scott Taylor
bc4cd01190 In wp-includes/taxonomy.php:
The keyword `elseif` should be used instead of `else if` so that all control keywords look like single words.

See #30799.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-08 06:26:23 +00:00
Scott Taylor
190165cb32 Use the 'not_found' label when there are no items for a taxonomy in the terms list table.
Props SergeyBiryukov.
Fixes #30586.

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


git-svn-id: http://core.svn.wordpress.org/trunk@31016 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-03 06:20:21 +00:00
Boone Gorges
1b63ada83d Introduce 'name' parameter for get_terms().
This enhancement requires a modification in the way that `wp_dropdown_categories()`
prepares its arguments for `get_terms()`, so that its unrelated 'name' param is
not mistaken for the new 'name' argument in `get_terms()`.

Props danielbachhuber.
Fixes #30611.
Built from https://develop.svn.wordpress.org/trunk@31024


git-svn-id: http://core.svn.wordpress.org/trunk@31005 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-01-02 21:34:23 +00:00
Scott Taylor
96558ac3c3 Update/fix inline docs for update_object_term_cache().
Props DrewAPicture.
Fixes #30731.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30993 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-31 18:12:26 +00:00
Sergey Biryukov
200ca064b0 Correct $taxonomies parameter description in get_terms() filters.
props dlh.
fixes #30851.
Built from https://develop.svn.wordpress.org/trunk@30994


git-svn-id: http://core.svn.wordpress.org/trunk@30976 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-28 01:44:24 +00:00
Boone Gorges
fb54c6d7c9 Pass $resource_type to 'get_ancestors' filter.
The `$resource_type` argument was added to the `get_ancestors()` function in
[30141]. In that changeset, the documentation for the filter was updated to
indicate that it would receive `$resource_type` as a param, but the filter
itself was not updated accordingly.

Props tmatsuur, DrewAPicture.
Fixes #30843.
Built from https://develop.svn.wordpress.org/trunk@30993


git-svn-id: http://core.svn.wordpress.org/trunk@30975 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-26 21:29:22 +00:00
Boone Gorges
b806668e71 In wp_update_term(), limit duplicate slug checks to the same taxonomy as the updated term.
In 4.1 [30240], `wp_insert_term()` was modified to allow the creation of terms
with duplicate slugs, as long as the terms are in different taxonomies.
`wp_update_term()` didn't get the corresponding modification, with the result
that term updates fail when the term being updated shares a slug with an older
term, regardless of that older term's taxonomy.

Props ipm-frommen.
Fixes #30780 for trunk.
Built from https://develop.svn.wordpress.org/trunk@30985


git-svn-id: http://core.svn.wordpress.org/trunk@30971 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-22 15:33:25 +00:00
Scott Taylor
5eb5afac34 For clarity, initialize some arrays that previously were only assigned via short circuit in loops.
See #30799.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30968 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-20 22:47:22 +00:00
Boone Gorges
e1ebba28d4 Update individual term caches in get_terms().
This was removed in [29915] as part of the attempt to add cache support to
`get_term_by()`. When that support was removed in [30900], it was not properly
restored.

This changeset includes a unit test to verify that the cache is properly primed
for terms found in `get_terms()`, as well as tests to verify the other cache
setting that was touched by [30900].

Fixes #30749. See #21760.
Built from https://develop.svn.wordpress.org/trunk@30954


git-svn-id: http://core.svn.wordpress.org/trunk@30942 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-17 16:39:24 +00:00
Boone Gorges
6ebb326c54 Remove caching for get_term_by() calls.
The new cache group scheme causes term invalidation to be overly broad, so
that busting the cache for one term will bust the cache for all terms in the
taxonomy. We'll have another go at more focused use of the 'last_changed'
incrementor in a future release.

Reverts [29915], [30073], [30080], [30108], [30112].
See #21760.
Built from https://develop.svn.wordpress.org/trunk@30900


git-svn-id: http://core.svn.wordpress.org/trunk@30890 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-16 13:27:22 +00:00
Drew Jaynes
337dfe7111 Restore missing line in DocBlock for WP_Tax_Query::get_sql_for_clause().
Props kpdesign.
See [30622], #30469.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30749 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-07 00:39:24 +00:00
Sergey Biryukov
1f64435284 Fix a typo in [30546].
see #30473.
Built from https://develop.svn.wordpress.org/trunk@30727


git-svn-id: http://core.svn.wordpress.org/trunk@30717 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-03 13:55:24 +00:00
Drew Jaynes
27297bcddf Use the correct hash notation syntax for the wp_insert_term() DocBlock.
See #28298.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-12-03 10:17:24 +00:00
Scott Taylor
ba914c7df1 Improve various @param docs.
See #30224.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30663 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-30 22:56:25 +00:00
Drew Jaynes
150f71e3e5 Docs Formatting: Backtick-escape inline code for all dynamic hook docs in wp-includes/taxonomy.php.
Affects DocBlocks for the following hooks:
* `get_$taxonomy`
* `edit_term_{$field}`
* `edit_{$taxonomy}_{$field}`
* `pre_term_{$field}`
* `pre_{$taxonomy}_{$field}`
* `term_{$field}_rss`
* `{$taxonomy}_{$field}_rss`
* `term_{$field}`
* `{$taxonomy}_{$field}`
* `delete_$taxonomy`
* `create_$taxonomy`
* `edit_$taxonomy`
* `edited_$taxonomy`

See #30552.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30644 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-30 12:00:23 +00:00
Drew Jaynes
ea1ee4369f 4.1 Docs Audit: Improve inline documentation in DocBlocks for various WP_Tax_Query methods, the pre_delete_term hook, and get_ancestors().
See #30469.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30612 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-28 12:26:24 +00:00
Boone Gorges
213ecc8a07 Revert shared taxonomy term splitting for 4.1.
This is a revert of [30494], [30492], [30347], and [30334]. The latter
changeset was a revert of [30336], which was a revert of [30241].

Watch for Term Splitting, Version III in version 4.2, coming soon to a
WordPress trunk near you.

See #30335, #5809.
Built from https://develop.svn.wordpress.org/trunk@30585


git-svn-id: http://core.svn.wordpress.org/trunk@30575 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-27 00:05:22 +00:00
Drew Jaynes
4b6abbaff4 Ensure inline code is markdown-escaped as such, HTML tags are removed from summaries, and that code snippets in descriptions are properly indented.
Affects DocBlocks for the following core elements:
* Backtick-escape code snippets in the description for `get_object_taxonomies()`
* Backtick-escape inline code in a markdown-formatted unordered list in the description for `get_taxonomy_labels()`
* Remove an HTML tag from the summary for the `Walker_Category_Checklist` class
* Remove an HTML tag from the summary for `wp_category_checklist()`, various formatting
* Remove an HTML tag from the summary for `wp_terms_checklist()`
* Backtick-escape an HTML tag in the description for `wp_popular_terms_checklist()`
* Remove HTML tags from the summaries for `page_template_dropdown()`, `parent_dropdown()`, and `wp_dropdown_roles()`
* Backtick-escape HTML tags in a parameter description for `add_settings_error()`
* Various formatting in the description and summary for `settings_errors()`
* Markdown-indent code snippets in the descriptions for `wpdb::prepare()`, `wpdb::insert()`, `wpdb::replace()`, `wpdb::update()`, and `wpdb::delete()`
* Backtick-escape an HTML tag in a parameter description for `login_header()`
* Remove HTML tags from the summaries for the `lostpassword_form` and `signup_header` hooks

Props rarst.
See #30473.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30535 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-24 06:31:21 +00:00
Boone Gorges
57e358da63 Improve cleanup of cached term_ids after shared terms are split.
* If the split term ID is stored as 'default_category', 'default_link_category', or 'default_email_category', update it to the new ID.
* If the split term ID is associated with a nav menu item, update that piece of postmeta to the new ID.

Props mboynes.
See #30335.
Built from https://develop.svn.wordpress.org/trunk@30494


git-svn-id: http://core.svn.wordpress.org/trunk@30483 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-21 03:17:22 +00:00
Boone Gorges
14e6c301ea Pass the taxonomy of the split tt_id to the 'split_shared_term' filter.
Props mboynes.
See #30335.
Built from https://develop.svn.wordpress.org/trunk@30493


git-svn-id: http://core.svn.wordpress.org/trunk@30482 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-21 03:14:23 +00:00
Boone Gorges
6f9eaf5df5 Store data about old and new term IDs when shared terms are split.
Props mboynes.
See #30335.
Built from https://develop.svn.wordpress.org/trunk@30492


git-svn-id: http://core.svn.wordpress.org/trunk@30481 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-21 03:13:22 +00:00
Dion Hulse
ddbb5a850f Remove a stray translator comment for a non-translatable string added in [30209] See #27238
Built from https://develop.svn.wordpress.org/trunk@30365


git-svn-id: http://core.svn.wordpress.org/trunk@30364 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-17 04:36:25 +00:00
Boone Gorges
866cfdf19b Flush cache for newly created term in _split_shared_term().
The term itself does not have any cached values yet, but in some cases the new
term's taxonomy may need its cached hierarchy to be refreshed as a result of
the term splitting.

Props jorbin.
See #30335.
Built from https://develop.svn.wordpress.org/trunk@30347


git-svn-id: http://core.svn.wordpress.org/trunk@30346 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-14 21:53:22 +00:00
Boone Gorges
c5bb06dafe Reinstate term splitting on term update.
Originally introduced in [30241] and reverted in [30336], term splitting is
back and better than ever. Now with *more unit tests* and *improved treatment
of child terms*!

See #30335.
Built from https://develop.svn.wordpress.org/trunk@30344


git-svn-id: http://core.svn.wordpress.org/trunk@30343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-14 21:27:24 +00:00
Boone Gorges
eb8f89bb13 Don't split shared terms on term update.
Splitting shared terms means assigning a new term_id to a given term_taxonomy_id.
It was uncovered that this change could cause problems for sites that have
cached the original term_id somehow - say, in postmeta - since future lookups
using that term_id will now fail.

Removing for 4.1-beta1. We'll look at improvements to backward compatibility
to try to get this back into a later beta.

Props mboynes.
See #30335.
Built from https://develop.svn.wordpress.org/trunk@30336


git-svn-id: http://core.svn.wordpress.org/trunk@30335 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-13 20:05:24 +00:00
Boone Gorges
c357de63ef Don't force child_of=0 for non-hierarchical taxonomies in get_terms().
This forcing appears to have been introduced to save unnecessary queries, but
(a) in some cases it appeared to be causing *more* queries, and (b) it caused
incorrect results when the 'exclude_tree' param of `get_terms()` called
`get_terms()` on each item in the tree using the 'child_of' param.

Fixes #30275.
Built from https://develop.svn.wordpress.org/trunk@30265


git-svn-id: http://core.svn.wordpress.org/trunk@30265 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-06 21:47:23 +00:00
Boone Gorges
3706590afb Split shared taxonomy terms during term update.
When updating an existing taxonomy term that shares its `term_id` with
another term, we generate a new row in `wp_terms` and associate the updated
term_taxonomy_id with the new term. This separates the terms, such that
updating the name of one term does not change the name of any others.

Note that this term splitting only occurs on installations whose database
schemas have been upgraded to version 30133 or higher. Note also that shared
terms are only split when run through `wp_update_term()`, as on edit-tags.php;
we will wait until a future release of WordPress to force the splitting of all
shared taxonomy terms.

Props boonebgorges, rmccue, greuben, garyc40, wonderboymusic, imath, jesin.
Fixes #5809.
Built from https://develop.svn.wordpress.org/trunk@30241


git-svn-id: http://core.svn.wordpress.org/trunk@30241 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-05 02:03:23 +00:00
Boone Gorges
32db3d1fe5 Do not create shared taxonomy terms.
A "shared" term occurs when two entries in the `wp_term_taxonomy` table share a
single `term_id`, and thereby correspond to the same row in `wp_terms`. This
changeset stops the practice of creating shared terms: each new row in
`wp_term_taxonomy` will receive its own row in `wp_terms`. The new strategy
for term creation depends on whether the installation's database schema is up
to date for 4.1:

* If so, terms are allowed to be created with the same slug as an existing term, as long as they are in different taxonomies and do not share a parent. Thus, a new tag with the slug 'wordpress' can exist alongside a category with the slug 'wordpress'.
* If not, new terms will be forced to have unique slugs. Thus, on an installation containing a category with the slug 'wordpress', a new tag 'WordPress' will get the slug 'wordpress-2'.

Fixes #21950. See #5809.
Built from https://develop.svn.wordpress.org/trunk@30240


git-svn-id: http://core.svn.wordpress.org/trunk@30240 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-05 01:42:22 +00:00
Boone Gorges
ef13be6f27 Enforce ORDER BY and LIMIT clauses in term_exists() queries.
In case of edge cases where a duplicate term might exist in a replicated
database for a split second, these explicit query clauses ensure that
`term_exists()` will always recognize the oldest matched term as the
canonical one. See [30238] for background.

Props pento.
See #22023, #5809.
Built from https://develop.svn.wordpress.org/trunk@30239


git-svn-id: http://core.svn.wordpress.org/trunk@30239 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-05 01:09:21 +00:00