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-comments.php'; |
11
|
|
|
require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-constants.php'; |
12
|
|
|
require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-callables.php'; |
13
|
|
|
require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-options.php'; |
14
|
|
|
require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-network-options.php'; |
15
|
|
|
require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-updates.php'; |
16
|
|
|
require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-users.php'; |
17
|
|
|
require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-themes.php'; |
18
|
|
|
require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-attachments.php'; |
19
|
|
|
require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-meta.php'; |
20
|
|
|
require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-terms.php'; |
21
|
|
|
require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-plugins.php'; |
22
|
|
|
require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-protect.php'; |
23
|
|
|
require_once dirname( __FILE__ ) . '/class.jetpack-sync-module-full-sync.php'; |
24
|
|
|
|
25
|
|
|
class Jetpack_Sync_Modules { |
26
|
|
|
|
27
|
|
|
private static $default_sync_modules = array( |
28
|
|
|
'Jetpack_Sync_Module_Constants', |
29
|
|
|
'Jetpack_Sync_Module_Callables', |
30
|
|
|
'Jetpack_Sync_Module_Options', |
31
|
|
|
'Jetpack_Sync_Module_Network_Options', |
32
|
|
|
'Jetpack_Sync_Module_Terms', |
33
|
|
|
'Jetpack_Sync_Module_Themes', |
34
|
|
|
'Jetpack_Sync_Module_Users', |
35
|
|
|
'Jetpack_Sync_Module_Posts', |
36
|
|
|
'Jetpack_Sync_Module_Comments', |
37
|
|
|
'Jetpack_Sync_Module_Updates', |
38
|
|
|
'Jetpack_Sync_Module_Attachments', |
39
|
|
|
'Jetpack_Sync_Module_Meta', |
40
|
|
|
'Jetpack_Sync_Module_Plugins', |
41
|
|
|
'Jetpack_Sync_Module_Protect', |
42
|
|
|
'Jetpack_Sync_Module_Full_Sync' |
43
|
|
|
); |
44
|
|
|
|
45
|
|
|
private static $initialized_modules = null; |
46
|
|
|
|
47
|
|
|
public static function get_modules() { |
48
|
|
|
if ( self::$initialized_modules === null ) { |
49
|
|
|
self::$initialized_modules = self::initialize_modules(); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
return self::$initialized_modules; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
public static function get_module( $module_name ) { |
56
|
|
|
foreach( self::get_modules() as $module ) { |
57
|
|
|
if ( $module->name() === $module_name ) { |
58
|
|
|
return $module; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
return false; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
static function initialize_modules() { |
66
|
|
|
/** |
67
|
|
|
* Filters the list of class names of sync modules. |
68
|
|
|
* If you add to this list, make sure any classes implement the |
69
|
|
|
* Jetpack_Sync_Module interface. |
70
|
|
|
* |
71
|
|
|
* @since 4.2.0 |
72
|
|
|
*/ |
73
|
|
|
$modules = apply_filters( 'jetpack_sync_modules', self::$default_sync_modules ); |
74
|
|
|
return array_map( array( 'Jetpack_Sync_Modules', 'initialize_module' ), $modules ); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
static function initialize_module( $module_name ) { |
78
|
|
|
$module = new $module_name; |
79
|
|
|
$module->set_defaults(); |
80
|
|
|
return $module; |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|