函数文档

wp_schedule_update_network_counts()

💡 云策文档标注

概述

wp_schedule_update_network_counts() 函数用于调度当前网络的全网计数更新任务。它仅在主站点且未处于安装模式时,安排一个每日两次的定时事件。

关键要点

  • 函数仅在 is_main_site() 返回 true 时执行,否则直接返回。
  • 使用 wp_next_scheduled() 检查 'update_network_counts' 事件是否已安排,避免重复调度。
  • 在未安装模式下,通过 wp_schedule_event() 安排 'update_network_counts' 为 'twicedaily' 频率。
  • 相关函数包括 wp_installing()、wp_next_scheduled()、wp_schedule_event() 和 is_main_site()。
  • 自 WordPress 3.1.0 版本引入。

📄 原文内容

Schedules update of the network-wide counts for the current network.

Source

function wp_schedule_update_network_counts() {
	if ( ! is_main_site() ) {
		return;
	}

	if ( ! wp_next_scheduled( 'update_network_counts' ) && ! wp_installing() ) {
		wp_schedule_event( time(), 'twicedaily', 'update_network_counts' );
	}
}

Changelog

Version Description
3.1.0 Introduced.