ACF_Admin_Upgrade::check_for_network_upgrades()
Checks if an ACF database upgrade is required on any site in the multisite network.
Stores the result in $this->network_upgrade_needed_transient, which is version-linked to ACF_UPGRADE_VERSION: the highest ACF version that requires an upgrade function to run. Bumping ACF_UPGRADE_VERSION will trigger new upgrade checks but incrementing ACF_VERSION alone will not.
Метод класса: ACF_Admin_Upgrade{}
Хуков нет.
Возвращает
Строку
. 'yes' if any site in the network requires an upgrade, otherwise 'no'. String instead of boolean so that false returned from a get_site_transient check can denote that an upgrade check is needed.
Использование
$ACF_Admin_Upgrade = new ACF_Admin_Upgrade(); $ACF_Admin_Upgrade->check_for_network_upgrades();
Список изменений
С версии 6.0.0 | Введена. |
Код ACF_Admin_Upgrade::check_for_network_upgrades() ACF Admin Upgrade::check for network upgrades ACF 6.0.4
public function check_for_network_upgrades() { $network_upgrade_needed = 'no'; $sites = get_sites( array( 'number' => 0, 'fields' => 'ids', // Reduces PHP memory usage. ) ); if ( $sites ) { // Reduces memory usage (same pattern used in wp-includes/ms-site.php). remove_action( 'switch_blog', 'wp_switch_roles_and_user', 1 ); foreach ( $sites as $site_id ) { switch_to_blog( $site_id ); $site_needs_upgrade = acf_has_upgrade(); restore_current_blog(); // Restores global vars. if ( $site_needs_upgrade ) { $network_upgrade_needed = 'yes'; break; } } add_action( 'switch_blog', 'wp_switch_roles_and_user', 1, 2 ); } set_site_transient( $this->network_upgrade_needed_transient, $network_upgrade_needed, 3 * MONTH_IN_SECONDS ); return $network_upgrade_needed; }