_prime_site_caches

函式
_prime_site_caches ( $ids, $update_meta_cache = true )
引數
  • (array) $ids ID list.
    Required:
  • (bool) $update_meta_cache Optional. Whether to update the meta cache. Default true.
    Required:
    Default: true
相關
  • update_site_cache()
定義位置
相關方法
_prime_term_caches_prime_post_caches_prime_comment_caches_prime_network_cachesupdate_site_cache
引入
4.6.0
棄用
-

_prime_site_caches: 該函式用於為給定的網站列表填充快取。它執行資料庫查詢以檢索網站列表,然後對結果進行快取以提高效能。

從給定的ID中新增任何不存在於快取中的網站到快取中。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function _prime_site_caches( $ids, $update_meta_cache = true ) {
global $wpdb;
$non_cached_ids = _get_non_cached_ids( $ids, 'sites' );
if ( ! empty( $non_cached_ids ) ) {
$fresh_sites = $wpdb->get_results( sprintf( "SELECT * FROM $wpdb->blogs WHERE blog_id IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
update_site_cache( $fresh_sites, $update_meta_cache );
}
}
function _prime_site_caches( $ids, $update_meta_cache = true ) { global $wpdb; $non_cached_ids = _get_non_cached_ids( $ids, 'sites' ); if ( ! empty( $non_cached_ids ) ) { $fresh_sites = $wpdb->get_results( sprintf( "SELECT * FROM $wpdb->blogs WHERE blog_id IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared update_site_cache( $fresh_sites, $update_meta_cache ); } }
function _prime_site_caches( $ids, $update_meta_cache = true ) {
	global $wpdb;

	$non_cached_ids = _get_non_cached_ids( $ids, 'sites' );
	if ( ! empty( $non_cached_ids ) ) {
		$fresh_sites = $wpdb->get_results( sprintf( "SELECT * FROM $wpdb->blogs WHERE blog_id IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared

		update_site_cache( $fresh_sites, $update_meta_cache );
	}
}

常見問題

FAQs
檢視更多 >