initial
This commit is contained in:
+286
@@ -0,0 +1,286 @@
|
||||
# Changelog
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [3.1.3] - 2026-05-19
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [3.1.2] - 2026-05-04
|
||||
### Changed
|
||||
- Internal: No longer require automattic/jetpack-changelogger as a per-project dev dependency. [#48225]
|
||||
|
||||
## [3.1.1] - 2025-06-19
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [3.1.0] - 2025-03-26
|
||||
### Added
|
||||
- Adds Account Protection initialization [#40925]
|
||||
|
||||
## [3.0.1] - 2025-02-24
|
||||
### Changed
|
||||
- Update dependencies.
|
||||
|
||||
## [3.0.0] - 2024-11-14
|
||||
### Removed
|
||||
- General: Update minimum PHP version to 7.2. [#40147]
|
||||
|
||||
## [2.0.4] - 2024-06-24
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [2.0.3] - 2024-06-03
|
||||
### Removed
|
||||
- Remove the Identity Crisis package dev dependency. [#37654]
|
||||
|
||||
## [2.0.2] - 2024-05-06
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [2.0.1] - 2024-03-14
|
||||
### Changed
|
||||
- Internal updates.
|
||||
|
||||
## [2.0.0] - 2023-11-20
|
||||
### Changed
|
||||
- Updated required PHP version to >= 7.0. [#34192]
|
||||
|
||||
## [1.15.4] - 2023-09-19
|
||||
|
||||
- Minor internal updates.
|
||||
|
||||
## [1.15.3] - 2023-06-26
|
||||
### Changed
|
||||
- Blaze can now be loaded as a module, instead of relying on the Config package. [#31479]
|
||||
|
||||
## [1.15.2] - 2023-04-10
|
||||
### Added
|
||||
- Add Jetpack Autoloader package suggestion. [#29988]
|
||||
|
||||
## [1.15.1] - 2023-03-28
|
||||
### Changed
|
||||
- Minor internal updates.
|
||||
|
||||
## [1.15.0] - 2023-03-27
|
||||
### Added
|
||||
- Initialize yoast promo package in jetpack plugin [#29641]
|
||||
|
||||
## [1.14.0] - 2023-02-20
|
||||
### Added
|
||||
- Added the Import package. [#28824]
|
||||
|
||||
## [1.13.0] - 2023-01-02
|
||||
### Added
|
||||
- Blaze package: Add config initialization, initialization checks for loading. [#28077]
|
||||
|
||||
## [1.12.0] - 2022-12-12
|
||||
### Added
|
||||
- Config: add option to init stats-admin [#27565]
|
||||
|
||||
## [1.11.1] - 2022-11-22
|
||||
### Changed
|
||||
- Updated package dependencies. [#27043]
|
||||
|
||||
## [1.11.0] - 2022-10-11
|
||||
### Changed
|
||||
- Integrate Stats package in Jetpack plugin [#26640]
|
||||
|
||||
## [1.10.0] - 2022-09-27
|
||||
### Added
|
||||
- Social: Added the option to configure if the plan information should be refreshed as the package is enabled. [#26294]
|
||||
|
||||
## [1.9.6] - 2022-08-26
|
||||
### Changed
|
||||
- Call ensure_options_$feature methods before the initialization
|
||||
|
||||
## [1.9.5] - 2022-08-23
|
||||
### Changed
|
||||
- Initialize VideoPress admin UI from the package [#25692]
|
||||
|
||||
## [1.9.4] - 2022-08-09
|
||||
### Changed
|
||||
- Initialize VideoPress package from the Config pkg [#25385]
|
||||
|
||||
## [1.9.3] - 2022-07-26
|
||||
### Changed
|
||||
- Updated package dependencies. [#25158]
|
||||
|
||||
## [1.9.2] - 2022-06-29
|
||||
|
||||
- Updated package dependencies.
|
||||
|
||||
## [1.9.1] - 2022-06-21
|
||||
### Changed
|
||||
- Renaming master to trunk.
|
||||
|
||||
## [1.9.0] - 2022-05-18
|
||||
### Added
|
||||
- Configuration for waf package [#24153]
|
||||
|
||||
## [1.8.0] - 2022-04-26
|
||||
### Added
|
||||
- Added the publicize package to be configured via the config package.
|
||||
|
||||
### Changed
|
||||
- Updated package dependencies.
|
||||
|
||||
## [1.7.2] - 2022-04-19
|
||||
### Added
|
||||
- Enable WordAds from Config class
|
||||
|
||||
## [1.7.1] - 2022-04-06
|
||||
### Removed
|
||||
- Removed tracking dependency.
|
||||
|
||||
## [1.7.0] - 2022-03-23
|
||||
### Added
|
||||
- Search: added search initialization
|
||||
|
||||
## [1.6.1] - 2022-02-09
|
||||
### Added
|
||||
- Allow sync package consumers to provide custom data settings.
|
||||
|
||||
## [1.6.0] - 2022-01-04
|
||||
### Added
|
||||
- Accept options for the IDC package.
|
||||
|
||||
### Changed
|
||||
- Updated package textdomain from `jetpack` to `jetpack-config`.
|
||||
|
||||
## [1.5.4] - 2021-12-14
|
||||
### Changed
|
||||
- Updated package dependencies.
|
||||
|
||||
## [1.5.3] - 2021-10-13
|
||||
### Changed
|
||||
- Updated package dependencies.
|
||||
|
||||
## [1.5.2] - 2021-10-12
|
||||
### Added
|
||||
- Add support for the identity-crisis package
|
||||
|
||||
## [1.5.1] - 2021-09-28
|
||||
### Changed
|
||||
- Updated package dependencies.
|
||||
|
||||
## [1.5.0] - 2021-09-22
|
||||
### Added
|
||||
- Allow for enabling and initializing new Post_List package from Config package.
|
||||
|
||||
## [1.4.7] - 2021-08-31
|
||||
### Changed
|
||||
- updates annotations versions.
|
||||
|
||||
## [1.4.6] - 2021-05-25
|
||||
### Changed
|
||||
- Updated package dependencies.
|
||||
|
||||
## [1.4.5] - 2021-04-27
|
||||
### Changed
|
||||
- Updated package dependencies.
|
||||
|
||||
## [1.4.4] - 2021-03-30
|
||||
### Added
|
||||
- Composer alias for dev-master, to improve dependencies
|
||||
|
||||
### Changed
|
||||
- Update package dependencies.
|
||||
|
||||
## [1.4.3] - 2021-01-19
|
||||
|
||||
- Add mirror-repo information to all current composer packages
|
||||
- Monorepo: Reorganize all projects
|
||||
|
||||
## [1.4.2] - 2020-10-28
|
||||
|
||||
- Updated PHPCS: Packages and Debugger
|
||||
- Config: remove tos and tracking features
|
||||
- Config: add info about the package dependencies to the package docs
|
||||
|
||||
## [1.4.1] - 2020-09-15
|
||||
|
||||
- Config: remove tos and tracking features
|
||||
|
||||
## [1.4.0] - 2020-08-26
|
||||
|
||||
- Config: Remove composer dependencies
|
||||
- Config: Add connection status check
|
||||
|
||||
## [1.3.0] - 2020-06-26
|
||||
|
||||
- Config: check for both JITM namespaces
|
||||
|
||||
## [1.2.0] - 2020-05-20
|
||||
|
||||
- Store the list of active plugins that uses connection in an option
|
||||
- Implement pre-connection JITMs
|
||||
- Connection Package: Handle disconnections gracefully
|
||||
|
||||
## [1.1.0] - 2020-01-23
|
||||
|
||||
- Moved JITM initialization to plugins_loaded.
|
||||
|
||||
## [1.0.1] - 2020-01-20
|
||||
|
||||
- Move connection manager related logic to after plugins_loaded.
|
||||
|
||||
## 1.0.0 - 2020-01-14
|
||||
|
||||
- Trying to add deterministic initialization.
|
||||
|
||||
[3.1.3]: https://github.com/Automattic/jetpack-config/compare/v3.1.2...v3.1.3
|
||||
[3.1.2]: https://github.com/Automattic/jetpack-config/compare/v3.1.1...v3.1.2
|
||||
[3.1.1]: https://github.com/Automattic/jetpack-config/compare/v3.1.0...v3.1.1
|
||||
[3.1.0]: https://github.com/Automattic/jetpack-config/compare/v3.0.1...v3.1.0
|
||||
[3.0.1]: https://github.com/Automattic/jetpack-config/compare/v3.0.0...v3.0.1
|
||||
[3.0.0]: https://github.com/Automattic/jetpack-config/compare/v2.0.4...v3.0.0
|
||||
[2.0.4]: https://github.com/Automattic/jetpack-config/compare/v2.0.3...v2.0.4
|
||||
[2.0.3]: https://github.com/Automattic/jetpack-config/compare/v2.0.2...v2.0.3
|
||||
[2.0.2]: https://github.com/Automattic/jetpack-config/compare/v2.0.1...v2.0.2
|
||||
[2.0.1]: https://github.com/Automattic/jetpack-config/compare/v2.0.0...v2.0.1
|
||||
[2.0.0]: https://github.com/Automattic/jetpack-config/compare/v1.15.4...v2.0.0
|
||||
[1.15.4]: https://github.com/Automattic/jetpack-config/compare/v1.15.3...v1.15.4
|
||||
[1.15.3]: https://github.com/Automattic/jetpack-config/compare/v1.15.2...v1.15.3
|
||||
[1.15.2]: https://github.com/Automattic/jetpack-config/compare/v1.15.1...v1.15.2
|
||||
[1.15.1]: https://github.com/Automattic/jetpack-config/compare/v1.15.0...v1.15.1
|
||||
[1.15.0]: https://github.com/Automattic/jetpack-config/compare/v1.14.0...v1.15.0
|
||||
[1.14.0]: https://github.com/Automattic/jetpack-config/compare/v1.13.0...v1.14.0
|
||||
[1.13.0]: https://github.com/Automattic/jetpack-config/compare/v1.12.0...v1.13.0
|
||||
[1.12.0]: https://github.com/Automattic/jetpack-config/compare/v1.11.1...v1.12.0
|
||||
[1.11.1]: https://github.com/Automattic/jetpack-config/compare/v1.11.0...v1.11.1
|
||||
[1.11.0]: https://github.com/Automattic/jetpack-config/compare/v1.10.0...v1.11.0
|
||||
[1.10.0]: https://github.com/Automattic/jetpack-config/compare/v1.9.6...v1.10.0
|
||||
[1.9.6]: https://github.com/Automattic/jetpack-config/compare/v1.9.5...v1.9.6
|
||||
[1.9.5]: https://github.com/Automattic/jetpack-config/compare/v1.9.4...v1.9.5
|
||||
[1.9.4]: https://github.com/Automattic/jetpack-config/compare/v1.9.3...v1.9.4
|
||||
[1.9.3]: https://github.com/Automattic/jetpack-config/compare/v1.9.2...v1.9.3
|
||||
[1.9.2]: https://github.com/Automattic/jetpack-config/compare/v1.9.1...v1.9.2
|
||||
[1.9.1]: https://github.com/Automattic/jetpack-config/compare/v1.9.0...v1.9.1
|
||||
[1.9.0]: https://github.com/Automattic/jetpack-config/compare/v1.8.0...v1.9.0
|
||||
[1.8.0]: https://github.com/Automattic/jetpack-config/compare/v1.7.2...v1.8.0
|
||||
[1.7.2]: https://github.com/Automattic/jetpack-config/compare/v1.7.1...v1.7.2
|
||||
[1.7.1]: https://github.com/Automattic/jetpack-config/compare/v1.7.0...v1.7.1
|
||||
[1.7.0]: https://github.com/Automattic/jetpack-config/compare/v1.6.1...v1.7.0
|
||||
[1.6.1]: https://github.com/Automattic/jetpack-config/compare/v1.6.0...v1.6.1
|
||||
[1.6.0]: https://github.com/Automattic/jetpack-config/compare/v1.5.4...v1.6.0
|
||||
[1.5.4]: https://github.com/Automattic/jetpack-config/compare/v1.5.3...v1.5.4
|
||||
[1.5.3]: https://github.com/Automattic/jetpack-config/compare/v1.5.2...v1.5.3
|
||||
[1.5.2]: https://github.com/Automattic/jetpack-config/compare/v1.5.1...v1.5.2
|
||||
[1.5.1]: https://github.com/Automattic/jetpack-config/compare/v1.5.0...v1.5.1
|
||||
[1.5.0]: https://github.com/Automattic/jetpack-config/compare/v1.4.7...v1.5.0
|
||||
[1.4.7]: https://github.com/Automattic/jetpack-config/compare/v1.4.6...v1.4.7
|
||||
[1.4.6]: https://github.com/Automattic/jetpack-config/compare/v1.4.5...v1.4.6
|
||||
[1.4.5]: https://github.com/Automattic/jetpack-config/compare/v1.4.4...v1.4.5
|
||||
[1.4.4]: https://github.com/Automattic/jetpack-config/compare/v1.4.3...v1.4.4
|
||||
[1.4.3]: https://github.com/Automattic/jetpack-config/compare/v1.4.2...v1.4.3
|
||||
[1.4.2]: https://github.com/Automattic/jetpack-config/compare/v1.4.1...v1.4.2
|
||||
[1.4.1]: https://github.com/Automattic/jetpack-config/compare/v1.4.0...v1.4.1
|
||||
[1.4.0]: https://github.com/Automattic/jetpack-config/compare/v1.3.0...v1.4.0
|
||||
[1.3.0]: https://github.com/Automattic/jetpack-config/compare/v1.2.0...v1.3.0
|
||||
[1.2.0]: https://github.com/Automattic/jetpack-config/compare/v1.1.0...v1.2.0
|
||||
[1.1.0]: https://github.com/Automattic/jetpack-config/compare/v1.0.1...v1.1.0
|
||||
[1.0.1]: https://github.com/Automattic/jetpack-config/compare/v1.0.0...v1.0.1
|
||||
+458
@@ -0,0 +1,458 @@
|
||||
<?php
|
||||
/**
|
||||
* The base Jetpack configuration class file.
|
||||
*
|
||||
* @package automattic/jetpack-config
|
||||
*/
|
||||
|
||||
namespace Automattic\Jetpack;
|
||||
|
||||
/*
|
||||
* The Config package does not require the composer packages that
|
||||
* contain the package classes shown below. The consumer plugin
|
||||
* must require the corresponding packages to use these features.
|
||||
*/
|
||||
use Automattic\Jetpack\Account_Protection\Account_Protection as Jetpack_Account_Protection_Main;
|
||||
use Automattic\Jetpack\Connection\Manager;
|
||||
use Automattic\Jetpack\Connection\Plugin;
|
||||
use Automattic\Jetpack\Import\Main as Import_Main;
|
||||
use Automattic\Jetpack\JITMS\JITM as JITMS_JITM;
|
||||
use Automattic\Jetpack\Post_List\Post_List;
|
||||
use Automattic\Jetpack\Publicize\Publicize_Setup;
|
||||
use Automattic\Jetpack\Search\Initializer as Jetpack_Search_Main;
|
||||
use Automattic\Jetpack\Stats\Main as Stats_Main;
|
||||
use Automattic\Jetpack\Stats_Admin\Main as Stats_Admin_Main;
|
||||
use Automattic\Jetpack\Sync\Main as Sync_Main;
|
||||
use Automattic\Jetpack\VideoPress\Initializer as VideoPress_Pkg_Initializer;
|
||||
use Automattic\Jetpack\Waf\Waf_Initializer as Jetpack_Waf_Main;
|
||||
|
||||
/**
|
||||
* The configuration class.
|
||||
*/
|
||||
class Config {
|
||||
|
||||
const FEATURE_ENSURED = 1;
|
||||
const FEATURE_NOT_AVAILABLE = 0;
|
||||
const FEATURE_ALREADY_ENSURED = -1;
|
||||
|
||||
/**
|
||||
* The initial setting values.
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
protected $config = array(
|
||||
'jitm' => false,
|
||||
'connection' => false,
|
||||
'sync' => false,
|
||||
'post_list' => false,
|
||||
'identity_crisis' => false,
|
||||
'search' => false,
|
||||
'publicize' => false,
|
||||
'account_protection' => false,
|
||||
'waf' => false,
|
||||
'videopress' => false,
|
||||
'stats' => false,
|
||||
'stats_admin' => false,
|
||||
'yoast_promo' => false,
|
||||
'import' => false,
|
||||
);
|
||||
|
||||
/**
|
||||
* Initialization options stored here.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $feature_options = array();
|
||||
|
||||
/**
|
||||
* Creates the configuration class instance.
|
||||
*/
|
||||
public function __construct() {
|
||||
/**
|
||||
* Adding the config handler to run on priority 2 because the class itself is
|
||||
* being constructed on priority 1.
|
||||
*/
|
||||
add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ), 2 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Require a feature to be initialized. It's up to the package consumer to actually add
|
||||
* the package to their composer project. Declaring a requirement using this method
|
||||
* instructs the class to initialize it.
|
||||
*
|
||||
* Run the options method (if exists) every time the method is called.
|
||||
*
|
||||
* @param String $feature the feature slug.
|
||||
* @param array $options Additional options, optional.
|
||||
*/
|
||||
public function ensure( $feature, array $options = array() ) {
|
||||
$this->config[ $feature ] = true;
|
||||
|
||||
$this->set_feature_options( $feature, $options );
|
||||
|
||||
$method_options = 'ensure_options_' . $feature;
|
||||
if ( method_exists( $this, $method_options ) ) {
|
||||
$this->{ $method_options }();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs on plugins_loaded hook priority with priority 2.
|
||||
*
|
||||
* @action plugins_loaded
|
||||
*/
|
||||
public function on_plugins_loaded() {
|
||||
if ( $this->config['connection'] ) {
|
||||
$this->ensure_class( 'Automattic\Jetpack\Connection\Manager' )
|
||||
&& $this->ensure_feature( 'connection' );
|
||||
}
|
||||
|
||||
if ( $this->config['sync'] ) {
|
||||
$this->ensure_class( 'Automattic\Jetpack\Sync\Main' )
|
||||
&& $this->ensure_feature( 'sync' );
|
||||
}
|
||||
|
||||
if ( $this->config['jitm'] ) {
|
||||
// Check for the JITM class in both namespaces. The namespace was changed in jetpack-jitm v1.6.
|
||||
( $this->ensure_class( 'Automattic\Jetpack\JITMS\JITM', false )
|
||||
|| $this->ensure_class( 'Automattic\Jetpack\JITM' ) )
|
||||
&& $this->ensure_feature( 'jitm' );
|
||||
}
|
||||
|
||||
if ( $this->config['post_list'] ) {
|
||||
$this->ensure_class( 'Automattic\Jetpack\Post_List\Post_List' )
|
||||
&& $this->ensure_feature( 'post_list' );
|
||||
}
|
||||
|
||||
if ( $this->config['identity_crisis'] ) {
|
||||
$this->ensure_class( 'Automattic\Jetpack\Identity_Crisis' )
|
||||
&& $this->ensure_feature( 'identity_crisis' );
|
||||
}
|
||||
|
||||
if ( $this->config['search'] ) {
|
||||
$this->ensure_class( 'Automattic\Jetpack\Search\Initializer' )
|
||||
&& $this->ensure_feature( 'search' );
|
||||
}
|
||||
|
||||
if ( $this->config['publicize'] ) {
|
||||
$this->ensure_class( 'Automattic\Jetpack\Publicize\Publicize_UI' ) && $this->ensure_class( 'Automattic\Jetpack\Publicize\Publicize' )
|
||||
&& $this->ensure_feature( 'publicize' );
|
||||
}
|
||||
|
||||
if ( $this->config['account_protection'] ) {
|
||||
$this->ensure_class( 'Automattic\Jetpack\Account_Protection\Account_Protection' )
|
||||
&& $this->ensure_feature( 'account_protection' );
|
||||
}
|
||||
|
||||
if ( $this->config['waf'] ) {
|
||||
$this->ensure_class( 'Automattic\Jetpack\Waf\Waf_Initializer' )
|
||||
&& $this->ensure_feature( 'waf' );
|
||||
}
|
||||
|
||||
if ( $this->config['videopress'] ) {
|
||||
$this->ensure_class( 'Automattic\Jetpack\VideoPress\Initializer' ) && $this->ensure_feature( 'videopress' );
|
||||
}
|
||||
if ( $this->config['stats'] ) {
|
||||
$this->ensure_class( 'Automattic\Jetpack\Stats\Main' ) && $this->ensure_feature( 'stats' );
|
||||
}
|
||||
if ( $this->config['stats_admin'] ) {
|
||||
$this->ensure_class( 'Automattic\Jetpack\Stats_Admin\Main' ) && $this->ensure_feature( 'stats_admin' );
|
||||
}
|
||||
|
||||
if ( $this->config['yoast_promo'] ) {
|
||||
$this->ensure_class( 'Automattic\Jetpack\Yoast_Promo' ) && $this->ensure_feature( 'yoast_promo' );
|
||||
}
|
||||
|
||||
if ( $this->config['import'] ) {
|
||||
$this->ensure_class( 'Automattic\Jetpack\Import\Main' )
|
||||
&& $this->ensure_feature( 'import' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the required class is available and alerts the user if it's not available
|
||||
* in case the site is in debug mode.
|
||||
*
|
||||
* @param String $classname a fully qualified class name.
|
||||
* @param Boolean $log_notice whether the E_USER_NOTICE should be generated if the class is not found.
|
||||
*
|
||||
* @return Boolean whether the class is available.
|
||||
*/
|
||||
protected function ensure_class( $classname, $log_notice = true ) {
|
||||
$available = class_exists( $classname );
|
||||
|
||||
if ( $log_notice && ! $available && defined( 'WP_DEBUG' ) && WP_DEBUG ) {
|
||||
trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
|
||||
sprintf(
|
||||
/* translators: %1$s is a PHP class name. */
|
||||
esc_html__(
|
||||
'Unable to load class %1$s. Please add the package that contains it using composer and make sure you are requiring the Jetpack autoloader',
|
||||
'jetpack-config'
|
||||
),
|
||||
esc_html( $classname )
|
||||
),
|
||||
E_USER_NOTICE
|
||||
);
|
||||
}
|
||||
|
||||
return $available;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures a feature is enabled, sets it up if it hasn't already been set up.
|
||||
*
|
||||
* @param String $feature slug of the feature.
|
||||
* @return Integer either FEATURE_ENSURED, FEATURE_ALREADY_ENSURED or FEATURE_NOT_AVAILABLE constants.
|
||||
*/
|
||||
protected function ensure_feature( $feature ) {
|
||||
$method = 'enable_' . $feature;
|
||||
if ( ! method_exists( $this, $method ) ) {
|
||||
return self::FEATURE_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
if ( did_action( 'jetpack_feature_' . $feature . '_enabled' ) ) {
|
||||
return self::FEATURE_ALREADY_ENSURED;
|
||||
}
|
||||
|
||||
$this->{ $method }();
|
||||
|
||||
/**
|
||||
* Fires when a specific Jetpack package feature is initalized using the Config package.
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
do_action( 'jetpack_feature_' . $feature . '_enabled' );
|
||||
|
||||
return self::FEATURE_ENSURED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the JITM feature.
|
||||
*/
|
||||
protected function enable_jitm() {
|
||||
if ( class_exists( 'Automattic\Jetpack\JITMS\JITM' ) ) {
|
||||
JITMS_JITM::configure();
|
||||
} else {
|
||||
// Provides compatibility with jetpack-jitm <v1.6.
|
||||
// @phan-suppress-next-line PhanUndeclaredClassMethod
|
||||
JITM::configure();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the Post_List feature.
|
||||
*/
|
||||
protected function enable_post_list() {
|
||||
Post_List::configure();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the Sync feature.
|
||||
*/
|
||||
protected function enable_sync() {
|
||||
Sync_Main::configure();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the Connection feature.
|
||||
*/
|
||||
protected function enable_connection() {
|
||||
Manager::configure();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the identity-crisis feature.
|
||||
*/
|
||||
protected function enable_identity_crisis() {
|
||||
Identity_Crisis::init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables the search feature.
|
||||
*/
|
||||
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 Account Protection.
|
||||
*/
|
||||
protected function enable_account_protection() {
|
||||
$account_protection = Jetpack_Account_Protection_Main::instance();
|
||||
$account_protection->initialize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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 ];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user