|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class Jetpack_Sync_Constants { |
|
4
|
|
|
|
|
5
|
|
|
static $constants = array( |
|
|
|
|
|
|
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
|
|
|
$values = self::values(); |
|
21
|
|
|
$constantCheckSum = self::get_check_sum( $values ); |
|
22
|
|
|
|
|
23
|
|
|
if ( Jetpack_Options::get_option( 'constant_check_sum' ) !== $constantCheckSum ) { |
|
24
|
|
|
Jetpack_Options::update_option( 'constant_check_sum', $constantCheckSum ); |
|
25
|
|
|
|
|
26
|
|
|
return $values; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
return null; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
static function sync_all() { |
|
33
|
|
|
Jetpack_Options::update_option( 'constant_check_sum', self::get_check_sum() ); |
|
34
|
|
|
return self::values(); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
static function get_check_sum( $values = null ) { |
|
38
|
|
|
if( is_null( $values ) ){ |
|
39
|
|
|
$values = self::values(); |
|
40
|
|
|
} |
|
41
|
|
|
return crc32( self::get_query_string( $values ) ); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
static function get_query_string( $values ) { |
|
45
|
|
|
return build_query( $values ); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
static function values() { |
|
49
|
|
|
$constants_values = array(); |
|
50
|
|
|
foreach ( self::$constants as $constant ) { |
|
51
|
|
|
$value = self::get( $constant ); |
|
52
|
|
|
if ( ! is_null( $value ) ) { |
|
53
|
|
|
$constants_values[ $constant ] = $value; |
|
54
|
|
|
} |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
return $constants_values; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
static function get( $constant ) { |
|
61
|
|
|
if ( defined( $constant ) ) { |
|
62
|
|
|
return constant( $constant ); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
return null; |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
|
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.