|
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
|
|
|
public function init_full_sync_listeners( $callable ) { |
|
14
|
|
|
add_action( 'jetpack_full_sync_theme_data', $callable ); |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
public function sync_theme_support() { |
|
18
|
|
|
/** |
|
19
|
|
|
* Fires when the client needs to sync theme support info |
|
20
|
|
|
* Only sends theme support attributes whitelisted in Jetpack_Sync_Defaults::$default_theme_support_whitelist |
|
21
|
|
|
* |
|
22
|
|
|
* @since 4.2.0 |
|
23
|
|
|
* |
|
24
|
|
|
* @param object the theme support hash |
|
25
|
|
|
*/ |
|
26
|
|
|
do_action( 'jetpack_sync_current_theme_support' , $this->get_theme_support_info() ); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function enqueue_full_sync_actions( $config ) { |
|
30
|
|
|
/** |
|
31
|
|
|
* Tells the client to sync all theme data to the server |
|
32
|
|
|
* |
|
33
|
|
|
* @since 4.2.0 |
|
34
|
|
|
* |
|
35
|
|
|
* @param boolean Whether to expand theme data (should always be true) |
|
36
|
|
|
*/ |
|
37
|
|
|
do_action( 'jetpack_full_sync_theme_data', true ); |
|
38
|
|
|
return 1; // The number of actions enqueued |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function estimate_full_sync_actions( $config ) { |
|
42
|
|
|
return 1; |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function init_before_send() { |
|
46
|
|
|
add_filter( 'jetpack_sync_before_send_jetpack_full_sync_theme_data', array( $this, 'expand_theme_data' ) ); |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
function get_full_sync_actions() { |
|
50
|
|
|
return array( 'jetpack_full_sync_theme_data' ); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
function expand_theme_data() { |
|
54
|
|
|
return array( $this->get_theme_support_info() ); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
private function get_theme_support_info() { |
|
58
|
|
|
global $_wp_theme_features; |
|
59
|
|
|
|
|
60
|
|
|
$theme_support = array(); |
|
61
|
|
|
|
|
62
|
|
|
foreach ( Jetpack_Sync_Defaults::$default_theme_support_whitelist as $theme_feature ) { |
|
|
|
|
|
|
63
|
|
|
$has_support = current_theme_supports( $theme_feature ); |
|
64
|
|
|
if ( $has_support ) { |
|
65
|
|
|
$theme_support[ $theme_feature ] = $_wp_theme_features[ $theme_feature ]; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
return $theme_support; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
|
This check looks for access to properties that are not accessible from the current context.
If you need to make a property accessible to another context you can either raise its visibility level or provide an accessible getter in the defining class.