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
檢視更多 >