Commit Graph

922 Commits

Author SHA1 Message Date
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
Boone Gorges
4ce9db9ce8 In wp_insert_term(), clean up accidental duplicate terms after insert.
In [30056], the UNIQUE index was removed from the 'slug' column of `wp_terms`.
While we have numerous checks in place to avoid the creation of unwanted
duplicate term+term_taxonomy pairs, it's possible that in certain edge cases -
such as during the lag caused by database replication, or a race condition
involving near-simultaneous creation of more than one term - we'll end up
unwittingly inserting two identical rows.

The current changeset minimizes this risk by introducing a failsafe mechanism
into `wp_insert_term()`. After a term and term_taxonomy are INSERTed, we check
to see whether the term just created is a duplicate of an existing term; if so,
we delete the new one and keep the old one. This prevents problems caused by
replication lag, because SELECT queries that take place after an INSERT will
hit the master database; it mitigates race conditions by enforcing that the
term that was created first (ie, the one with the lowest `term_id`) is
always the "canonical" one.

Props nacin, markjaquith.
See #22023, #5809.
Built from https://develop.svn.wordpress.org/trunk@30238


git-svn-id: http://core.svn.wordpress.org/trunk@30238 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-05 01:00:24 +00:00
Boone Gorges
7919a6d812 Improve docblocks for get_the_taxonomies() and the_taxonomies().
* In `the_taxonomies()`, only document those arguments that are specific to the function. Arguments shared with `get_the_taxonomies()` should be documented in the later function's docblock.
* Add $args hash documentation to `get_the_taxonomies()`.
* Remove the redundant default argument definition in `the_taxonomies()`.

Fixes #27238.
Built from https://develop.svn.wordpress.org/trunk@30210


git-svn-id: http://core.svn.wordpress.org/trunk@30210 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-03 18:49:45 +00:00
Boone Gorges
eec3eea392 Introduce term_template param to get_the_taxonomies().
This parameter allows theme and plugin authors to specify the formatting they
would like on the term links as they are parsed into the taxonomy list.

Props hereswhatidid, dlh, davidjlaietta.
See #27238.
Built from https://develop.svn.wordpress.org/trunk@30209


git-svn-id: http://core.svn.wordpress.org/trunk@30209 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-03 18:49:24 +00:00
Boone Gorges
fc4b17a5d2 In in_object_in_term(), only check numeric string values against term_id.
The previous `in_array()` check was playing too loose with mixed types, such
that a string like '10_term_name' would incorrectly match a term_id 10.

Props nobinobi, realloc.
Fixes #29467.
Built from https://develop.svn.wordpress.org/trunk@30205


git-svn-id: http://core.svn.wordpress.org/trunk@30205 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-03 14:25:44 +00:00
Scott Taylor
a587ebc946 In WP_Tax_Query, declare $primary_table and $primary_id_column as properties.
See #30224.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30184 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-03 03:45:22 +00:00
Boone Gorges
96b42c2fdc Allow resource_type to be specified in get_ancestors().
Being explicit about resource type (taxonomy vs post_type) allows for the
proper resolution of conflicts when a taxonomy and post_type share a slug.

Props filosofo.
Fixes #15029.
Built from https://develop.svn.wordpress.org/trunk@30141


git-svn-id: http://core.svn.wordpress.org/trunk@30141 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-11-01 02:58:23 +00:00
Drew Jaynes
66c47f29bb Correct references of @uses $wpdb in core documentation to use @global.
See #30191, [30105].
Fixes #30217.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30122 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-31 17:56:22 +00:00
Boone Gorges
af026330c4 Clean up get_term_by() caching.
* Fix cache key/group modification that was missed in [30073].
* Update unit tests to reflect new key/group format.

Props tollmanz.
Fixes #21760.
Built from https://develop.svn.wordpress.org/trunk@30108


git-svn-id: http://core.svn.wordpress.org/trunk@30108 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-30 02:50:23 +00:00
Boone Gorges
47742eae12 In get_terms(), do not override 'hierarchical' and 'pad_counts' when 'parent' is present.
The previous behavior resulted in descendant terms being improperly excluded
from the results when passing a 'parent', even when 'hierarchical' had been
set to true.

The patch also adds unit tests that demonstrate the various interactions
between the 'child_of', 'parent', and 'hierarchical' parameters of `get_terms()`.

Props landakram.
Fixes #29815.
Built from https://develop.svn.wordpress.org/trunk@30107


git-svn-id: http://core.svn.wordpress.org/trunk@30107 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-30 02:12:22 +00:00
Drew Jaynes
f8657d5890 Remove redundant and erroneous @uses tag from most core inline documentation.
Per our inline documentation standards, no further use of the `@uses` tag is recommended as used and used-by relationships can be derived through other means. This removes most uses of the tag in core documentation, with remaining tags to be converted to `@global` or `@see` as they apply.

Fixes #30191.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30105 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-30 01:05:24 +00:00
Boone Gorges
e9adba887d Introduce 'pre_delete_term' hook.
Props cmmarslender.
Fixes #30127.
Built from https://develop.svn.wordpress.org/trunk@30088


git-svn-id: http://core.svn.wordpress.org/trunk@30088 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-29 02:44:22 +00:00
Boone Gorges
4013156e51 Be more specific in documentation of 'slug' param for get_terms().
Props jfarthing84.
Fixes #23636.
Built from https://develop.svn.wordpress.org/trunk@30086


git-svn-id: http://core.svn.wordpress.org/trunk@30086 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-29 02:35:23 +00:00
Boone Gorges
682fb09f01 Update inline docs for [30052].
Fixes #23261.
Built from https://develop.svn.wordpress.org/trunk@30077


git-svn-id: http://core.svn.wordpress.org/trunk@30077 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-28 21:26:22 +00:00
Scott Taylor
315612a96b Adjust caching for get_term_by() calls:
* Remove md5 hashes for term name cache keys
* Remove the namespace for the keys for `names` and `slugs` and add them to the group names
* Remove `wp_get_last_changed()`, which @nacin hated
 
Props tollmanz.
Fixes #21760.

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


git-svn-id: http://core.svn.wordpress.org/trunk@30073 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-28 21:05:23 +00:00
Boone Gorges
bd48b40cc4 Introduce orderby=include support for get_terms().
Props wpsmith.
Fixes #23261.
Built from https://develop.svn.wordpress.org/trunk@30052


git-svn-id: http://core.svn.wordpress.org/trunk@30052 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-28 18:13:19 +00:00
Boone Gorges
4177b48b1e Allow 'slug' param of get_terms() to accept an array.
Props jfarthing84, dlh.
Fixes #23636.
Built from https://develop.svn.wordpress.org/trunk@30042


git-svn-id: http://core.svn.wordpress.org/trunk@30042 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-28 14:57:22 +00:00
Boone Gorges
61115c51f7 Improve WP_Tax_Query param sanitization for empty strings.
When an empty string is passed as one of the clauses in the `$tax_query`
parameter, it should be discarded rather than parsed as a first-order clause.

Props tmtrademark.
Fixes #30117.
Built from https://develop.svn.wordpress.org/trunk@30031


git-svn-id: http://core.svn.wordpress.org/trunk@30031 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-26 22:57:18 +00:00
Boone Gorges
43fb0af4f1 Invalidate cache for child terms when parent term is deleted.
Props socki03.
Fixes #29911.
Built from https://develop.svn.wordpress.org/trunk@29945


git-svn-id: http://core.svn.wordpress.org/trunk@29695 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-17 20:59:20 +00:00
Boone Gorges
3949a8b6cc Remove invalid continue calls from WP_Tax_Query::get_sql_for_clause().
This was leftover code from the previous implementation, which used a `foreach()`
loop. See [29901].

Props nofearinc.
See #29738, #29718.
Built from https://develop.svn.wordpress.org/trunk@29931


git-svn-id: http://core.svn.wordpress.org/trunk@29683 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-16 22:07:20 +00:00
Scott Taylor
84a26a78a8 Cache get_term_by() calls:
* Add a helper function, `wp_get_last_changed()`, to retrieve a last-modified timestamp by cache group
* When caching a term, also make cache entries for slug and name via `slug:{$term_id}` and `name:{$term_id}` keys in the `$taxonomy:$last_changed` bucket that reference the term_id
* In `clean_term_cache()` and `update_term_cache()`, respect `$_wp_suspend_cache_invalidation`
* Original term cache entries maintain BC

Adds unit tests.

Props wonderboymusic, tollmanz, boonebgorges.
Fixes #21760.

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


git-svn-id: http://core.svn.wordpress.org/trunk@29668 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-16 04:45:17 +00:00
Boone Gorges
af6beda45b Avoid redundant table joins in WP_Tax_Query.
IN clauses that are connected by OR require only a single table join. To avoid
extraneous joins, keep track of generated table aliases, and let sibling
clauses piggy-back on those aliases when possible.

Introduces WP_Tax_Query::sanitize_relation() to reduce some repeated code.

Adds unit tests to verify the JOIN consolidation, and integration tests for
cases where JOINS are being combined.

Props boonebgorges, otto42, jakub.tyrcha.
Fixes #18105.
Built from https://develop.svn.wordpress.org/trunk@29902


git-svn-id: http://core.svn.wordpress.org/trunk@29657 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-15 16:40:18 +00:00
Boone Gorges
09fbcfc1ad Support 'EXISTS' and 'NOT EXISTS' in WP_Tax_Query.
These new values for the 'operator' parameter make it possible to filter items
that have no term from a given taxonomy, or any term from a given taxonomy.

Includes unit tests.

Fixes #29181.
Built from https://develop.svn.wordpress.org/trunk@29896


git-svn-id: http://core.svn.wordpress.org/trunk@29651 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-15 00:54:21 +00:00
Boone Gorges
0143196338 Introduce support for nested queries in WP_Tax_Query.
Previously, tax query arguments could be joined by a single AND or OR relation.
Now, these queries can be arbitrarily nested, allowing clauses to be linked
together with multiple relations.

In a few places, WP_Query runs through a list of clauses in a tax_query in order
to set certain query vars for backward compatibility. The necessary changes have
been made to WP_Query to support this feature with the new complex structure of
tax_query. Unit tests are included for these backward compatibility fixes.

Unit tests for the new nesting syntax are included.

Props boonebgorges.
Fixes #29718. See #29738.
Built from https://develop.svn.wordpress.org/trunk@29891


git-svn-id: http://core.svn.wordpress.org/trunk@29647 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-14 04:03:19 +00:00
Boone Gorges
d088de7195 Return an error when adding a term to a non-existent parent.
Parallels the logic of wp_insert_term(), introduced in [29196].

Props jesin.
Fixes #29614.
Built from https://develop.svn.wordpress.org/trunk@29867


git-svn-id: http://core.svn.wordpress.org/trunk@29627 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-09 18:12:20 +00:00
Drew Jaynes
a724b435d8 Add more complete inline documentation for get_term_link().
Adds more complete parameter descriptions for the `$term` and `$taxonomy` parameters. 

Props amruta123.b for the initial patch.
Fixes #29901.

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


git-svn-id: http://core.svn.wordpress.org/trunk@29626 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-09 15:41:18 +00:00
Boone Gorges
587599c54f Don't bail out of term_exists() when term sanitizes to an empty string.
This change brings return values for failures of this sort in line with other
failed lookups in term_exists(): a null value is now returned in all cases
where the queried term is not found.

Adds unit test for the sanitization issue. Modifies existing unit test to
reflect the change in return value for empty term strings.

Props boonebgorges, georgestephanis.
Fixes #29589.
Built from https://develop.svn.wordpress.org/trunk@29865


git-svn-id: http://core.svn.wordpress.org/trunk@29625 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-09 03:16:18 +00:00
Boone Gorges
61317341eb Fix term_exists() for parent = 0.
Passing a 0 (or '0') as the 'parent' param of term_exists() should limit
results to terms with no parent.

Adds unit test.

Fixes #29851.
Built from https://develop.svn.wordpress.org/trunk@29863


git-svn-id: http://core.svn.wordpress.org/trunk@29623 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-09 02:49:18 +00:00
Boone Gorges
3ceee6cd24 Improve 'alias_of' handling in wp_insert_term() and wp_update_term().
Using get_term_by() rather than direct SQL queries to fetch the alias term
fixes a number of issues:

* Object cache for aliased term is properly cleared after update.
* If the aliased term is in the object cache, it's served from there, saving a database query.
* Duplicate 'edit_terms' and 'edited_terms' hooks can be removed.
* Fix a PHP notice when the 'alias_of' term is not found.
* Prevent the incorrect creation of a new term group for the primary term when the 'alias_of' term is not found.

Adds unit tests for 'alias_of' functionality in both functions.

Fixes #29848.
Built from https://develop.svn.wordpress.org/trunk@29862


git-svn-id: http://core.svn.wordpress.org/trunk@29622 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-09 02:32:19 +00:00
Boone Gorges
17631e3b8e Explicitly declare hierarchical=false for post_tag in create_initial_taxonomies().
In certain edge cases, such as during the automated test suite,
create_initial_taxonomies() can be called in a situation where a non-default
permastruct setting has been saved outside of wp-admin. This causes the
'hierarchical' setting for the post_tag taxonomy to remain unset, leading to
PHP notices in get_term_link().

See #29827.
Built from https://develop.svn.wordpress.org/trunk@29859


git-svn-id: http://core.svn.wordpress.org/trunk@29620 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-09 00:58:20 +00:00
Boone Gorges
0c64fe335a In get_terms(), select term taxonomy count for all values of 'fields'.
Not having the count caused queries with 'fields' values of 'id=>name' and
'id=>slug' to return incorrect results when querying a hierarchical taxonomy
with 'hide_empty=true'.

Includes unit tests for get_terms() when using various combinations of 'fields',
'hide_empty', and 'hierarchical' arguments.

Props technical_mastermind.
Fixes #29859.
Built from https://develop.svn.wordpress.org/trunk@29845


git-svn-id: http://core.svn.wordpress.org/trunk@29608 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-10-06 22:05:18 +00:00
Scott Taylor
d4d1fcda0f wp_update_term() should mimic wp_insert_term() and set a value for $term_group before the alias_of logic runs. This ensures that $term_group exists when compact() is called.
See [28461].
Fixes #29278.

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


git-svn-id: http://core.svn.wordpress.org/trunk@29325 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-20 17:04:18 +00:00
John Blackbourn
93c80ac896 Docblock corrections for get_the_terms() function and corresponding filter, and registered_taxonomy action. Fixes #29183.
Built from https://develop.svn.wordpress.org/trunk@29467


git-svn-id: http://core.svn.wordpress.org/trunk@29245 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-08-11 21:17:17 +00:00
Sergey Biryukov
ef14aed9a2 Use an existing string.
see #19205.
Built from https://develop.svn.wordpress.org/trunk@29234


git-svn-id: http://core.svn.wordpress.org/trunk@29018 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-18 23:56:14 +00:00
Scott Taylor
cf3deb2ecb Avoid a race condition when multiple windows are open so that orphaned terms cannot be created by accident.
Adds a unit test.

Props dlh.
Fixes #19205.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28980 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-16 21:52:15 +00:00
Drew Jaynes
164f31e8e8 Add indentation for the hash notation missed in [29128].
See #28841.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28914 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-13 04:18:15 +00:00
Drew Jaynes
862cc336d2 Convert default arguments documentation for get_terms() into a hash notation.
See #28841.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28913 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-13 04:15:16 +00:00
Scott Taylor
fabec026c2 The 2nd argument to array_unique() was added to PHP in 5.2.9, so don't use it. We have to use our own code to return unique terms when fields => all in wp_get_object_terms().
See #28843 and [28583].

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


git-svn-id: http://core.svn.wordpress.org/trunk@28905 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-12 03:54:15 +00:00
Drew Jaynes
d4dd02b4ae Remove backticks on $post variables in some short parameter descriptions.
See [28653], [28654].
See #28388.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28765 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-03 19:28:14 +00:00
Sergey Biryukov
19a3159082 Make default 'template' argument of the_taxonomies() and get_the_taxonomies() translatable.
props juliobox.
fixes #28714.
Built from https://develop.svn.wordpress.org/trunk@28957


git-svn-id: http://core.svn.wordpress.org/trunk@28753 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-02 13:21:16 +00:00
Drew Jaynes
52fbb3c484 Fix parameter description for $append in wp_set_object_terms() inline docs.
See #26570.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28749 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-02 01:39:15 +00:00
Sergey Biryukov
1b23dd8f05 Clarify the docs and add more unit tests for wp_set_object_terms().
props DrewAPicture.
fixes #26570.
Built from https://develop.svn.wordpress.org/trunk@28951


git-svn-id: http://core.svn.wordpress.org/trunk@28748 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-07-02 01:28:15 +00:00
Sergey Biryukov
a8d0832a15 Notify developers when register_post_type() or register_taxonomy() fails because of post type or taxonomy key length.
props mattheweppelsheimer.
fixes #28683.
Built from https://develop.svn.wordpress.org/trunk@28902


git-svn-id: http://core.svn.wordpress.org/trunk@28701 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-29 21:54:14 +00:00
Sergey Biryukov
16595af731 Correct @return value for term_exists().
props simonwheatley.
fixes #28538.
Built from https://develop.svn.wordpress.org/trunk@28753


git-svn-id: http://core.svn.wordpress.org/trunk@28567 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-14 14:57:16 +00:00
Scott Taylor
17b17d1c78 Don't use variable variables in get_terms().
See #27881.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28550 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-11 17:41:14 +00:00
Scott Taylor
980744f882 In wp_insert_term(), when no slug is provided, check for an existing term by name. If it exists, use that slug instead of calling sanitize_title( $name ).
Prevents creating an endless number of terms like `A+` or `$$$$` in any given taxonomy.

Props wonderboymusic, SergeyBiryukov, aaroncampbell.
Fixes #17689.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28547 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-11 02:28:14 +00:00
Scott Taylor
05eeb16e30 Replace all uses of like_escape() with $wpdb->esc_like().
Props miqrogroove.
See #10041.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28528 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-10 00:44:15 +00:00
Drew Jaynes
b0877f02a4 Make sure $post is properly documented as optional where applicable.
See #28388.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28471 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-06-03 03:53:17 +00:00
Scott Taylor
96d788132a When queries are passed to WP_Tax_Query, the value for operator is assumed to be uppercase. This is an unnecessary constraint. In ->get_sql(), cast it using $operator = strtoupper( $query['operator'] ).
Props clifgriffin.
Fixes #27557.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28442 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-29 17:53:15 +00:00
Scott Taylor
8653099a83 In wp_get_object_terms(), before returning terms (and before running them through the 'wp_get_object_terms' filter) - run them through $terms = array_values( array_unique( $terms, SORT_REGULAR ) ).
There will be "dupes" when the function is called with `'fields' => 'all_with_object_id'`, but the objects will actually be unique due to the `object_id` addition, so they shouldn't be filtered out. 

Adds unit tests. All other unit tests pass.

Fixes #11003.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28408 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-27 03:29:14 +00:00
Scott Taylor
44c4b365a0 When adding queries to tax_query: if the query's field is term_taxonomy_id, don't require taxonomy to be specified. In WP_Tax_Query::transform_query(), $query['taxonomy'] is never checked for the 'term_taxonomy_id' case because 'term_taxonomy_id' is the primary key being looked up.
Adds unit tests.

Props helen.
Fixes #25284.


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


git-svn-id: http://core.svn.wordpress.org/trunk@28388 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-23 19:59:14 +00:00
Scott Taylor
b8d469600b These functions import $wpdb but do not use it.
See #27882.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28365 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-22 17:37:14 +00:00
Scott Taylor
eea7052df8 Eliminate the use of extract() in wp_delete_term().
See #22400.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28293 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-17 14:55:14 +00:00
Scott Taylor
bec9993f38 Eliminate the use of extract() in get_terms().
See #22400.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28292 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-17 14:47:14 +00:00
Scott Taylor
c1b5670a00 Eliminate the use of extract() in wp_insert_term().
See #22400.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28291 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-17 14:16:14 +00:00
Scott Taylor
66c3f62a54 Eliminate use of extract() in wp_update_term().
See #22400.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28288 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-16 21:29:13 +00:00
Scott Taylor
5a5c86139f Eliminate use of extract() in wp_get_object_terms().
There are 3 properties, just set them to variables. They are used too often to warrant a refactor.

See #22400.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28268 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-15 19:58:15 +00:00
Scott Taylor
eb2bbf9c97 Eliminate the use of extract() in get_objects_in_term(). Only one property (order) was extracted.
See #22400.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28250 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-15 05:43:16 +00:00
Scott Taylor
80a37d2fcd Eliminate the use of extract() in WP_Tax_Query::get_sql(). All unit tests still pass.
See #22400.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28249 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-15 05:41:14 +00:00
Scott Taylor
e6fad96f5e Eliminate the use of extract() in the_taxonomies(). Adds unit test.
See #22400.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28248 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-15 05:25:14 +00:00
Scott Taylor
c0b0b00e6d Eliminate use of extract() in get_the_taxonomies(). Adds unit test.
See #22400.

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


git-svn-id: http://core.svn.wordpress.org/trunk@28242 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-15 03:51:13 +00:00
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
Andrew Nacin
cd47b3dc90 Add $taxonomy to edit_terms and edited_terms actions. props SergeyBiryukov, fixes #22542.
git-svn-id: http://core.svn.wordpress.org/trunk@24829 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-28 22:15:03 +00:00
Andrew Nacin
4fd4d4452f Use sanitize_key() instead of esc_sql() when 'escaping' variable DB field names. see #21767.
git-svn-id: http://core.svn.wordpress.org/trunk@24714 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-07-16 14:21:05 +00:00
Ryan Boren
ad4a081c0c Pinking shears
git-svn-id: http://core.svn.wordpress.org/trunk@24303 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-05-20 12:10:58 +00:00
Sergey Biryukov
53d52e7cd5 Correct inline docs for wp_delete_term(). fixes #24343.
git-svn-id: http://core.svn.wordpress.org/trunk@24261 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-05-15 08:10:52 +00:00
Sergey Biryukov
4b4b35ae3b Remove unnecessary error suppression from get_terms(). fixes #21887.
git-svn-id: http://core.svn.wordpress.org/trunk@23599 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-04 02:52:43 +00:00
Sergey Biryukov
b35c629308 Fix array formatting. props WraithKenny. fixes #21210.
git-svn-id: http://core.svn.wordpress.org/trunk@23598 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-04 02:48:20 +00:00
Ryan Boren
315bfb019a Use wp_unslash() instead of stripslashes() and stripslashes_deep(). Use wp_slash() instead of add_magic_quotes().
see #21767


git-svn-id: http://core.svn.wordpress.org/trunk@23594 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-03 21:11:40 +00:00
Ryan Boren
43a7e695e9 Revert 23416, 23419, 23445 except for wp_reset_vars() changes. We are going a different direction with the slashing cleanup, so resetting to a clean slate. see #21767
git-svn-id: http://core.svn.wordpress.org/trunk@23554 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-01 16:28:40 +00:00
Sergey Biryukov
e58f456cb1 Make wp_remove_object_terms() return false if nothing has been deleted. props kovshenin. fixes #15475.
git-svn-id: http://core.svn.wordpress.org/trunk@23552 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-03-01 16:22:07 +00:00
Sergey Biryukov
5777e5a949 Rename 'no_tagcloud' taxonomy label to 'not_found', for consistency with the post type label of the same key. fixes #23597.
git-svn-id: http://core.svn.wordpress.org/trunk@23484 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-02-25 19:39:38 +00:00
Sergey Biryukov
bf1ca6b9ca Move 'no_tagcloud' argument to the taxonomy labels object. props DrewAPicture for initial patch. fixes #23597.
git-svn-id: http://core.svn.wordpress.org/trunk@23483 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-02-25 18:35:05 +00:00
Ryan Boren
cc5ed3a485 Change all core API to expect unslashed rather than slashed arguments.
The exceptions to this are update_post_meta() and add_post_meta() which are often used by plugins in POST handlers and will continue accepting slashed data for now.

Introduce wp_upate_post_meta() and wp_add_post_meta() as unslashed alternatives to update_post_meta() and add_post_meta(). These functions could become methods in WP_Post so don't use them too heavily yet.

Remove all escape() calls from wp_xmlrpc_server. Now that core expects unslashed data this is no longer needed.

Remove addslashes(), addslashes_gpc(), add_magic_quotes() calls on data being prepared for handoff to core functions that until now expected slashed data. Adding slashes in no longer necessary.

Introduce wp_unslash() and use to it remove slashes from GPCS data before using it in core API. Almost every instance of stripslashes() in core should now be wp_unslash(). In the future (a release or three) when GPCS is no longer slashed, wp_unslash() will stop stripping slashes and simply return what is passed. At this point wp_unslash() calls can be removed from core.

Introduce wp_slash() for slashing GPCS data. This will also turn into a noop once GPCS is no longer slashed. wp_slash() should almost never be used. It is mainly of use in unit tests.

Plugins should use wp_unslash() on data being passed to core API.

Plugins should no longer slash data being passed to core. So when you get_post() and then wp_insert_post() the post data from get_post() no longer needs addslashes(). Most plugins were not bothering with this. They will magically start doing the right thing. Unfortunately, those few souls who did it properly will now have to avoid calling addslashes() for 3.6 and newer.

Use wp_kses_post() and wp_kses_data(), which expect unslashed data, instead of wp_filter_post_kses() and wp_filter_kses(), which expect slashed data. Filters are no longer passed slashed data.

Remove many no longer necessary calls to $wpdb->escape() and esc_sql().

In wp_get_referer() and wp_get_original_referer(), return unslashed data.

Remove old stripslashes() calls from WP_Widget::update() handlers. These haven't been necessary since WP_Widget.

Switch several queries over to prepare().

Expect something to break.

Props alexkingorg
see #21767


git-svn-id: http://core.svn.wordpress.org/trunk@23416 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-02-14 22:51:06 +00:00
Ryan Boren
353ef064ea Use microtime() instead of incrementors for last_changed to to avoid race conditions with cache evictions.
Props westi
fixes #23448


git-svn-id: http://core.svn.wordpress.org/trunk@23401 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-02-11 18:08:14 +00:00
Mark Jaquith
6953fe2a25 Introduce wp_remove_object_terms() and wp_add_object_terms(). No more fetch-alter-update nonsense. Use wp_remove_object_terms() in a few places internally.
props simonwheatley, scribu, ericmann, maxcutler. fixes #15475

git-svn-id: http://core.svn.wordpress.org/trunk@23398 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-02-08 18:45:34 +00:00
Ryan Boren
0f80568a7e Use incrementors for cache invalidation in get_terms().
fixes #23326
see #23173


git-svn-id: http://core.svn.wordpress.org/trunk@23384 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2013-02-04 13:48:46 +00:00
Ryan Boren
b237423e72 Clear the object term relationships cache in wp_set_object_terms() rather than wp_set_post_terms(). This should be done lower in the stack than wp_set_post_terms().
Props batmoo
fixes #22560


git-svn-id: http://core.svn.wordpress.org/trunk@22878 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-27 19:42:38 +00:00
Ryan Boren
06ee370814 Pinking shears
git-svn-id: http://core.svn.wordpress.org/trunk@22634 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-17 15:11:29 +00:00
Andrew Nacin
1b0a4561a4 Use correct variable. props picklewagon. fixes #22394.
git-svn-id: http://core.svn.wordpress.org/trunk@22476 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-09 00:16:30 +00:00
Andrew Nacin
039279db28 Only call wp_get_object_terms() if get_object_term_cache() says there is no cache (false), which is different than no terms. props wonderboymusic, fixes #16505.
git-svn-id: http://core.svn.wordpress.org/trunk@22433 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-07 20:00:51 +00:00
Andrew Nacin
711f6f2619 Treat a single taxonomy passed as an array the same as when passed as a string in get_terms(). props wonderboymusic, fixes #17955.
git-svn-id: http://core.svn.wordpress.org/trunk@22417 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-11-07 09:03:40 +00:00
Jon Cave
391ff2f639 Fix documentation typo: s/WP_Erorr/WP_Error/. See #21593.
git-svn-id: http://core.svn.wordpress.org/trunk@22309 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-25 22:29:37 +00:00
Ryan Boren
28461df188 Return WP_Error when registering a taxonomy that exceeds 32 characters.
Props ocean90.
fixes #21593


git-svn-id: http://core.svn.wordpress.org/trunk@22307 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-25 22:12:02 +00:00
Ryan Boren
77518e9c71 Objects no longer need to be explicitly passed by ref to call_user_func*() to be callable. Props wonderboymusic. fixes #21865
git-svn-id: http://core.svn.wordpress.org/trunk@22118 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-04 20:00:16 +00:00
Ryan Boren
faca571a3a Avoid 'Only variables should be assigned by reference' warning. Props wonderboymusic. see #21865
git-svn-id: http://core.svn.wordpress.org/trunk@22114 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-04 18:21:47 +00:00
Ryan Boren
3c2b9a6901 An empty taxonomy query should return no results rather than all posts. Props wonderboymusic. fixes #20604
git-svn-id: http://core.svn.wordpress.org/trunk@22109 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-10-04 13:16:47 +00:00
Andrew Nacin
557d9313a7 Introduce constants to allow for easier expression of time periods in seconds. Adds MINUTE_IN_SECONDS, HOUR_IN_SECONDS, DAY_IN_SECONDS, WEEK_IN_SECONDS, YEAR_IN_SECONDS. props nbachiyski, SergeyBiryukov. fixes #20987.
git-svn-id: http://core.svn.wordpress.org/trunk@21996 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-09-25 05:26:19 +00:00
Andrew Nacin
d80d004b10 Don't repeatedly call get_object_taxonomies() in clean_object_term_cache(). see #11399.
git-svn-id: http://core.svn.wordpress.org/trunk@21951 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-09-22 15:21:30 +00:00
Ryan Boren
df21fa1cc6 Pass a term object to the delete_term actions. Props bigdawggi. fixes #20645
git-svn-id: http://core.svn.wordpress.org/trunk@21939 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-09-21 13:27:56 +00:00
Andrew Nacin
8203ef4905 Make WP_Tax_Query::transform_query() public. props scribu. fixes #21684.
git-svn-id: http://core.svn.wordpress.org/trunk@21863 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-09-15 20:17:03 +00:00
Andrew Nacin
e728ad3a1e Update docs to reflect that wp_count_terms() can return WP_Error when the taxonomy does not exist. props SergeyBiryukov, fixes #21888.
git-svn-id: http://core.svn.wordpress.org/trunk@21843 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-09-14 16:11:30 +00:00
Ryan Boren
f483a85676 Remove unnecessary return by refs. Props wonderboymusic. fixes #21839
git-svn-id: http://core.svn.wordpress.org/trunk@21792 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-09-10 17:00:11 +00:00
Andrew Nacin
1af8c36086 Allow easy registration of taxonomy columns on post (and custom post type) list table screens.
To register a column for a list table, use the new manage_taxonomies_for_{$post_type}_columns
filter. Introduces show_admin_column => true for register_taxonomy(), which automatically
displays that column on all associated post types.

props jtsternberg, SergeyBiryukov for initial patches.
fixes #21240.



git-svn-id: http://core.svn.wordpress.org/trunk@21788 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-09-08 03:18:36 +00:00
Ryan Boren
2b47dd4afe Return WP_Error if the db insert in wp_set_object_terms() fails. Props jndetlefsen. fixes #21800
git-svn-id: http://core.svn.wordpress.org/trunk@21766 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-09-05 17:57:53 +00:00
Andrew Nacin
5a9193d6c9 Validate $order in wp_get_object_terms(). props duck_.
git-svn-id: http://core.svn.wordpress.org/trunk@21758 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-09-05 01:23:53 +00:00
Ryan Boren
f56d8278bb Remove return ref from all calls to get_post()
Return WP_Post from get_default_post_to_edit()
Replace all calls to get_page() with get_post()
see #21309


git-svn-id: http://core.svn.wordpress.org/trunk@21597 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-08-23 20:01:10 +00:00
Ryan Boren
9377523bce Introduce WP_Post class. Clean up ancestors handling. Props scribu, toppa. fixes #10381 see #21309
git-svn-id: http://core.svn.wordpress.org/trunk@21559 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-08-20 19:47:52 +00:00
Ryan Boren
9dbb6a34f6 Reduce calls to sanitize_title_with_dashes in register_(post_type|taxonomy). Props ocean90. fixes #21600
git-svn-id: http://core.svn.wordpress.org/trunk@21553 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-08-20 17:25:06 +00:00
Andrew Nacin
9eeccc2230 Add term_taxonomy_id field handling to WP_Tax_Query::transform_query(), allowing the transformation to be bypassed when tt ids are passed.
props wonderboymusic.
fixes #21228.



git-svn-id: http://core.svn.wordpress.org/trunk@21552 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-08-20 16:49:21 +00:00
Andrew Nacin
84c3a86036 Hide the link manager from the UI on upgrade, if the site has no links. New DB option, link_manager_enabled.
Enforce this by denying the 'manage_links' capability, which hides the All Links, Add New Link, and Link Categories screens. Hide WP_Widget_Links and the UI for the default_link_category as well.

Convert all references to 'posts and links' when handling reassignment on user deletion to just 'posts'.

see #21307.



git-svn-id: http://core.svn.wordpress.org/trunk@21501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-08-13 16:18:42 +00:00
ryan
eaa419dba3 Consolodate some strings. Props pavelevap. fixes #20809
git-svn-id: http://core.svn.wordpress.org/trunk@20972 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-06-01 19:05:30 +00:00
nacin
2243e45a43 Add view_item to the phpdoc for get_taxonomy_labels(). props Caspie. fixes #20406.
git-svn-id: http://svn.automattic.com/wordpress/trunk@20436 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-04-11 20:08:30 +00:00
nacin
0730535015 Introduce $wpdb->delete(). props justindgivens, scribu. fixes #18948.
git-svn-id: http://svn.automattic.com/wordpress/trunk@20287 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-03-24 15:24:31 +00:00
duck_
a395e06896 Reduce references to the $wp_rewrite global because it's no longer used or a wrapper function can be used instead. Fixes #14546.#14546.
git-svn-id: http://svn.automattic.com/wordpress/trunk@20023 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-02-28 20:29:33 +00:00
duck_
8ac3015ccf Stop invalid SQL syntax by bailing from wp_get_object_terms() if $object_ids or $taxonomies is empty. Props batmoo. Fixes #19952.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19975 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-02-21 20:20:50 +00:00
duck_
ecdac4be4f Taxonomy rewrite generation when turning on permalinks, r18443 for taxonomies. Props SergeyBiryukov. Fixes #19794.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19930 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-02-15 17:30:37 +00:00
duck_
312e1f1811 Post formats should show_in_nav_menus when the current theme supports them. Props filosofo, nacin. Fixes #16390.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19876 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-02-08 17:12:02 +00:00
duck_
2f4c545761 Use new $args parameter for (WP_Rewrite::)add_permastruct(). Fixes #16092.
Use array_intersect_key() to keep WP_Rewrite::$extra_permastructs free of unnecessary/unknown keys + values.


git-svn-id: http://svn.automattic.com/wordpress/trunk@19779 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-01-28 21:00:59 +00:00
nacin
774e51c04c Correct logic inversion. #19275.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19742 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-01-23 20:10:01 +00:00
nacin
0c224cd82c Clean up and better document create_initial_taxonomies(). see #19275.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19741 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-01-23 19:58:26 +00:00
nacin
61abfcd3c7 Add 'ep_mask' as an argument to the 'rewrite' array for register_post_type() and register_taxonomy(). Keeps 'permalink_epmask' compatible as an argument for post type registrations. Fixes endpoints for category and tag pages. fixes #19275.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19738 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-01-23 19:12:04 +00:00
ryan
2b44b1a244 Update register_taxonomy_for_object_type() phpdoc to reflect that the post_type must be a string only, no arrays allowed. Props transom. fixes #19795
git-svn-id: http://svn.automattic.com/wordpress/trunk@19730 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-01-11 21:39:01 +00:00
ryan
4cf5450a81 Use wp_cache_add() instead of wp_cache_set() when priming the object term cache in update_object_term_cache(). Pass the real post_type to clean_object_term_cache() instead of hard-coding post. Call clean_object_term_cache() from clean_bookmark_cache(). Props leewillis77. fixes #19690
git-svn-id: http://svn.automattic.com/wordpress/trunk@19729 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-01-11 21:26:18 +00:00
ryan
616c35e71c One newline is enough.
git-svn-id: http://svn.automattic.com/wordpress/trunk@19684 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2012-01-05 20:10:39 +00:00