Commit Graph

653 Commits

Author SHA1 Message Date
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