wp_lazyload_term_meta example

function _prime_term_caches( $term_ids$update_meta_cache = true ) {
    global $wpdb;

    $non_cached_ids = _get_non_cached_ids( $term_ids, 'terms' );
    if ( ! empty( $non_cached_ids ) ) {
        $fresh_terms = $wpdb->get_results( sprintf( "SELECT t.*, tt.* FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) );

        update_term_cache( $fresh_terms );
    }

    if ( $update_meta_cache ) {
        wp_lazyload_term_meta( $term_ids );
    }
}

// // Default callbacks. //
/** * Updates term count based on object types of the current taxonomy. * * Private function for the default callback for post_tag and category * taxonomies. * * @access private * @since 2.3.0 * * @global wpdb $wpdb WordPress database abstraction object. * * @param int[] $terms List of term taxonomy IDs. * @param WP_Taxonomy $taxonomy Current taxonomy object of terms. */
$term_ids[] = (int) $term_id;
                        } elseif ( isset( $term_id->term_id ) ) {
                            $term_ids[] = (int) $term_id->term_id;
                        }
                    }
                }
            }
        }
        $term_ids = array_unique( $term_ids );
    }

    wp_lazyload_term_meta( $term_ids );
}

/** * Updates the custom taxonomies' term counts when a post's status is changed. * * For example, default posts term counts (for custom taxonomies) don't include * private / draft posts. * * @since 3.3.0 * @access private * * @param string $new_status New post status. * @param string $old_status Old post status. * @param WP_Post $post Post object. */
        if ( $hierarchical && $number && is_array( $term_objects ) ) {
            if ( $offset >= count( $term_objects ) ) {
                $term_objects = array();
            } else {
                $term_objects = array_slice( $term_objects$offset$number, true );
            }
        }

        // Prime termmeta cache.         if ( $args['update_term_meta_cache'] ) {
            $term_ids = wp_list_pluck( $term_objects, 'term_id' );
            wp_lazyload_term_meta( $term_ids );
        }

        if ( 'all_with_object_id' === $_fields && ! empty( $args['object_ids'] ) ) {
            $term_cache = array();
            foreach ( $term_objects as $term ) {
                $object            = new stdClass();
                $object->term_id   = $term->term_id;
                $object->object_id = $term->object_id;
                $term_cache[]      = $object;
            }
        } elseif ( 'all' === $_fields && $args['pad_counts'] ) {
            
Home | Imprint | This part of the site doesn't use cookies.