|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class Jetpack_Sync_Themes { |
|
4
|
|
|
|
|
5
|
|
|
static $check_sum_id = 'function_check_sum'; |
|
|
|
|
|
|
6
|
|
|
static $sync = false; |
|
|
|
|
|
|
7
|
|
|
static $theme_slug = ''; |
|
|
|
|
|
|
8
|
|
|
static $theme_mods = ''; |
|
|
|
|
|
|
9
|
|
|
|
|
10
|
|
|
static function init() { |
|
11
|
|
|
add_action( 'switch_theme', array( __CLASS__, 'refresh_theme_data' ) ); |
|
12
|
|
|
self::$theme_slug = get_option( 'stylesheet' ); |
|
13
|
|
|
self::$theme_mods = 'theme_mods_' . self::$theme_slug; |
|
14
|
|
|
add_action( 'add_option_' . self::$theme_mods, array( __CLASS__, 'sync_theme_data' ) ); |
|
15
|
|
|
add_action( 'update_option_' . self::$theme_mods, array( __CLASS__, 'sync_theme_data' ) ); |
|
16
|
|
|
add_action( 'delete_option_' . self::$theme_mods, array( __CLASS__, 'sync_theme_data' ) ); |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* Triggers a sync of information specific to the current theme. |
|
21
|
|
|
*/ |
|
22
|
|
|
static function sync_theme_data() { |
|
23
|
|
|
self::$sync = true; |
|
24
|
|
|
Jetpack_Sync::schedule_sync(); |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
static function refresh_theme_data() { |
|
28
|
|
|
self::$sync = true; |
|
29
|
|
|
Jetpack_Sync::schedule_sync(); |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
static function get_to_sync() { |
|
33
|
|
|
if ( self::$sync ) { |
|
34
|
|
|
return self::get_all(); |
|
35
|
|
|
} |
|
36
|
|
|
return array(); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
static function get_all() { |
|
40
|
|
|
return array( |
|
41
|
|
|
'stylesheet' => self::$theme_slug, |
|
42
|
|
|
self::$theme_mods => get_option( self::$theme_mods ), |
|
43
|
|
|
'featured_images_enabled' => Jetpack::featured_images_enabled(), |
|
44
|
|
|
'content_width' => Jetpack::get_content_width(), |
|
45
|
|
|
'current_theme_supports_post-thumbnails' => current_theme_supports( 'post-thumbnails' ), |
|
46
|
|
|
'current_theme_supports_post-formats' => current_theme_supports( 'post-formats' ), |
|
47
|
|
|
'current_theme_supports_custom-header' => current_theme_supports( 'custom-header' ), |
|
48
|
|
|
'current_theme_supports_custom-background' => current_theme_supports( 'custom-background' ), |
|
49
|
|
|
'current_theme_supports_custom-logo' => current_theme_supports( 'custom-logo' ), |
|
50
|
|
|
'current_theme_supports_menus' => current_theme_supports( 'menus' ), |
|
51
|
|
|
'current_theme_supports_automatic-feed-links' => current_theme_supports( 'automatic-feed-links' ), |
|
52
|
|
|
'current_theme_supports_editor-style' => current_theme_supports( 'editor-style' ), |
|
53
|
|
|
'current_theme_supports_widgets' => current_theme_supports( 'widgets' ), |
|
54
|
|
|
'current_theme_supports_html5' => current_theme_supports( 'html5' ), |
|
55
|
|
|
'current_theme_supports_title-tag' => current_theme_supports( 'title-tag' ), |
|
56
|
|
|
'current_theme_supports_jetpack-social-menu' => current_theme_supports( 'jetpack-social-menu' ), |
|
57
|
|
|
'current_theme_supports_jetpack-responsive-videos' => current_theme_supports( 'jetpack-responsive-videos' ), |
|
58
|
|
|
'current_theme_supports_infinite-scroll' => current_theme_supports( 'infinite-scroll' ), |
|
59
|
|
|
'current_theme_supports_site-logo' => current_theme_supports( 'site-logo' ), |
|
60
|
|
|
); |
|
61
|
|
|
} |
|
62
|
|
|
} |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.