mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-30 01:14:28 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@34997 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -319,18 +319,19 @@ function clean_category_cache( $id ) {
|
||||
* pass to it. This is one of the features with using pass by reference in PHP.
|
||||
*
|
||||
* @since 2.3.0
|
||||
* @since 4.4.0 The `$category` parameter now also accepts a WP_Term object.
|
||||
* @access private
|
||||
*
|
||||
* @param array|object $category Category Row object or array
|
||||
* @param array|object|WP_Term $category Category Row object or array
|
||||
*/
|
||||
function _make_cat_compat( &$category ) {
|
||||
if ( is_object( $category ) && ! is_wp_error( $category ) ) {
|
||||
$category->cat_ID = &$category->term_id;
|
||||
$category->category_count = &$category->count;
|
||||
$category->category_description = &$category->description;
|
||||
$category->cat_name = &$category->name;
|
||||
$category->category_nicename = &$category->slug;
|
||||
$category->category_parent = &$category->parent;
|
||||
$category->cat_ID = $category->term_id;
|
||||
$category->category_count = $category->count;
|
||||
$category->category_description = $category->description;
|
||||
$category->cat_name = $category->name;
|
||||
$category->category_nicename = $category->slug;
|
||||
$category->category_parent = $category->parent;
|
||||
} elseif ( is_array( $category ) && isset( $category['term_id'] ) ) {
|
||||
$category['cat_ID'] = &$category['term_id'];
|
||||
$category['category_count'] = &$category['count'];
|
||||
|
||||
Reference in New Issue
Block a user