|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Just some defaults that we share with the server |
|
5
|
|
|
*/ |
|
6
|
|
|
class Jetpack_Sync_Defaults { |
|
7
|
|
|
static $default_options_whitelist = array( |
|
|
|
|
|
|
8
|
|
|
'stylesheet', |
|
9
|
|
|
'blogname', |
|
10
|
|
|
'home', |
|
11
|
|
|
'siteurl', |
|
12
|
|
|
'blogdescription', |
|
13
|
|
|
'blog_charset', |
|
14
|
|
|
'permalink_structure', |
|
15
|
|
|
'category_base', |
|
16
|
|
|
'tag_base', |
|
17
|
|
|
'comment_moderation', |
|
18
|
|
|
'default_comment_status', |
|
19
|
|
|
'thread_comments', |
|
20
|
|
|
'thread_comments_depth', |
|
21
|
|
|
'jetpack_site_icon_url', |
|
22
|
|
|
'social_notifications_like', |
|
23
|
|
|
'page_on_front', |
|
24
|
|
|
'rss_use_excerpt', |
|
25
|
|
|
'subscription_options', |
|
26
|
|
|
'stb_enabled', |
|
27
|
|
|
'stc_enabled', |
|
28
|
|
|
'comment_registration', |
|
29
|
|
|
'require_name_email', |
|
30
|
|
|
'show_avatars', |
|
31
|
|
|
'avatar_default', |
|
32
|
|
|
'avatar_rating', |
|
33
|
|
|
'highlander_comment_form_prompt', |
|
34
|
|
|
'jetpack_comment_form_color_scheme', |
|
35
|
|
|
'stats_options', |
|
36
|
|
|
'gmt_offset', |
|
37
|
|
|
'timezone_string', |
|
38
|
|
|
'jetpack_sync_non_public_post_stati', |
|
39
|
|
|
'jetpack_options', |
|
40
|
|
|
'site_icon', // (int) - ID of core's Site Icon attachment ID |
|
41
|
|
|
'default_post_format', |
|
42
|
|
|
'default_category', |
|
43
|
|
|
'large_size_w', |
|
44
|
|
|
'large_size_h', |
|
45
|
|
|
'thumbnail_size_w', |
|
46
|
|
|
'thumbnail_size_h', |
|
47
|
|
|
'medium_size_w', |
|
48
|
|
|
'medium_size_h', |
|
49
|
|
|
'thumbnail_crop', |
|
50
|
|
|
'image_default_link_type', |
|
51
|
|
|
'site_logo', |
|
52
|
|
|
'sharing-options', |
|
53
|
|
|
'sharing-services', |
|
54
|
|
|
'post_count', |
|
55
|
|
|
'default_ping_status', |
|
56
|
|
|
'sticky_posts', |
|
57
|
|
|
'disabled_likes', |
|
58
|
|
|
'blog_public', |
|
59
|
|
|
'default_pingback_flag', |
|
60
|
|
|
'require_name_email', |
|
61
|
|
|
'close_comments_for_old_posts', |
|
62
|
|
|
'close_comments_days_old', |
|
63
|
|
|
'thread_comments', |
|
64
|
|
|
'thread_comments_depth', |
|
65
|
|
|
'page_comments', |
|
66
|
|
|
'comments_per_page', |
|
67
|
|
|
'default_comments_page', |
|
68
|
|
|
'comment_order', |
|
69
|
|
|
'comments_notify', |
|
70
|
|
|
'moderation_notify', |
|
71
|
|
|
'social_notifications_like', |
|
72
|
|
|
'social_notifications_reblog', |
|
73
|
|
|
'social_notifications_subscribe', |
|
74
|
|
|
'comment_whitelist', |
|
75
|
|
|
'comment_max_links', |
|
76
|
|
|
'moderation_keys', |
|
77
|
|
|
'blacklist_keys', |
|
78
|
|
|
'lang_id', |
|
79
|
|
|
'wga', |
|
80
|
|
|
'disabled_likes', |
|
81
|
|
|
'disabled_reblogs', |
|
82
|
|
|
'jetpack_comment_likes_enabled', |
|
83
|
|
|
'twitter_via', |
|
84
|
|
|
'twitter-cards-site-tag' |
|
85
|
|
|
); |
|
86
|
|
|
|
|
87
|
|
|
static $default_constants_whitelist = array( |
|
|
|
|
|
|
88
|
|
|
'EMPTY_TRASH_DAYS', |
|
89
|
|
|
'WP_POST_REVISIONS', |
|
90
|
|
|
'AUTOMATIC_UPDATER_DISABLED', |
|
91
|
|
|
'ABSPATH', |
|
92
|
|
|
'WP_CONTENT_DIR', |
|
93
|
|
|
'FS_METHOD', |
|
94
|
|
|
'DISALLOW_FILE_EDIT', |
|
95
|
|
|
'DISALLOW_FILE_MODS', |
|
96
|
|
|
'WP_AUTO_UPDATE_CORE', |
|
97
|
|
|
'WP_HTTP_BLOCK_EXTERNAL', |
|
98
|
|
|
'WP_ACCESSIBLE_HOSTS', |
|
99
|
|
|
'JETPACK__VERSION' |
|
100
|
|
|
); |
|
101
|
|
|
|
|
102
|
|
|
static $default_callable_whitelist = array( |
|
|
|
|
|
|
103
|
|
|
'wp_max_upload_size' => 'wp_max_upload_size', |
|
104
|
|
|
'is_main_network' => array( 'Jetpack', 'is_multi_network' ), |
|
105
|
|
|
'is_multi_site' => 'is_multisite', |
|
106
|
|
|
'main_network_site' => 'network_site_url', |
|
107
|
|
|
'single_user_site' => array( 'Jetpack', 'is_single_user_site' ), |
|
108
|
|
|
'has_file_system_write_access' => array( 'Jetpack_Sync_Functions', 'file_system_write_access' ), |
|
109
|
|
|
'is_version_controlled' => array( 'Jetpack_Sync_Functions', 'is_version_controlled' ), |
|
110
|
|
|
'modules' => array( 'Jetpack_Sync_Functions', 'get_modules' ), |
|
111
|
|
|
'taxonomies' => array( 'Jetpack_Sync_Functions', 'get_taxonomies' ), |
|
112
|
|
|
'post_types' => array( 'Jetpack_Sync_Functions', 'get_post_types' ), |
|
113
|
|
|
); |
|
114
|
|
|
|
|
115
|
|
|
static $blacklisted_post_types = array( |
|
|
|
|
|
|
116
|
|
|
'revision', // "don't ever sync revisions, they overwrite post meta for the parent post." |
|
117
|
|
|
'ai1ec_event' // https://irc.automattic.com/chanlog.php?channel=jetpack&day=2014-05-29&sort=asc#m71850 |
|
118
|
|
|
); |
|
119
|
|
|
|
|
120
|
|
|
// returns escapted SQL that can be injected into a WHERE clause |
|
121
|
|
|
static function get_blacklisted_post_types_sql() { |
|
122
|
|
|
return 'post_type NOT IN (\'' . join( '\', \'', array_map( 'esc_sql', self::$blacklisted_post_types ) ) . '\')'; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
static $default_multisite_callable_whitelist = array( |
|
|
|
|
|
|
126
|
|
|
'network_name' => array( 'Jetpack', 'network_name' ), |
|
127
|
|
|
'network_allow_new_registrations' => array( 'Jetpack', 'network_allow_new_registrations' ), |
|
128
|
|
|
'network_add_new_users' => array( 'Jetpack', 'network_add_new_users' ), |
|
129
|
|
|
'network_site_upload_space' => array( 'Jetpack', 'network_site_upload_space' ), |
|
130
|
|
|
'network_upload_file_types' => array( 'Jetpack', 'network_upload_file_types' ), |
|
131
|
|
|
'network_enable_administration_menus' => array( 'Jetpack', 'network_enable_administration_menus' ), |
|
132
|
|
|
); |
|
133
|
|
|
|
|
134
|
|
|
static $default_whitelist_meta_keys = array( |
|
|
|
|
|
|
135
|
|
|
'_wp_attachment_metadata', |
|
136
|
|
|
'_thumbnail_id', |
|
137
|
|
|
); |
|
138
|
|
|
|
|
139
|
|
|
// TODO: move this to server? - these are theme support values |
|
|
|
|
|
|
140
|
|
|
// that should be synced as jetpack_current_theme_supports_foo option values |
|
141
|
|
|
static $default_theme_support_whitelist = array( |
|
|
|
|
|
|
142
|
|
|
'post-thumbnails', |
|
143
|
|
|
'post-formats', |
|
144
|
|
|
'custom-header', |
|
145
|
|
|
'custom-background', |
|
146
|
|
|
'custom-logo', |
|
147
|
|
|
'menus', |
|
148
|
|
|
'automatic-feed-links', |
|
149
|
|
|
'editor-style', |
|
150
|
|
|
'widgets', |
|
151
|
|
|
'html5', |
|
152
|
|
|
'title-tag', |
|
153
|
|
|
'jetpack-social-menu', |
|
154
|
|
|
'jetpack-responsive-videos', |
|
155
|
|
|
'infinite-scroll', |
|
156
|
|
|
'site-logo', |
|
157
|
|
|
); |
|
158
|
|
|
|
|
159
|
|
|
static function is_whitelisted_option( $option ) { |
|
160
|
|
|
foreach ( self::$default_options_whitelist as $whitelisted_option ) { |
|
161
|
|
|
if ( $whitelisted_option[0] === '/' && preg_match( $whitelisted_option, $option ) ) { |
|
162
|
|
|
return true; |
|
163
|
|
|
} elseif ( $whitelisted_option === $option ) { |
|
164
|
|
|
return true; |
|
165
|
|
|
} |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
return false; |
|
169
|
|
|
} |
|
170
|
|
|
|
|
171
|
|
|
static $default_network_options_whitelist = array( 'site_name' ); |
|
|
|
|
|
|
172
|
|
|
static $default_taxonomy_whitelist = array(); |
|
|
|
|
|
|
173
|
|
|
static $default_send_buffer_memory_size = 500000; // very conservative value, 1/2 MB |
|
|
|
|
|
|
174
|
|
|
static $default_upload_max_bytes = 600000; // a little bigger than the upload limit to account for serialization |
|
|
|
|
|
|
175
|
|
|
static $default_upload_max_rows = 500; |
|
|
|
|
|
|
176
|
|
|
static $default_sync_wait_time = 10; // seconds, between syncs |
|
|
|
|
|
|
177
|
|
|
static $default_sync_callables_wait_time = MINUTE_IN_SECONDS; // seconds before sending callables again |
|
|
|
|
|
|
178
|
|
|
static $default_sync_constants_wait_time = HOUR_IN_SECONDS; // seconds before sending constants again |
|
|
|
|
|
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
|
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.