ACF::deactivate_other_instances()
Checks if another version of ACF/ACF PRO is active and deactivates it. Hooked on activated_plugin other plugin is deactivated when current plugin is activated.
Метод класса: ACF{}
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
$ACF = new ACF(); $ACF->deactivate_other_instances( $plugin );
- $plugin(строка) (обязательный)
- The plugin being activated.
Код ACF::deactivate_other_instances() ACF::deactivate other instances ACF 6.0.4
public function deactivate_other_instances( $plugin ) { if ( ! in_array( $plugin, array( 'advanced-custom-fields/acf.php', 'advanced-custom-fields-pro/acf.php' ), true ) ) { return; } $plugin_to_deactivate = 'advanced-custom-fields/acf.php'; $deactivated_notice_id = '1'; // If we just activated the free version, deactivate the pro version. if ( $plugin === $plugin_to_deactivate ) { $plugin_to_deactivate = 'advanced-custom-fields-pro/acf.php'; $deactivated_notice_id = '2'; } if ( is_multisite() && is_network_admin() ) { $active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() ); $active_plugins = array_keys( $active_plugins ); } else { $active_plugins = (array) get_option( 'active_plugins', array() ); } foreach ( $active_plugins as $plugin_basename ) { if ( $plugin_to_deactivate === $plugin_basename ) { set_transient( 'acf_deactivated_notice_id', $deactivated_notice_id, 1 * HOUR_IN_SECONDS ); deactivate_plugins( $plugin_basename ); return; } } }