Make WordPress Core


Ignore:
Timestamp:
10/10/2015 01:58:37 AM (9 years ago)
Author:
boonebgorges
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/category-functions.php

    r34419 r34997  
    320320 *
    321321 * @since 2.3.0
     322 * @since 4.4.0 The `$category` parameter now also accepts a WP_Term object.
    322323 * @access private
    323324 *
    324  * @param array|object $category Category Row object or array
     325 * @param array|object|WP_Term $category Category Row object or array
    325326 */
    326327function _make_cat_compat( &$category ) {
    327328    if ( is_object( $category ) && ! is_wp_error( $category ) ) {
    328         $category->cat_ID = &$category->term_id;
    329         $category->category_count = &$category->count;
    330         $category->category_description = &$category->description;
    331         $category->cat_name = &$category->name;
    332         $category->category_nicename = &$category->slug;
    333         $category->category_parent = &$category->parent;
     329        $category->cat_ID = $category->term_id;
     330        $category->category_count = $category->count;
     331        $category->category_description = $category->description;
     332        $category->cat_name = $category->name;
     333        $category->category_nicename = $category->slug;
     334        $category->category_parent = $category->parent;
    334335    } elseif ( is_array( $category ) && isset( $category['term_id'] ) ) {
    335336        $category['cat_ID'] = &$category['term_id'];
Note: See TracChangeset for help on using the changeset viewer.