wp_queue_comments_for_comment_meta_lazyload

函式
wp_queue_comments_for_comment_meta_lazyload ( $comments )
引數
  • (WP_Comment[]) $comments Array of comment objects.
    Required:
定義位置
相關方法
wp_queue_posts_for_term_meta_lazyloadwp_update_comment_count_nowwp_latest_comments_draft_or_post_titlepost_comment_meta_box_theadpost_comment_meta_box
引入
4.5.0
棄用
-

wp_queue_comments_for_comment_meta_lazyload: 這個函式用來排隊評論,以便懶惰地載入評論後設資料。它通過只在需要時載入評論後設資料來提高網站的效能。

為後設資料的懶載入佇列評論。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_queue_comments_for_comment_meta_lazyload( $comments ) {
// Don't use `wp_list_pluck()` to avoid by-reference manipulation.
$comment_ids = array();
if ( is_array( $comments ) ) {
foreach ( $comments as $comment ) {
if ( $comment instanceof WP_Comment ) {
$comment_ids[] = $comment->comment_ID;
}
}
}
if ( $comment_ids ) {
$lazyloader = wp_metadata_lazyloader();
$lazyloader->queue_objects( 'comment', $comment_ids );
}
}
function wp_queue_comments_for_comment_meta_lazyload( $comments ) { // Don't use `wp_list_pluck()` to avoid by-reference manipulation. $comment_ids = array(); if ( is_array( $comments ) ) { foreach ( $comments as $comment ) { if ( $comment instanceof WP_Comment ) { $comment_ids[] = $comment->comment_ID; } } } if ( $comment_ids ) { $lazyloader = wp_metadata_lazyloader(); $lazyloader->queue_objects( 'comment', $comment_ids ); } }
function wp_queue_comments_for_comment_meta_lazyload( $comments ) {
	// Don't use `wp_list_pluck()` to avoid by-reference manipulation.
	$comment_ids = array();
	if ( is_array( $comments ) ) {
		foreach ( $comments as $comment ) {
			if ( $comment instanceof WP_Comment ) {
				$comment_ids[] = $comment->comment_ID;
			}
		}
	}

	if ( $comment_ids ) {
		$lazyloader = wp_metadata_lazyloader();
		$lazyloader->queue_objects( 'comment', $comment_ids );
	}
}

常見問題

FAQs
檢視更多 >