Completed
Push — add/sync-rest-options ( 79f0db...12319b )
by
unknown
08:38
created

Jetpack_Constants_Sync::getConstant()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
class Jetpack_Constants_Sync {
4
5
	static $constants = array(
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $constants.

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
		'EMPTY_TRASH_DAYS',
7
		'WP_POST_REVISIONS',
8
		'AUTOMATIC_UPDATER_DISABLED',
9
		'ABSPATH',
10
		'WP_CONTENT_DIR',
11
		'FS_METHOD',
12
		'DISALLOW_FILE_EDIT',
13
		'DISALLOW_FILE_MODS',
14
		'WP_AUTO_UPDATE_CORE',
15
		'WP_HTTP_BLOCK_EXTERNAL',
16
		'WP_ACCESSIBLE_HOSTS',
17
	);
18
19
	static function sync() {
20
		$query_string = self::getQueryString();
21
		$constantCheckSum  =  crc32( $query_string );
22
23
		if ( Jetpack_Options::get_option( 'constant_check_sum' ) !== $constantCheckSum  ) {
24
			Jetpack_Options::update_option( 'constant_check_sum', $constantCheckSum );
25
			return $query_string;
26
		}
27
		return null;
28
	}
29
30
	static function sync_all() {
31
		return self::getQueryString();
32
	}
33
34
	static function getQueryString() {
35
		$constants_values = array();
36
		foreach( self::$constants as $constant ) {
37
			$constants_values[ $constant  ] = self::getConstant( $constant );
38
		}
39
		return build_query( $constants_values );
40
	}
41
42
	static function getConstant( $constant ) {
43
		if ( defined( $constant ) ) {
44
			return constant ( $constant );
45
		}
46
		return null;
47
	}
48
49
}
50
51
52
53
54
55