PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 6.4.4
Jetpack – WP Security, Backup, Speed, & Growth v6.4.4
12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 14.4.2 All 500 releases
jetpack / sync / class.jetpack-sync-modules.php
class.jetpack-sync-modules.php
105 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * simple wrapper that allows enumerating cached static instances
5 * of sync modules
6 */
7
8 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module.php';
9 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-posts.php';
10 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-import.php';
11 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-comments.php';
12 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-constants.php';
13 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-callables.php';
14 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-options.php';
15 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-network-options.php';
16 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-updates.php';
17 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-users.php';
18 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-themes.php';
19 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-menus.php';
20 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-attachments.php';
21 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-meta.php';
22 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-terms.php';
23 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-plugins.php';
24 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-full-sync.php';
25 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-stats.php';
26 require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-protect.php';
27
28 class Jetpack_Sync_Modules {
29
30 private static $default_sync_modules = array(
31 'Jetpack_Sync_Module_Constants',
32 'Jetpack_Sync_Module_Callables',
33 'Jetpack_Sync_Module_Options',
34 'Jetpack_Sync_Module_Network_Options',
35 'Jetpack_Sync_Module_Terms',
36 'Jetpack_Sync_Module_Themes',
37 'Jetpack_Sync_Module_Menus',
38 'Jetpack_Sync_Module_Users',
39 'Jetpack_Sync_Module_Posts',
40 'Jetpack_Sync_Module_Import',
41 'Jetpack_Sync_Module_Protect',
42 'Jetpack_Sync_Module_Comments',
43 'Jetpack_Sync_Module_Updates',
44 'Jetpack_Sync_Module_Attachments',
45 'Jetpack_Sync_Module_Meta',
46 'Jetpack_Sync_Module_Plugins',
47 'Jetpack_Sync_Module_Full_Sync',
48 'Jetpack_Sync_Module_Stats',
49 );
50
51 private static $initialized_modules = null;
52
53 public static function get_modules() {
54 if ( null === self::$initialized_modules ) {
55 self::$initialized_modules = self::initialize_modules();
56 }
57
58 return self::$initialized_modules;
59 }
60
61 public static function set_defaults() {
62 foreach ( self::get_modules() as $module ) {
63 $module->set_defaults();
64 }
65 }
66
67 public static function get_module( $module_name ) {
68 foreach ( self::get_modules() as $module ) {
69 if ( $module->name() === $module_name ) {
70 return $module;
71 }
72 }
73
74 return false;
75 }
76
77 static function initialize_modules() {
78 /**
79 * Filters the list of class names of sync modules.
80 * If you add to this list, make sure any classes implement the
81 * Jetpack_Sync_Module interface.
82 *
83 * @since 4.2.0
84 */
85 $modules = apply_filters( 'jetpack_sync_modules', self::$default_sync_modules );
86
87 $modules = array_map( array( 'Jetpack_Sync_Modules', 'load_module' ), $modules );
88
89 return array_map( array( 'Jetpack_Sync_Modules', 'set_module_defaults' ), $modules );
90 }
91
92 static function load_module( $module_name ) {
93 return new $module_name;
94 }
95
96 static function set_module_defaults( $module ) {
97 $module->set_defaults();
98 if ( method_exists( $module, 'set_late_default' ) ) {
99 add_action( 'init', array( $module, 'set_late_default' ), 90 );
100 }
101 return $module;
102 }
103
104 }
105