load_textdomain(); $this->setup(); $this->load_importers(); // Admin if ( is_admin() ) { new Air_WP_Sync_Admin( $this->importers ); } // Initalize WP_CLI only in cli mode if ( class_exists( 'WP_CLI' ) ) { WP_CLI::add_command( 'air-wp-sync', new Air_WP_Sync_CLI( $this->importers ) ); } new Air_WP_Sync_Action_Consumer( $this->importers ); // Init Sources new Air_WP_Sync_Barcode_Source(); new Air_WP_Sync_Collaborator_Source(); new Air_WP_Sync_Unsupported_Source(); // Init Destinations with Formatters new Air_WP_Sync_Post_Destination( new Air_WP_Sync_Markdown_Formatter( new Air_WP_Sync_Parsedown() ), new Air_WP_Sync_Interval_Formatter() ); new Air_WP_Sync_Meta_Destination( new Air_WP_Sync_Markdown_Formatter( new Air_WP_Sync_Parsedown() ), new Air_WP_Sync_Attachments_Formatter() ); new Air_WP_Sync_Taxonomy_Destination( new Air_WP_Sync_Markdown_Formatter( new Air_WP_Sync_Parsedown() ), new Air_WP_Sync_Terms_Formatter(), new Air_WP_Sync_Interval_Formatter() ); } /** * 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' ), 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 ( $plugin === $plugin_to_deactivate ) { $plugin_to_deactivate = 'air-wp-sync-pro/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 ( $plugin_to_deactivate === $plugin_basename ) { 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' ); } ?>

array( 'interval' => 300, 'display' => __( 'Every 5 minutes', 'air-wp-sync' ), ), 'airwpsync_tenminutes' => array( 'interval' => 600, 'display' => __( 'Every 10 minutes', 'air-wp-sync' ), ), 'airwpsync_thirtyminutes' => array( 'interval' => 1800, 'display' => __( 'Every 30 minutes', 'air-wp-sync' ), ), ) ); } /** * Plugin Setup */ protected function setup() { register_post_type( 'airwpsync-connection', array( 'labels' => array( 'name' => __( 'Connections', 'air-wp-sync' ), 'singular_name' => __( 'Connection', 'air-wp-sync' ), 'add_new' => __( 'Add New', 'air-wp-sync' ), 'add_new_item' => __( 'Add New Connection', 'air-wp-sync' ), 'edit_item' => __( 'Edit Connection', 'air-wp-sync' ), 'new_item' => __( 'New Connection', 'air-wp-sync' ), 'view_item' => __( 'View Connection', 'air-wp-sync' ), 'search_items' => __( 'Search Connections', 'air-wp-sync' ), 'not_found' => __( 'No Connections found', 'air-wp-sync' ), 'not_found_in_trash' => __( 'No Connections found in Trash', 'air-wp-sync' ), ), 'public' => false, 'show_ui' => true, 'show_in_menu' => false, '_builtin' => false, 'capability_type' => 'post', 'supports' => array( 'title' ), 'rewrite' => false, 'query_var' => false, ) ); } /** * Load availale importers */ protected function load_importers() { $importer_posts = get_posts( array( 'post_type' => 'airwpsync-connection', 'post_status' => array( 'publish' ), 'posts_per_page' => -1, ) ); foreach ( $importer_posts as $importer_post ) { $this->importers[] = new Air_WP_Sync_Importer( $importer_post ); } } }