|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class Jetpack_Sync_Module_Themes extends Jetpack_Sync_Module { |
|
4
|
|
|
function name() { |
|
5
|
|
|
return 'themes'; |
|
6
|
|
|
} |
|
7
|
|
|
|
|
8
|
|
|
public function init_listeners( $callable ) { |
|
9
|
|
|
add_action( 'switch_theme', array( $this, 'sync_theme_support' ) ); |
|
10
|
|
|
add_action( 'jetpack_sync_current_theme_support', $callable ); |
|
11
|
|
|
} |
|
12
|
|
|
|
|
13
|
|
|
// TODO: distinct action for full sync |
|
|
|
|
|
|
14
|
|
|
public function init_full_sync_listeners( $callable ) { |
|
15
|
|
|
add_action( 'jetpack_full_sync_themes', $callable ); |
|
16
|
|
|
} |
|
17
|
|
|
|
|
18
|
|
|
public function sync_theme_support() { |
|
19
|
|
|
$this->enqueue_theme_support_as_action( 'jetpack_sync_current_theme_support' ); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function enqueue_full_sync_actions() { |
|
23
|
|
|
return $this->enqueue_theme_support_as_action( 'jetpack_full_sync_themes' ); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
function enqueue_theme_support_as_action( $action_name ) { |
|
27
|
|
|
global $_wp_theme_features; |
|
28
|
|
|
|
|
29
|
|
|
$theme_support = array(); |
|
30
|
|
|
|
|
31
|
|
|
foreach ( Jetpack_Sync_Defaults::$default_theme_support_whitelist as $theme_feature ) { |
|
|
|
|
|
|
32
|
|
|
$has_support = current_theme_supports( $theme_feature ); |
|
33
|
|
|
if ( $has_support ) { |
|
34
|
|
|
$theme_support[ $theme_feature ] = $_wp_theme_features[ $theme_feature ]; |
|
35
|
|
|
} |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Fires when the client needs to sync theme support info |
|
40
|
|
|
* Only sends theme support attributes whitelisted in Jetpack_Sync_Defaults::$default_theme_support_whitelist |
|
41
|
|
|
* |
|
42
|
|
|
* @since 4.2.0 |
|
43
|
|
|
* |
|
44
|
|
|
* @param object the theme support hash |
|
45
|
|
|
*/ |
|
46
|
|
|
do_action( $action_name, $theme_support ); |
|
47
|
|
|
|
|
48
|
|
|
return 1; // The number of actions enqueued |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
function get_full_sync_actions() { |
|
52
|
|
|
return array( 'jetpack_full_sync_themes' ); |
|
53
|
|
|
} |
|
54
|
|
|
} |
|
55
|
|
|
|