load_textdomain(); $this->setup(); // Init Modules new Air_WP_Sync_Post_Module(); new Air_WP_Sync_User_Module(); new Air_WP_Sync_Term_Module(); $this->load_importers(); // Admin if ( is_admin() ) { new Air_WP_Sync_Admin( ); } // Initalize WP_CLI only in cli mode if ( class_exists( 'WP_CLI' ) ) { WP_CLI::add_command( 'air-wp-sync', new Air_WP_Sync_CLI( ) ); } new Air_WP_Sync_Action_Consumer( ); // Init Sources new Air_WP_Sync_Barcode_Source(); new Air_WP_Sync_Collaborator_Source(); new Air_WP_Sync_Link_To_Another_Record_Source(); new Air_WP_Sync_Formula_Source(); new Air_WP_Sync_Unsupported_Source(); // Init Destinations with Formatters do_action( 'airwpsync/register_destination' ); } /** * Checks if another version of Air WP Sync free/pro is active and deactivates it. * Hooked on `activated_plugin` so other plugin is deactivated when current plugin is activated. * * @param string $plugin The plugin being activated. */ public function deactivate_other_instances( $plugin ) { if ( ! in_array( $plugin, array( 'air-wp-sync/air-wp-sync.php', 'air-wp-sync-pro/air-wp-sync.php', 'air-wp-sync-pro-plus/air-wp-sync.php' ), true ) ) { return; } $plugin_to_deactivate = ['air-wp-sync/air-wp-sync.php']; $deactivated_notice_id = '1'; // If we just activated the free version, deactivate the pro version. if ( in_array($plugin, $plugin_to_deactivate, true ) ) { $plugin_to_deactivate = ['air-wp-sync-pro/air-wp-sync.php', 'air-wp-sync-pro-plus/air-wp-sync.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 ( in_array($plugin_basename, $plugin_to_deactivate, true ) ) { set_transient( 'airwpsync_deactivated_notice_id', $deactivated_notice_id, 1 * HOUR_IN_SECONDS ); deactivate_plugins( $plugin_basename ); return; } } } /** * Displays a notice when either ACF or ACF PRO is automatically deactivated. */ public function plugin_deactivated_notice() { $deactivated_notice_id = (int) get_transient( 'airwpsync_deactivated_notice_id' ); if ( ! in_array( $deactivated_notice_id, array( 1, 2 ), true ) ) { return; } $message = __( "Air WP Sync and Air WP Sync Pro should not be active at the same time. We've automatically deactivated Air WP Sync.", 'air-wp-sync' ); if ( 2 === $deactivated_notice_id ) { $message = __( "Air WP Sync and Air WP Sync Pro should not be active at the same time. We've automatically deactivated Air WP Sync Pro.", 'air-wp-sync' ); } ?>