load_textdomain(); $this->setup(); $this->load_importers(); // Admin if ( is_admin() ) { new Air_WP_Sync_Admin_Page( $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 ) ); } } /** * Load translations */ public function load_textdomain() { load_plugin_textdomain( 'airwpsync', false, dirname( AIR_WP_SYNC_BASENAME ) . '/languages' ); } /** * Init registered modules */ protected function setup() { register_post_type( 'airwpsync-connection', array( 'labels' => array( 'name' => __( 'Connections', 'airwpsync' ), 'singular_name' => __( 'Connection', 'airwpsync' ), 'add_new' => __( 'Add New', 'airwpsync' ), 'add_new_item' => __( 'Add New Connection', 'airwpsync' ), 'edit_item' => __( 'Edit Connection', 'airwpsync' ), 'new_item' => __( 'New Connection', 'airwpsync' ), 'view_item' => __( 'View Connection', 'airwpsync' ), 'search_items' => __( 'Search Connections', 'airwpsync' ), 'not_found' => __( 'No Connections found', 'airwpsync' ), 'not_found_in_trash' => __( 'No Connections found in Trash', 'airwpsync' ), ), 'public' => false, 'show_ui' => true, 'show_in_menu' => false, '_builtin' => false, 'capability_type' => 'post', 'supports' => array( 'title' ), 'rewrite' => false, 'query_var' => false, ) ); } public function add_cron_schedules( $schedules ) { return array_merge( $schedules, array( 'airwpsync_fiveminutes' => array( 'interval' => 300, 'display' => __( 'Every 5 minutes', 'airwpsync' ), ), 'airwpsync_tenminutes' => array( 'interval' => 600, 'display' => __( 'Every 10 minutes', 'airwpsync' ), ), 'airwpsync_thirtyminutes' => array( 'interval' => 1800, 'display' => __( 'Every 30 minutes', 'airwpsync' ), ), ) ); } 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 ); } } }