ACF_Admin_Upgrade::network_admin_menu()
network_admin_menu
Sets up admin logic if DB Upgrade is required on a multi site.
{} Это метод класса: ACF_Admin_Upgrade{}
Хуков нет.
Возвращает
null
. Ничего.
Использование
$ACF_Admin_Upgrade = new ACF_Admin_Upgrade(); $ACF_Admin_Upgrade->network_admin_menu();
Список изменений
С версии 5.7.4 | Введена. |
Код ACF_Admin_Upgrade::network_admin_menu() ACF Admin Upgrade::network admin menu ACF 5.10.2
function network_admin_menu() { // Vars. $upgrade = false; // Loop over sites and check for upgrades. $sites = get_sites( array( 'number' => 0 ) ); if ( $sites ) { // Unhook action to avoid memory issue (as seen in wp-includes/ms-site.php). remove_action( 'switch_blog', 'wp_switch_roles_and_user', 1 ); foreach ( $sites as $site ) { // Switch site. switch_to_blog( $site->blog_id ); // Check for upgrade. $site_upgrade = acf_has_upgrade(); // Restore site. // Ideally, we would switch back to the original site at after looping, however, // the restore_current_blog() is needed to modify global vars. restore_current_blog(); // Check if upgrade was found. if ( $site_upgrade ) { $upgrade = true; break; } } add_action( 'switch_blog', 'wp_switch_roles_and_user', 1, 2 ); } // Bail early if no upgrade is needed. if ( ! $upgrade ) { return; } // Add notice. add_action( 'network_admin_notices', array( $this, 'network_admin_notices' ) ); // Add page. $page = add_submenu_page( 'index.php', __( 'Upgrade Database', 'acf' ), __( 'Upgrade Database', 'acf' ), acf_get_setting( 'capability' ), 'acf-upgrade-network', array( $this, 'network_admin_html' ) ); add_action( "load-$page", array( $this, 'network_admin_load' ) ); }