_prime_post_caches example

if ( $count >= $start ) {
                        $to_display[ $op->ID ] = 0;
                    }

                    $count++;
                }
            }
        }

        $ids = array_keys( $to_display );
        _prime_post_caches( $ids );
        $_posts = array_map( 'get_post', $ids );
        update_post_author_caches( $_posts );

        if ( ! isset( $GLOBALS['post'] ) ) {
            $GLOBALS['post'] = reset( $ids );
        }

        foreach ( $to_display as $page_id => $level ) {
            echo "\t";
            $this->single_row( $page_id$level );
        }
    }
$object_id = get_post_meta( $menu_item->ID, '_menu_item_object_id', true );
        $type      = get_post_meta( $menu_item->ID, '_menu_item_type', true );

        if ( 'post_type' === $type ) {
            $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. */
$classes    = array_merge(
        $colors['css_classes'],
        $font_sizes['css_classes'],
        $is_responsive_menu ? array( 'is-responsive' ) : array(),
        $layout_class ? array( $layout_class ) : array(),
        $is_fallback ? array( 'is-fallback' ) : array(),
        $text_decoration ? array( $text_decoration_class ) : array()
    );

    $post_ids = block_core_navigation_get_post_ids( $inner_blocks );
    if ( $post_ids ) {
        _prime_post_caches( $post_ids, false, false );
    }

    $list_item_nav_blocks = array(
        'core/navigation-link',
        'core/home-link',
        'core/site-title',
        'core/site-logo',
        'core/navigation-submenu',
    );

    $needs_list_item_wrapper = array(
        
if ( 'html5' === $format ) {
            // The title may be filtered: Strip out HTML and make sure the aria-label is never empty.             $title      = trim( strip_tags( $title ) );
            $aria_label = $title ? $title : $default_title;
            $output    .= '<nav aria-label="' . esc_attr( $aria_label ) . '">';
        }

        $output .= '<ul id="' . esc_attr( $recent_comments_id ) . '">';
        if ( is_array( $comments ) && $comments ) {
            // Prime cache for associated posts. (Prime post term cache if we need it for permalinks.)             $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
            _prime_post_caches( $post_idsstrpos( get_option( 'permalink_structure' ), '%category%' ), false );

            foreach ( (array) $comments as $comment ) {
                $output .= '<li class="recentcomments">';
                $output .= sprintf(
                    /* translators: Comments widget. 1: Comment author, 2: Post link. */
                    _x( '%1$s on %2$s', 'widgets' ),
                    '<span class="comment-author-link">' . get_comment_author_link( $comment ) . '</span>',
                    '<a href="' . esc_url( get_comment_link( $comment ) ) . '">' . get_the_title( $comment->comment_post_ID ) . '</a>'
                );
                $output .= '</li>';
            }
        }
'status'      => 'approve',
                'post_status' => 'publish',
            ),
            array()
        )
    );

    $list_items_markup = '';
    if ( ! empty( $comments ) ) {
        // Prime the cache for associated posts. This is copied from \WP_Widget_Recent_Comments::widget().         $post_ids = array_unique( wp_list_pluck( $comments, 'comment_post_ID' ) );
        _prime_post_caches( $post_idsstrpos( get_option( 'permalink_structure' ), '%category%' ), false );

        foreach ( $comments as $comment ) {
            $list_items_markup .= '<li class="wp-block-latest-comments__comment">';
            if ( $attributes['displayAvatar'] ) {
                $avatar = get_avatar(
                    $comment,
                    48,
                    '',
                    '',
                    array(
                        'class' => 'wp-block-latest-comments__comment-avatar',
                    )
$cache_key   = $this->generate_cache_key( $q$new_request );

            $cache_found = false;
            if ( null === $this->posts ) {
                $cached_results = wp_cache_get( $cache_key, 'post-queries', false, $cache_found );

                if ( $cached_results ) {
                    if ( 'ids' === $q['fields'] ) {
                        /** @var int[] */
                        $this->posts = array_map( 'intval', $cached_results['posts'] );
                    } else {
                        _prime_post_caches( $cached_results['posts']$q['update_post_term_cache']$q['update_post_meta_cache'] );
                        /** @var WP_Post[] */
                        $this->posts = array_map( 'get_post', $cached_results['posts'] );
                    }

                    $this->post_count    = count( $this->posts );
                    $this->found_posts   = $cached_results['found_posts'];
                    $this->max_num_pages = $cached_results['max_num_pages'];

                    if ( 'ids' === $q['fields'] ) {
                        return $this->posts;
                    } elseif ( 'id=>parent' === $q['fields'] ) {
                        

    }

    // Reduce the array to unique attachment IDs.     $attachment_ids = array_unique( array_filter( array_values( $images ) ) );

    if ( count( $attachment_ids ) > 1 ) {
        /* * Warm the object cache with post and meta information for all found * images to avoid making individual database calls. */
        _prime_post_caches( $attachment_ids, false, true );
    }

    // Iterate through the matches in order of occurrence as it is relevant for whether or not to lazy-load.     foreach ( $matches as $match ) {
        // Filter an image match.         if ( isset( $images[ $match[0] ] ) ) {
            $filtered_image = $match[0];
            $attachment_id  = $images[ $match[0] ];

            // Add 'width' and 'height' attributes if applicable.             if ( $attachment_id > 0 && ! str_contains( $filtered_image, ' width=' ) && ! str_contains( $filtered_image, ' height=' ) ) {
                
$thumb_ids = array();

    foreach ( $wp_query->posts as $post ) {
        $id = get_post_thumbnail_id( $post->ID );
        if ( $id ) {
            $thumb_ids[] = $id;
        }
    }

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

    $wp_query->thumbnails_cached = true;
}

/** * Retrieves the post thumbnail. * * When a theme adds 'post-thumbnail' support, a special 'post-thumbnail' image size * is registered, which differs from the 'thumbnail' image size managed via the * Settings > Media screen. * * When using the_post_thumbnail() or related functions, the 'post-thumbnail' image * size is used by default, though a different size can be specified instead as needed. * * @since 2.9.0 * @since 4.4.0 `$post` can be a post ID or WP_Post object. * * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`. * @param string|int[] $size Optional. Image size. Accepts any registered image size name, or an array of * width and height values in pixels (in that order). Default 'post-thumbnail'. * @param string|array $attr Optional. Query string or array of attributes. Default empty. * @return string The post thumbnail image tag. */

function update_post_parent_caches( $posts ) {
    $parent_ids = wp_list_pluck( $posts, 'post_parent' );
    $parent_ids = array_map( 'absint', $parent_ids );
    $parent_ids = array_unique( array_filter( $parent_ids ) );

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

/** * Updates metadata cache for a list of post IDs. * * Performs SQL query to retrieve the metadata for the post IDs and updates the * metadata cache for the posts. Therefore, the functions, which call this * function, do not need to perform SQL queries on their own. * * @since 2.1.0 * * @param int[] $post_ids Array of post IDs. * @return array|false An array of metadata on success, false if there is nothing to update. */
$_comments[] = $_comment;
            }
        }

        // Prime comment post caches.         if ( $this->query_vars['update_comment_post_cache'] ) {
            $comment_post_ids = array();
            foreach ( $_comments as $_comment ) {
                $comment_post_ids[] = $_comment->comment_post_ID;
            }

            _prime_post_caches( $comment_post_ids, false, false );
        }

        /** * Filters the comment query results. * * @since 3.1.0 * * @param WP_Comment[] $_comments An array of comments. * @param WP_Comment_Query $query Current instance of WP_Comment_Query (passed by reference). */
        $_comments = apply_filters_ref_array( 'the_comments', array( $_comments, &$this ) );

        
Home | Imprint | This part of the site doesn't use cookies.