ure. */ protected function enable_search() { Jetpack_Search_Main::init(); } /** * Enables the Publicize feature. */ protected function enable_publicize() { Publicize_Setup::configure(); return true; } /** * Handles Publicize options. */ protected function ensure_options_publicize() { $options = $this->get_feature_options( 'publicize' ); if ( ! empty( $options['force_refresh'] ) ) { Publicize_Setup::$refresh_plan_info = true; } } /** * Enables WordAds. */ protected function enable_wordads() { Jetpack_WordAds_Main::init(); } /** * Enables Waf. */ protected function enable_waf() { Jetpack_Waf_Main::init(); return true; } /** * Enables VideoPress. */ protected function enable_videopress() { VideoPress_Pkg_Initializer::init(); return true; } /** * Enables Stats. */ protected function enable_stats() { Stats_Main::init(); return true; } /** * Enables Stats Admin. */ protected function enable_stats_admin() { Stats_Admin_Main::init(); return true; } /** * Handles VideoPress options */ protected function ensure_options_videopress() { $options = $this->get_feature_options( 'videopress' ); if ( ! empty( $options ) ) { VideoPress_Pkg_Initializer::update_init_options( $options ); } return true; } /** * Enables Blaze. */ protected function enable_blaze() { Blaze::init(); return true; } /** * Enables Yoast Promo. */ protected function enable_yoast_promo() { Yoast_Promo::init(); return true; } /** * Enables the Import feature. */ protected function enable_import() { Import_Main::configure(); return true; } /** * Setup the Connection options. */ protected function ensure_options_connection() { $options = $this->get_feature_options( 'connection' ); if ( ! empty( $options['slug'] ) ) { // The `slug` and `name` are removed from the options because they need to be passed as arguments. $slug = $options['slug']; unset( $options['slug'] ); $name = $slug; if ( ! empty( $options['name'] ) ) { $name = $options['name']; unset( $options['name'] ); } ( new Plugin( $slug ) )->add( $name, $options ); } return true; } /** * Setup the Identity Crisis options. * * @return bool */ protected function ensure_options_identity_crisis() { $options = $this->get_feature_options( 'identity_crisis' ); if ( is_array( $options ) && count( $options ) ) { add_filter( 'jetpack_idc_consumers', function ( $consumers ) use ( $options ) { $consumers[] = $options; return $consumers; } ); } return true; } /** * Setup the Sync options. */ protected function ensure_options_sync() { $options = $this->get_feature_options( 'sync' ); if ( method_exists( 'Automattic\Jetpack\Sync\Main', 'set_sync_data_options' ) ) { Sync_Main::set_sync_data_options( $options ); } return true; } /** * Temporary save initialization options for a feature. * * @param string $feature The feature slug. * @param array $options The options. * * @return bool */ protected function set_feature_options( $feature, array $options ) { if ( $options ) { $this->feature_options[ $feature ] = $options; } return true; } /** * Get initialization options for a feature from the temporary storage. * * @param string $feature The feature slug. * * @return array */ protected function get_feature_options( $feature ) { return empty( $this->feature_options[ $feature ] ) ? array() : $this->feature_options[ $feature ]; } }