_prime_term_caches example

if ( 'ids' === $_fields ) {
                $cache = array_map( 'intval', $cache );
            } elseif ( 'count' !== $_fields ) {
                if ( ( 'all_with_object_id' === $_fields && ! empty( $args['object_ids'] ) )
                    || ( 'all' === $_fields && $args['pad_counts'] )
                ) {
                    $term_ids = wp_list_pluck( $cache, 'term_id' );
                } else {
                    $term_ids = array_map( 'intval', $cache );
                }

                _prime_term_caches( $term_ids$args['update_term_meta_cache'] );

                $term_objects = $this->populate_terms( $cache );
                $cache        = $this->format_terms( $term_objects$_fields );
            }

            $this->terms = $cache;
            return $this->terms;
        }

        if ( 'count' === $_fields ) {
            $count = $wpdb->get_var( $this->request ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
// Backward compatibility for if a plugin is putting objects into the cache, rather than IDs.     $term_ids = array();
    foreach ( $_term_ids as $term_id ) {
        if ( is_numeric( $term_id ) ) {
            $term_ids[] = (int) $term_id;
        } elseif ( isset( $term_id->term_id ) ) {
            $term_ids[] = (int) $term_id->term_id;
        }
    }

    // Fill the term objects.     _prime_term_caches( $term_ids );

    $terms = array();
    foreach ( $term_ids as $term_id ) {
        $term = get_term( $term_id$taxonomy );
        if ( is_wp_error( $term ) ) {
            return $term;
        }

        $terms[] = $term;
    }

    
$post_ids[] = (int) $object_id;
        } elseif ( 'taxonomy' === $type ) {
            $term_ids[] = (int) $object_id;
        }
    }

    if ( ! empty( $post_ids ) ) {
        _prime_post_caches( $post_ids, false );
    }

    if ( ! empty( $term_ids ) ) {
        _prime_term_caches( $term_ids );
    }
}

/** * Decorates a menu item object with the shared navigation menu item properties. * * Properties: * - ID: The term_id if the menu item represents a taxonomy term. * - attr_title: The title attribute of the link element for this menu item. * - classes: The array of class attribute values for the link element of this menu item. * - db_id: The DB ID of this item as a nav_menu_item object, if it exists (0 if it doesn't exist). * - description: The description of this menu item. * - menu_item_parent: The DB ID of the nav_menu_item that is this item's menu parent, if any. 0 otherwise. * - object: The type of object originally represented, such as 'category', 'post', or 'attachment'. * - object_id: The DB ID of the original object this menu item represents, e.g. ID for posts and term_id for categories. * - post_parent: The DB ID of the original object's parent object, if any (0 otherwise). * - post_title: A "no title" label if menu item represents a post that lacks a title. * - target: The target attribute of the link element for this menu item. * - title: The title of this menu item. * - type: The family of objects originally represented, such as 'post_type' or 'taxonomy'. * - type_label: The singular label used to describe this type of menu item. * - url: The URL to which this menu item points. * - xfn: The XFN relationship expressed in the link of this menu item. * - _invalid: Whether the menu item represents an object that no longer exists. * * @since 3.0.0 * * @param object $menu_item The menu item to modify. * @return object The menu item with standard menu item properties. */
Home | Imprint | This part of the site doesn't use cookies.