wp_should_upgrade_global_tables

函数
wp_should_upgrade_global_tables ( No parameters )
返回值
  • (bool) Whether to run the upgrade routines on global tables.
定义位置
相关方法
wp_get_global_styleswp_enqueue_global_styleswp_get_global_stylesheetwp_filter_global_styles_postwp_cache_add_global_groups
引入
4.3.0
弃用
-

wp_should_upgrade_global_tables是一个用来确定是否应该升级WordPress站点的全局数据库表的函数。

确定全局表是否应该被升级。

这个函数执行一系列的检查,以确保环境允许全局WordPress数据库表的安全升级。它是必要的,因为全局表在大型安装中通常会增长到数百万行,而控制其升级程序的权限对大型网络的运行至关重要。

在未来的迭代中,这个函数可能会使用`wp_is_large_network()`来更智能地防止全局表的升级。在那之前,我们要确保WordPress是在主网络的主站点上,以避免在多站点或多网络环境中多次运行查询。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function wp_should_upgrade_global_tables() {
// Return false early if explicitly not upgrading.
if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
return false;
}
// Assume global tables should be upgraded.
$should_upgrade = true;
// Set to false if not on main network (does not matter if not multi-network).
if ( ! is_main_network() ) {
$should_upgrade = false;
}
// Set to false if not on main site of current network (does not matter if not multi-site).
if ( ! is_main_site() ) {
$should_upgrade = false;
}
/**
* Filters if upgrade routines should be run on global tables.
*
* @since 4.3.0
*
* @param bool $should_upgrade Whether to run the upgrade routines on global tables.
*/
return apply_filters( 'wp_should_upgrade_global_tables', $should_upgrade );
}
function wp_should_upgrade_global_tables() { // Return false early if explicitly not upgrading. if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) { return false; } // Assume global tables should be upgraded. $should_upgrade = true; // Set to false if not on main network (does not matter if not multi-network). if ( ! is_main_network() ) { $should_upgrade = false; } // Set to false if not on main site of current network (does not matter if not multi-site). if ( ! is_main_site() ) { $should_upgrade = false; } /** * Filters if upgrade routines should be run on global tables. * * @since 4.3.0 * * @param bool $should_upgrade Whether to run the upgrade routines on global tables. */ return apply_filters( 'wp_should_upgrade_global_tables', $should_upgrade ); }
function wp_should_upgrade_global_tables() {

	// Return false early if explicitly not upgrading.
	if ( defined( 'DO_NOT_UPGRADE_GLOBAL_TABLES' ) ) {
		return false;
	}

	// Assume global tables should be upgraded.
	$should_upgrade = true;

	// Set to false if not on main network (does not matter if not multi-network).
	if ( ! is_main_network() ) {
		$should_upgrade = false;
	}

	// Set to false if not on main site of current network (does not matter if not multi-site).
	if ( ! is_main_site() ) {
		$should_upgrade = false;
	}

	/**
	 * Filters if upgrade routines should be run on global tables.
	 *
	 * @since 4.3.0
	 *
	 * @param bool $should_upgrade Whether to run the upgrade routines on global tables.
	 */
	return apply_filters( 'wp_should_upgrade_global_tables', $should_upgrade );
}

常见问题

FAQs
查看更多 >