Commit Graph

39 Commits

Author SHA1 Message Date
Scott Taylor
c5b6202dfa Widgets: revert [34376] and [34386] as pertains to the Categories widget supporting custom taxonomies.
Punting on 4th down.

See #21165.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-20 04:57:25 +00:00
Boone Gorges
2543ffbbae Bust object term cache in wp_remove_object_terms().
Props tszming.
Fixes #34338.
Built from https://develop.svn.wordpress.org/trunk@35268


git-svn-id: http://core.svn.wordpress.org/trunk@35234 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-19 01:53:24 +00:00
Boone Gorges
4430e5dbbb Return null from get_term() on taxonomy mismatch.
[34997] caused `get_term()` to return an error object in the case when
`$taxonomy` did not match the taxonomy of the located term. This was an
inadvertant change from the previous behavior, when `get_term()` would return
null in these cases.

Props dlh.
See #14162. Fixes #34332.
Built from https://develop.svn.wordpress.org/trunk@35227


git-svn-id: http://core.svn.wordpress.org/trunk@35193 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-16 21:42:25 +00:00
Drew Jaynes
217b661703 Docs: Add missing descriptions for the $wpdb global in DocBlocks all the places.
See #32246.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35136 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-14 23:44:25 +00:00
John Blackbourn
a5cca9c5ff Reinstate the Link Category admin screen after [34359].
See [13216]

Fixes #34284

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


git-svn-id: http://core.svn.wordpress.org/trunk@35119 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-14 01:51:26 +00:00
Boone Gorges
cd563fd404 Use a more reliable method for generating get_terms() cache key.
Previously, the cache key included a serialization of `list_terms_exclusions`
callbacks, to ensure that the cache was differentiated properly for different
uses of the `list_terms_exclusions` filter. This strategy was flawed in a
couple of ways: serialization doesn't work equally well for all callable types;
the serialization required reaching into the `$wp_filter` global; serializing
the callback itself didn't properly account for the possibility that the
callback might return different values in different contexts; the cache key
didn't account for other filters that similarly affect the cached values, such
as `terms_clauses`.

We skirt all these issues by concatenating the cache key using the SQL query
string, which will reflect all filters applied earlier in `get_terms()`.

Props boonebgorges, wonderboymusic.
Fixes #21267.
Built from https://develop.svn.wordpress.org/trunk@35120


git-svn-id: http://core.svn.wordpress.org/trunk@35085 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-13 03:07:24 +00:00
Boone Gorges
7de3499949 In get_terms(), don't store WP_Term objects in cache.
Fixes #34282.
Built from https://develop.svn.wordpress.org/trunk@35117


git-svn-id: http://core.svn.wordpress.org/trunk@35082 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-13 02:58:24 +00:00
Boone Gorges
499d1b74ba Don't cache WP_Term objects in wp_get_object_cache().
The data stored in the cache should be raw database query results, not
`WP_Term` objects (which may be modified by plugins, and may contain additional
properties that shouldn't be cached).

If term relationships caches were handled in `wp_get_object_terms()` - where
a database query takes place - it would be straightforward to cache raw data.
See #34239. Since, in fact, `get_the_terms()` caches the value it gets from
`wp_get_object_terms()`, we need a technique that allows us to get raw data
from a `WP_Term` object. Mirroring `WP_User`, we introduce a `data` property
on term objects, which `get_the_terms()` uses to fetch cacheable term info.

Fixes #34262.
Built from https://develop.svn.wordpress.org/trunk@35032


git-svn-id: http://core.svn.wordpress.org/trunk@34997 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 15:13:48 +00:00
Boone Gorges
58aee33cd9 After [35028], normalize get_term_field() doc formatting.
Fixes #34245.
Built from https://develop.svn.wordpress.org/trunk@35029


git-svn-id: http://core.svn.wordpress.org/trunk@34994 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 04:14:48 +00:00
Boone Gorges
1a87ade436 Don't require a $taxonomy to be specified in get_term_field().
After [34997], the `$taxonomy` parameter of `get_term()` is optional. This
changeset brings `get_term_field()` in line with the new usage.

Adds unit tests for `get_term_field()`.

Props DrewAPicture.
See #34245.
Built from https://develop.svn.wordpress.org/trunk@35028


git-svn-id: http://core.svn.wordpress.org/trunk@34993 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-12 04:14:24 +00:00
Boone Gorges
636464857e Return WP_Post objects from wp_get_object_terms().
A side effect of this change is that terms stored in the cache no longer have
an `object_id` associated with them. Previously, `object_id` had always been
cached when the term cache was populated via `wp_get_object_terms()`, a
strategy that was mostly harmless but still incorrect.

See #14162.
Built from https://develop.svn.wordpress.org/trunk@34999


git-svn-id: http://core.svn.wordpress.org/trunk@34964 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-10 03:39:26 +00:00
Boone Gorges
71429da5b4 Return WP_Term objects from get_terms().
Props boonebgorges, flixos90, DrewAPicture.
See #14162.
Built from https://develop.svn.wordpress.org/trunk@34998


git-svn-id: http://core.svn.wordpress.org/trunk@34963 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-10 02:13:28 +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
Scott Taylor
0c2b2a0e3d List Tables/WP_Screen: in WP_Screen, add methods to store, retrieve, and render screen reader text, primarily used by list table screens.
These additions are based on an audit and recommendations by the Accessibility team. #a11y'all

Props afercia.
Fixes #32147.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34856 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-07 01:28:25 +00:00
Drew Jaynes
6079c4c6d2 Docs: _pad_term_counts() takes an array of objects passed by reference, not term IDs.
Props wpsmith.
Fixes #34174.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34849 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-06 22:39:23 +00:00
Boone Gorges
f08e5c2d80 Update the taxonomy relationship cache in is_object_in_term().
This function attempts to read from the relationship cache, and uses any data
it finds. If it finds no data, it does a query for the data it needs. Since we
are going to the trouble to query for the relationships, and since we are
already using cached data when available, let's go ahead and cache it for
later use.

Props joehoyle, boonebgorges.
Fixes #32044.
Built from https://develop.svn.wordpress.org/trunk@34812


git-svn-id: http://core.svn.wordpress.org/trunk@34777 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-03 21:19:23 +00:00
Boone Gorges
5be41d618f Don't prime term meta cache in is_object_in_term().
Term meta is not necessary in this case, so priming the cache wastes a query.

See #10142, #32044.
Built from https://develop.svn.wordpress.org/trunk@34811


git-svn-id: http://core.svn.wordpress.org/trunk@34776 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-03 21:07:24 +00:00
Boone Gorges
28625bfc38 When creating terms, avoid false dupe checks due to accented characters.
`wp_insert_term()` doesn't allow the creation of a term when the term `name`
is the same as another term in the same hierarchy level of the same taxonomy.
Previously, this duplicate check used `get_term_by( 'name' )`, which uses the
database collation to determine sameness. But common collations do not
distinguish between accented and non-accented versions of a character. As a
result, it was impossible to create a term 'Foo' if a sibling term with an
accented character existed.

We address this problem by using `get_terms()` to do the duplicate check. This
query returns all potentially matching terms. We then do a stricter check
for equivalence in PHP, before determining whether one of the matches is
indeed a duplicate.

Props boonebgorges, tyxla, geza.miklo, mehulkaklotar.
Fixes #33864.
Built from https://develop.svn.wordpress.org/trunk@34809


git-svn-id: http://core.svn.wordpress.org/trunk@34774 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-03 20:25:26 +00:00
John Blackbourn
27dbbdfba4 Introduce a register_taxonomy_args filter for filtering the arguments passed when calling register_taxonomy(). This is the taxonomy equivalent of the newly introduced register_post_type_args filter.
Fixes #33990
Props tyxla for initial patch

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


git-svn-id: http://core.svn.wordpress.org/trunk@34752 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-10-02 23:57:25 +00:00
Boone Gorges
dac1de24f7 Bail out of termmeta functions if schema is not up-to-date.
Termmeta cache priming was throwing database errors on installations that had
not yet gone through the database update routine. To avoid errors in all cases,
the check has been added to all termmeta functions. These checks will be
removed in a future version of WordPress. (Hang on to your hats!)

Fixes #34091.
Built from https://develop.svn.wordpress.org/trunk@34718


git-svn-id: http://core.svn.wordpress.org/trunk@34682 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-30 04:53:25 +00:00
Boone Gorges
db880777f4 Improve lazyloading of term metadata in WP_Query loops.
[34529] introduced lazyloading for the metadata belonging to terms matching
posts in the main `WP_Query`. The current changeset improves this technique
in the following ways:

* Term meta lazyloading is now performed on the results of all `WP_Query` queries, not just the main query.
* Fewer global variable touches and greater encapsulation.
* The logic for looping through posts to identify terms is now only performed once per `WP_Query`.

Props dlh, boonebgorges.
See #34047.
Built from https://develop.svn.wordpress.org/trunk@34704


git-svn-id: http://core.svn.wordpress.org/trunk@34668 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-29 22:00:24 +00:00
Boone Gorges
061c536031 Don't require explicit taxonomy when getting terms by term_taxonomy_id.
Props wonderboymusic.
Fixes #30620.
Built from https://develop.svn.wordpress.org/trunk@34679


git-svn-id: http://core.svn.wordpress.org/trunk@34643 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-29 03:52:25 +00:00
Boone Gorges
ff7df78e04 Bust term query cache when modifying term meta.
The 'last_changed' incrementor is used to invalidate the `get_terms()` query
cache. Since `get_terms()` queries may reference 'meta_query', changing term
metadata could change the results of the queries. So we invalidate the cache
on add, delete, and update.

See #10142.
Built from https://develop.svn.wordpress.org/trunk@34538


git-svn-id: http://core.svn.wordpress.org/trunk@34502 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-25 13:47:25 +00:00
Boone Gorges
fd946a9b5a Pinking shears.
Built from https://develop.svn.wordpress.org/trunk@34534


git-svn-id: http://core.svn.wordpress.org/trunk@34498 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-25 04:44:25 +00:00
Boone Gorges
563d70aa0d After [34529], normalize documentation for get_terms() and wp_get_object_terms().
See #10142.
Built from https://develop.svn.wordpress.org/trunk@34530


git-svn-id: http://core.svn.wordpress.org/trunk@34494 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-25 04:05:24 +00:00
Boone Gorges
8b4a5d1ec0 Introduce metadata for taxonomy terms.
Adds a new table to the database schema (`wp_termmeta`), and a set of
`*_term_meta()` API functions. `get_terms()` and `wp_get_object_terms()`
now also support 'meta_query' parameters, with syntax identical to other
uses of `WP_Meta_Query`.

When fetching terms via `get_terms()` or `wp_get_object_terms()`, metadata for
matched terms is preloaded into the cache by default. Disable this behavior
by setting the new `$update_term_meta_cache` paramater to `false`.

To maximize performance, within `WP_Query` loops, the termmeta cache is *not*
primed by default. Instead, we use a lazy-loading technique: metadata for all
terms belonging to posts in the loop is loaded into the cache the first time
that `get_term_meta()` is called within the loop.

Props boonebgorges, sirzooro.
See #10142.
Built from https://develop.svn.wordpress.org/trunk@34529


git-svn-id: http://core.svn.wordpress.org/trunk@34493 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-25 03:59:27 +00:00
John Blackbourn
bef8977ea1 Add a @since entry for the implementation of the $public argument in register_taxonomy().
See #21949

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


git-svn-id: http://core.svn.wordpress.org/trunk@34480 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 20:16:26 +00:00
Drew Jaynes
a6c8b7aafa Docs: Convert the $args parameter description in the register_taxonomy() DocBlock to a hash notation.
Also standardizes the DocBlock summary.

Props johnbillion.
Fixes #33991.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34474 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-24 19:12:26 +00:00
Scott Taylor
939d9b7395 Remove some unused globals and/or their docs.
See ##33491.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34410 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-22 20:27:25 +00:00
Drew Jaynes
4bcbeb129e Docs: Clarify the file header summary for wp-includes/taxonomy-functions.php, introduced in [33760].
See #33413. See #33701.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34367 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-22 13:20:27 +00:00
Scott Taylor
40c15af795 Widgets: Make the categories widget work with custom taxonomies.
Props fonglh, wonderboymusic, DrewAPicture, kucrut.
Fixes #21165.

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


git-svn-id: http://core.svn.wordpress.org/trunk@34340 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-22 04:25:24 +00:00
John Blackbourn
970752a351 Remove the ability to view the term editing screen for taxonomies with show_ui set to false. It is unexpected and unintended behaviour that this is allowed.
If your plugin or site does rely on this behaviour, the arguments that are passed to `register_taxonomy()` should be altered so that `show_ui` is `true`, and arguments such as `show_in_menu` and `show_in_nav_menus` are false.

Fixes #33938

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


git-svn-id: http://core.svn.wordpress.org/trunk@34323 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-20 17:11:25 +00:00
Boone Gorges
471fc6d9a5 Allow taxonomies to be non-public.
[13216] introduced the 'public' argument for `register_taxonomy()`. This param
was used to set defaults for 'show_ui' and a number of other params, but it
never did anything itself.

With this changeset, taxonomies registered with `public=false` will no longer
be queryable on the front end, ie via taxonomy archive queries.

Props wpsmith, ocean90, nacin, ericlewis, boonebgorges.
Fixes #21949.
Built from https://develop.svn.wordpress.org/trunk@34247


git-svn-id: http://core.svn.wordpress.org/trunk@34211 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-16 19:05:23 +00:00
Boone Gorges
6153a72796 Failed get_term_by() lookups should always return false.
Previously, we sometimes returned `null`.

Props charlestonsw, tyxla.
Fixes #33281.
Built from https://develop.svn.wordpress.org/trunk@34246


git-svn-id: http://core.svn.wordpress.org/trunk@34210 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-16 18:50:26 +00:00
Boone Gorges
cfbd3c2cc0 Omit the ORDER BY clause when updating object term cache.
The `ORDER BY` clause was forcing filesorts on large tables, and is
unnecessary, since term order doesn't matter when updating the cache.

Props mbrandys, wonderboymusic.
Fixes #28922.
Built from https://develop.svn.wordpress.org/trunk@34217


git-svn-id: http://core.svn.wordpress.org/trunk@34181 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-15 20:53:33 +00:00
Dominik Schilling
008dca20b4 Docs: Fix DocBlock formatting for wp_insert_term().
Built from https://develop.svn.wordpress.org/trunk@34051


git-svn-id: http://core.svn.wordpress.org/trunk@34019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-11 18:48:24 +00:00
Scott Taylor
c1bb5b5ce3 After [33843], update the location of some files in This filter is documented in docs
Props dimadin.
See #33413.

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


git-svn-id: http://core.svn.wordpress.org/trunk@33923 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-08 22:17:26 +00:00
Boone Gorges
45e8bef3cd In get_terms(), allow terms to be ordered by 'term_id'.
[29128] introduced updated documentation for the `'orderby'` parameter of
`get_terms()`. The new documentation mistakenly said that 'term_id' was a valid
orderby value. The current changeset makes that fantasy...A REALITY.

Props ixkaito.
Fixes #33726.
Built from https://develop.svn.wordpress.org/trunk@33903


git-svn-id: http://core.svn.wordpress.org/trunk@33872 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2015-09-04 21:17:26 +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