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.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / vendor / automattic / jetpack-config / src / class-config.php
woocommerce / vendor / automattic / jetpack-config / src Last commit date
class-config.php 1 year ago
class-config.php
456 lines
1 <?php
2 /**
3 * The base Jetpack configuration class file.
4 *
5 * @package automattic/jetpack-config
6 */
7
8 namespace Automattic\Jetpack;
9
10 /*
11 * The Config package does not require the composer packages that
12 * contain the package classes shown below. The consumer plugin
13 * must require the corresponding packages to use these features.
14 */
15 use Automattic\Jetpack\Connection\Manager;
16 use Automattic\Jetpack\Connection\Plugin;
17 use Automattic\Jetpack\Import\Main as Import_Main;
18 use Automattic\Jetpack\JITMS\JITM as JITMS_JITM;
19 use Automattic\Jetpack\Post_List\Post_List;
20 use Automattic\Jetpack\Publicize\Publicize_Setup;
21 use Automattic\Jetpack\Search\Initializer as Jetpack_Search_Main;
22 use Automattic\Jetpack\Stats\Main as Stats_Main;
23 use Automattic\Jetpack\Stats_Admin\Main as Stats_Admin_Main;
24 use Automattic\Jetpack\Sync\Main as Sync_Main;
25 use Automattic\Jetpack\VideoPress\Initializer as VideoPress_Pkg_Initializer;
26 use Automattic\Jetpack\Waf\Waf_Initializer as Jetpack_Waf_Main;
27 use Automattic\Jetpack\WordAds\Initializer as Jetpack_WordAds_Main;
28
29 /**
30 * The configuration class.
31 */
32 class Config {
33
34 const FEATURE_ENSURED = 1;
35 const FEATURE_NOT_AVAILABLE = 0;
36 const FEATURE_ALREADY_ENSURED = -1;
37
38 /**
39 * The initial setting values.
40 *
41 * @var Array
42 */
43 protected $config = array(
44 'jitm' => false,
45 'connection' => false,
46 'sync' => false,
47 'post_list' => false,
48 'identity_crisis' => false,
49 'search' => false,
50 'publicize' => false,
51 'wordads' => false,
52 'waf' => false,
53 'videopress' => false,
54 'stats' => false,
55 'stats_admin' => false,
56 'yoast_promo' => false,
57 'import' => false,
58 );
59
60 /**
61 * Initialization options stored here.
62 *
63 * @var array
64 */
65 protected $feature_options = array();
66
67 /**
68 * Creates the configuration class instance.
69 */
70 public function __construct() {
71 /**
72 * Adding the config handler to run on priority 2 because the class itself is
73 * being constructed on priority 1.
74 */
75 add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ), 2 );
76 }
77
78 /**
79 * Require a feature to be initialized. It's up to the package consumer to actually add
80 * the package to their composer project. Declaring a requirement using this method
81 * instructs the class to initialize it.
82 *
83 * Run the options method (if exists) every time the method is called.
84 *
85 * @param String $feature the feature slug.
86 * @param array $options Additional options, optional.
87 */
88 public function ensure( $feature, array $options = array() ) {
89 $this->config[ $feature ] = true;
90
91 $this->set_feature_options( $feature, $options );
92
93 $method_options = 'ensure_options_' . $feature;
94 if ( method_exists( $this, $method_options ) ) {
95 $this->{ $method_options }();
96 }
97 }
98
99 /**
100 * Runs on plugins_loaded hook priority with priority 2.
101 *
102 * @action plugins_loaded
103 */
104 public function on_plugins_loaded() {
105 if ( $this->config['connection'] ) {
106 $this->ensure_class( 'Automattic\Jetpack\Connection\Manager' )
107 && $this->ensure_feature( 'connection' );
108 }
109
110 if ( $this->config['sync'] ) {
111 $this->ensure_class( 'Automattic\Jetpack\Sync\Main' )
112 && $this->ensure_feature( 'sync' );
113 }
114
115 if ( $this->config['jitm'] ) {
116 // Check for the JITM class in both namespaces. The namespace was changed in jetpack-jitm v1.6.
117 ( $this->ensure_class( 'Automattic\Jetpack\JITMS\JITM', false )
118 || $this->ensure_class( 'Automattic\Jetpack\JITM' ) )
119 && $this->ensure_feature( 'jitm' );
120 }
121
122 if ( $this->config['post_list'] ) {
123 $this->ensure_class( 'Automattic\Jetpack\Post_List\Post_List' )
124 && $this->ensure_feature( 'post_list' );
125 }
126
127 if ( $this->config['identity_crisis'] ) {
128 $this->ensure_class( 'Automattic\Jetpack\Identity_Crisis' )
129 && $this->ensure_feature( 'identity_crisis' );
130 }
131
132 if ( $this->config['search'] ) {
133 $this->ensure_class( 'Automattic\Jetpack\Search\Initializer' )
134 && $this->ensure_feature( 'search' );
135 }
136
137 if ( $this->config['publicize'] ) {
138 $this->ensure_class( 'Automattic\Jetpack\Publicize\Publicize_UI' ) && $this->ensure_class( 'Automattic\Jetpack\Publicize\Publicize' )
139 && $this->ensure_feature( 'publicize' );
140 }
141
142 if ( $this->config['wordads'] ) {
143 $this->ensure_class( 'Automattic\Jetpack\WordAds\Initializer' )
144 && $this->ensure_feature( 'wordads' );
145 }
146
147 if ( $this->config['waf'] ) {
148 $this->ensure_class( 'Automattic\Jetpack\Waf\Waf_Initializer' )
149 && $this->ensure_feature( 'waf' );
150 }
151
152 if ( $this->config['videopress'] ) {
153 $this->ensure_class( 'Automattic\Jetpack\VideoPress\Initializer' ) && $this->ensure_feature( 'videopress' );
154 }
155 if ( $this->config['stats'] ) {
156 $this->ensure_class( 'Automattic\Jetpack\Stats\Main' ) && $this->ensure_feature( 'stats' );
157 }
158 if ( $this->config['stats_admin'] ) {
159 $this->ensure_class( 'Automattic\Jetpack\Stats_Admin\Main' ) && $this->ensure_feature( 'stats_admin' );
160 }
161
162 if ( $this->config['yoast_promo'] ) {
163 $this->ensure_class( 'Automattic\Jetpack\Yoast_Promo' ) && $this->ensure_feature( 'yoast_promo' );
164 }
165
166 if ( $this->config['import'] ) {
167 $this->ensure_class( 'Automattic\Jetpack\Import\Main' )
168 && $this->ensure_feature( 'import' );
169 }
170 }
171
172 /**
173 * Returns true if the required class is available and alerts the user if it's not available
174 * in case the site is in debug mode.
175 *
176 * @param String $classname a fully qualified class name.
177 * @param Boolean $log_notice whether the E_USER_NOTICE should be generated if the class is not found.
178 *
179 * @return Boolean whether the class is available.
180 */
181 protected function ensure_class( $classname, $log_notice = true ) {
182 $available = class_exists( $classname );
183
184 if ( $log_notice && ! $available && defined( 'WP_DEBUG' ) && WP_DEBUG ) {
185 trigger_error( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
186 sprintf(
187 /* translators: %1$s is a PHP class name. */
188 esc_html__(
189 'Unable to load class %1$s. Please add the package that contains it using composer and make sure you are requiring the Jetpack autoloader',
190 'jetpack-config'
191 ),
192 esc_html( $classname )
193 ),
194 E_USER_NOTICE
195 );
196 }
197
198 return $available;
199 }
200
201 /**
202 * Ensures a feature is enabled, sets it up if it hasn't already been set up.
203 *
204 * @param String $feature slug of the feature.
205 * @return Integer either FEATURE_ENSURED, FEATURE_ALREADY_ENSURED or FEATURE_NOT_AVAILABLE constants.
206 */
207 protected function ensure_feature( $feature ) {
208 $method = 'enable_' . $feature;
209 if ( ! method_exists( $this, $method ) ) {
210 return self::FEATURE_NOT_AVAILABLE;
211 }
212
213 if ( did_action( 'jetpack_feature_' . $feature . '_enabled' ) ) {
214 return self::FEATURE_ALREADY_ENSURED;
215 }
216
217 $this->{ $method }();
218
219 /**
220 * Fires when a specific Jetpack package feature is initalized using the Config package.
221 *
222 * @since 1.1.0
223 */
224 do_action( 'jetpack_feature_' . $feature . '_enabled' );
225
226 return self::FEATURE_ENSURED;
227 }
228
229 /**
230 * Enables the JITM feature.
231 */
232 protected function enable_jitm() {
233 if ( class_exists( 'Automattic\Jetpack\JITMS\JITM' ) ) {
234 JITMS_JITM::configure();
235 } else {
236 // Provides compatibility with jetpack-jitm <v1.6.
237 // @phan-suppress-next-line PhanUndeclaredClassMethod
238 JITM::configure();
239 }
240
241 return true;
242 }
243
244 /**
245 * Enables the Post_List feature.
246 */
247 protected function enable_post_list() {
248 Post_List::configure();
249
250 return true;
251 }
252
253 /**
254 * Enables the Sync feature.
255 */
256 protected function enable_sync() {
257 Sync_Main::configure();
258
259 return true;
260 }
261
262 /**
263 * Enables the Connection feature.
264 */
265 protected function enable_connection() {
266 Manager::configure();
267
268 return true;
269 }
270
271 /**
272 * Enables the identity-crisis feature.
273 */
274 protected function enable_identity_crisis() {
275 Identity_Crisis::init();
276 }
277
278 /**
279 * Enables the search feature.
280 */
281 protected function enable_search() {
282 Jetpack_Search_Main::init();
283 }
284
285 /**
286 * Enables the Publicize feature.
287 */
288 protected function enable_publicize() {
289 Publicize_Setup::configure();
290
291 return true;
292 }
293
294 /**
295 * Handles Publicize options.
296 */
297 protected function ensure_options_publicize() {
298 $options = $this->get_feature_options( 'publicize' );
299
300 if ( ! empty( $options['force_refresh'] ) ) {
301 Publicize_Setup::$refresh_plan_info = true;
302 }
303 }
304
305 /**
306 * Enables WordAds.
307 */
308 protected function enable_wordads() {
309 Jetpack_WordAds_Main::init();
310 }
311
312 /**
313 * Enables Waf.
314 */
315 protected function enable_waf() {
316 Jetpack_Waf_Main::init();
317
318 return true;
319 }
320
321 /**
322 * Enables VideoPress.
323 */
324 protected function enable_videopress() {
325 VideoPress_Pkg_Initializer::init();
326 return true;
327 }
328
329 /**
330 * Enables Stats.
331 */
332 protected function enable_stats() {
333 Stats_Main::init();
334 return true;
335 }
336
337 /**
338 * Enables Stats Admin.
339 */
340 protected function enable_stats_admin() {
341 Stats_Admin_Main::init();
342 return true;
343 }
344
345 /**
346 * Handles VideoPress options
347 */
348 protected function ensure_options_videopress() {
349 $options = $this->get_feature_options( 'videopress' );
350 if ( ! empty( $options ) ) {
351 VideoPress_Pkg_Initializer::update_init_options( $options );
352 }
353 return true;
354 }
355
356 /**
357 * Enables Yoast Promo.
358 */
359 protected function enable_yoast_promo() {
360 Yoast_Promo::init();
361 return true;
362 }
363
364 /**
365 * Enables the Import feature.
366 */
367 protected function enable_import() {
368 Import_Main::configure();
369
370 return true;
371 }
372
373 /**
374 * Setup the Connection options.
375 */
376 protected function ensure_options_connection() {
377 $options = $this->get_feature_options( 'connection' );
378
379 if ( ! empty( $options['slug'] ) ) {
380 // The `slug` and `name` are removed from the options because they need to be passed as arguments.
381 $slug = $options['slug'];
382 unset( $options['slug'] );
383
384 $name = $slug;
385 if ( ! empty( $options['name'] ) ) {
386 $name = $options['name'];
387 unset( $options['name'] );
388 }
389
390 ( new Plugin( $slug ) )->add( $name, $options );
391 }
392
393 return true;
394 }
395
396 /**
397 * Setup the Identity Crisis options.
398 *
399 * @return bool
400 */
401 protected function ensure_options_identity_crisis() {
402 $options = $this->get_feature_options( 'identity_crisis' );
403
404 if ( is_array( $options ) && count( $options ) ) {
405 add_filter(
406 'jetpack_idc_consumers',
407 function ( $consumers ) use ( $options ) {
408 $consumers[] = $options;
409 return $consumers;
410 }
411 );
412 }
413
414 return true;
415 }
416
417 /**
418 * Setup the Sync options.
419 */
420 protected function ensure_options_sync() {
421 $options = $this->get_feature_options( 'sync' );
422 if ( method_exists( 'Automattic\Jetpack\Sync\Main', 'set_sync_data_options' ) ) {
423 Sync_Main::set_sync_data_options( $options );
424 }
425
426 return true;
427 }
428
429 /**
430 * Temporary save initialization options for a feature.
431 *
432 * @param string $feature The feature slug.
433 * @param array $options The options.
434 *
435 * @return bool
436 */
437 protected function set_feature_options( $feature, array $options ) {
438 if ( $options ) {
439 $this->feature_options[ $feature ] = $options;
440 }
441
442 return true;
443 }
444
445 /**
446 * Get initialization options for a feature from the temporary storage.
447 *
448 * @param string $feature The feature slug.
449 *
450 * @return array
451 */
452 protected function get_feature_options( $feature ) {
453 return empty( $this->feature_options[ $feature ] ) ? array() : $this->feature_options[ $feature ];
454 }
455 }
456