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
[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
[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
`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
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
[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
[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
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
`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
`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
[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
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
* 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
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
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