Completed
Push — add/sync-rest-2 ( 0f1049...2638b5 )
by
unknown
09:02
created

Jetpack_Sync_Themes::get_all()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 23
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
c 3
b 0
f 1
dl 0
loc 23
rs 9.0856
cc 1
eloc 21
nc 1
nop 0
1
<?php
2
3
class Jetpack_Sync_Themes {
4
5
	static $check_sum_id = 'function_check_sum';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $check_sum_id.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
6
	static $sync = false;
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $sync.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
7
	static $theme_slug = '';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $theme_slug.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
8
	static $theme_mods = '';
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $theme_mods.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
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
}