| 1 |
<?php |
| 2 |
require_once( JETPACK__PLUGIN_DIR . 'modules/sso/class.jetpack-sso-helpers.php' ); |
| 3 |
|
| 4 |
/** |
| 5 |
* Just some defaults that we share with the server |
| 6 |
*/ |
| 7 |
class Jetpack_Sync_Defaults { |
| 8 |
static $default_options_whitelist = array( |
| 9 |
'stylesheet', |
| 10 |
'blogname', |
| 11 |
'home', |
| 12 |
'siteurl', |
| 13 |
'blogdescription', |
| 14 |
'blog_charset', |
| 15 |
'permalink_structure', |
| 16 |
'category_base', |
| 17 |
'tag_base', |
| 18 |
'comment_moderation', |
| 19 |
'default_comment_status', |
| 20 |
'jetpack_site_icon_url', |
| 21 |
'page_on_front', |
| 22 |
'rss_use_excerpt', |
| 23 |
'subscription_options', |
| 24 |
'stb_enabled', |
| 25 |
'stc_enabled', |
| 26 |
'comment_registration', |
| 27 |
'show_avatars', |
| 28 |
'avatar_default', |
| 29 |
'avatar_rating', |
| 30 |
'highlander_comment_form_prompt', |
| 31 |
'jetpack_comment_form_color_scheme', |
| 32 |
'stats_options', |
| 33 |
'gmt_offset', |
| 34 |
'timezone_string', |
| 35 |
'jetpack_sync_non_public_post_stati', |
| 36 |
'jetpack_options', |
| 37 |
'site_icon', // (int) - ID of core's Site Icon attachment ID |
| 38 |
'default_post_format', |
| 39 |
'default_category', |
| 40 |
'large_size_w', |
| 41 |
'large_size_h', |
| 42 |
'thumbnail_size_w', |
| 43 |
'thumbnail_size_h', |
| 44 |
'medium_size_w', |
| 45 |
'medium_size_h', |
| 46 |
'thumbnail_crop', |
| 47 |
'image_default_link_type', |
| 48 |
'site_logo', |
| 49 |
'sharing-options', |
| 50 |
'sharing-services', |
| 51 |
'post_count', |
| 52 |
'default_ping_status', |
| 53 |
'sticky_posts', |
| 54 |
'blog_public', |
| 55 |
'default_pingback_flag', |
| 56 |
'require_name_email', |
| 57 |
'close_comments_for_old_posts', |
| 58 |
'close_comments_days_old', |
| 59 |
'thread_comments', |
| 60 |
'thread_comments_depth', |
| 61 |
'page_comments', |
| 62 |
'comments_per_page', |
| 63 |
'default_comments_page', |
| 64 |
'comment_order', |
| 65 |
'comments_notify', |
| 66 |
'moderation_notify', |
| 67 |
'social_notifications_like', |
| 68 |
'social_notifications_reblog', |
| 69 |
'social_notifications_subscribe', |
| 70 |
'comment_whitelist', |
| 71 |
'comment_max_links', |
| 72 |
'moderation_keys', |
| 73 |
'lang_id', |
| 74 |
'wga', |
| 75 |
'disabled_likes', |
| 76 |
'disabled_reblogs', |
| 77 |
'jetpack_comment_likes_enabled', |
| 78 |
'twitter_via', |
| 79 |
'jetpack-twitter-cards-site-tag', |
| 80 |
'wpcom_publish_posts_with_markdown', |
| 81 |
'wpcom_publish_comments_with_markdown', |
| 82 |
'jetpack_activated', |
| 83 |
'jetpack_available_modules', |
| 84 |
'jetpack_autoupdate_plugins', |
| 85 |
'jetpack_autoupdate_themes', |
| 86 |
'jetpack_autoupdate_core', |
| 87 |
'carousel_background_color', |
| 88 |
'carousel_display_exif', |
| 89 |
'jetpack_portfolio', |
| 90 |
'jetpack_portfolio_posts_per_page', |
| 91 |
'jetpack_testimonial', |
| 92 |
'jetpack_testimonial_posts_per_page', |
| 93 |
'tiled_galleries', |
| 94 |
'gravatar_disable_hovercards', |
| 95 |
'infinite_scroll', |
| 96 |
'infinite_scroll_google_analytics', |
| 97 |
'wp_mobile_excerpt', |
| 98 |
'wp_mobile_featured_images', |
| 99 |
'wp_mobile_app_promos', |
| 100 |
'monitor_receive_notifications', |
| 101 |
'post_by_email_address', |
| 102 |
'jetpack_protect_key', |
| 103 |
'jetpack_protect_global_whitelist', |
| 104 |
'sharing_services', |
| 105 |
'jetpack_sso_require_two_step', |
| 106 |
'jetpack_relatedposts', |
| 107 |
'verification_services_codes', |
| 108 |
'users_can_register', |
| 109 |
'active_plugins', |
| 110 |
'uninstall_plugins', |
| 111 |
); |
| 112 |
|
| 113 |
static $default_constants_whitelist = array( |
| 114 |
'EMPTY_TRASH_DAYS', |
| 115 |
'WP_POST_REVISIONS', |
| 116 |
'AUTOMATIC_UPDATER_DISABLED', |
| 117 |
'ABSPATH', |
| 118 |
'WP_CONTENT_DIR', |
| 119 |
'FS_METHOD', |
| 120 |
'DISALLOW_FILE_EDIT', |
| 121 |
'DISALLOW_FILE_MODS', |
| 122 |
'WP_AUTO_UPDATE_CORE', |
| 123 |
'WP_HTTP_BLOCK_EXTERNAL', |
| 124 |
'WP_ACCESSIBLE_HOSTS', |
| 125 |
'JETPACK__VERSION', |
| 126 |
'IS_PRESSABLE', |
| 127 |
); |
| 128 |
|
| 129 |
static $default_callable_whitelist = array( |
| 130 |
'wp_max_upload_size' => 'wp_max_upload_size', |
| 131 |
'is_main_network' => array( 'Jetpack', 'is_multi_network' ), |
| 132 |
'is_multi_site' => 'is_multisite', |
| 133 |
'main_network_site' => array( 'Jetpack_Sync_Functions', 'main_network_site_url' ), |
| 134 |
'site_url' => array( 'Jetpack_Sync_Functions', 'site_url' ), |
| 135 |
'home_url' => array( 'Jetpack_Sync_Functions', 'home_url' ), |
| 136 |
'single_user_site' => array( 'Jetpack', 'is_single_user_site' ), |
| 137 |
'updates' => array( 'Jetpack', 'get_updates' ), |
| 138 |
'has_file_system_write_access' => array( 'Jetpack_Sync_Functions', 'file_system_write_access' ), |
| 139 |
'is_version_controlled' => array( 'Jetpack_Sync_Functions', 'is_version_controlled' ), |
| 140 |
'taxonomies' => array( 'Jetpack_Sync_Functions', 'get_taxonomies' ), |
| 141 |
'post_types' => array( 'Jetpack_Sync_Functions', 'get_post_types' ), |
| 142 |
'post_type_features' => array( 'Jetpack_Sync_Functions', 'get_post_type_features' ), |
| 143 |
'rest_api_allowed_post_types' => array( 'Jetpack_Sync_Functions', 'rest_api_allowed_post_types' ), |
| 144 |
'rest_api_allowed_public_metadata' => array( 'Jetpack_Sync_Functions', 'rest_api_allowed_public_metadata' ), |
| 145 |
'sso_is_two_step_required' => array( 'Jetpack_SSO_Helpers', 'is_two_step_required' ), |
| 146 |
'sso_should_hide_login_form' => array( 'Jetpack_SSO_Helpers', 'should_hide_login_form' ), |
| 147 |
'sso_match_by_email' => array( 'Jetpack_SSO_Helpers', 'match_by_email' ), |
| 148 |
'sso_new_user_override' => array( 'Jetpack_SSO_Helpers', 'new_user_override' ), |
| 149 |
'sso_bypass_default_login_form' => array( 'Jetpack_SSO_Helpers', 'bypass_login_forward_wpcom' ), |
| 150 |
'wp_version' => array( 'Jetpack_Sync_Functions', 'wp_version' ), |
| 151 |
'get_plugins' => array( 'Jetpack_Sync_Functions', 'get_plugins' ), |
| 152 |
'active_modules' => array( 'Jetpack', 'get_active_modules' ), |
| 153 |
); |
| 154 |
|
| 155 |
static $blacklisted_post_types = array( |
| 156 |
'ai1ec_event', |
| 157 |
'snitch', |
| 158 |
); |
| 159 |
|
| 160 |
static $default_post_checksum_columns = array( |
| 161 |
'ID', |
| 162 |
'post_modified', |
| 163 |
); |
| 164 |
|
| 165 |
static $default_comment_checksum_columns = array( |
| 166 |
'comment_ID', |
| 167 |
'comment_content', |
| 168 |
); |
| 169 |
|
| 170 |
static $default_option_checksum_columns = array( |
| 171 |
'option_name', |
| 172 |
'option_value', |
| 173 |
); |
| 174 |
|
| 175 |
static $default_multisite_callable_whitelist = array( |
| 176 |
'network_name' => array( 'Jetpack', 'network_name' ), |
| 177 |
'network_allow_new_registrations' => array( 'Jetpack', 'network_allow_new_registrations' ), |
| 178 |
'network_add_new_users' => array( 'Jetpack', 'network_add_new_users' ), |
| 179 |
'network_site_upload_space' => array( 'Jetpack', 'network_site_upload_space' ), |
| 180 |
'network_upload_file_types' => array( 'Jetpack', 'network_upload_file_types' ), |
| 181 |
'network_enable_administration_menus' => array( 'Jetpack', 'network_enable_administration_menus' ), |
| 182 |
); |
| 183 |
|
| 184 |
|
| 185 |
static $default_whitelist_meta_keys = array( |
| 186 |
'_wp_attachment_metadata', |
| 187 |
'_thumbnail_id', |
| 188 |
'_wpas_mess', |
| 189 |
'_wpas_skip_', |
| 190 |
'_g_feedback_shortcode', |
| 191 |
'_feedback_extra_fields', |
| 192 |
'_feedback_akismet_values', |
| 193 |
'_publicize_facebook_user', |
| 194 |
'_wp_attachment_image_alt', |
| 195 |
'_jetpack_post_thumbnail', |
| 196 |
'_thumbnail_id', |
| 197 |
'_wp_attachment_metadata', |
| 198 |
'_wp_page_template', |
| 199 |
'_publicize_twitter_user', |
| 200 |
'_wp_trash_meta_comments_status', |
| 201 |
); |
| 202 |
|
| 203 |
static $default_blacklist_meta_keys = array( |
| 204 |
'post_views_count', |
| 205 |
'Views', |
| 206 |
'tve_leads_impressions', |
| 207 |
'views', |
| 208 |
'scc_share_count_crawldate', |
| 209 |
'wprss_last_update', |
| 210 |
'wprss_feed_is_updating', |
| 211 |
'snapFB', |
| 212 |
'syndication_item_hash', |
| 213 |
'phonenumber_spellings', |
| 214 |
'tmac_last_id', |
| 215 |
'opanda_imperessions', |
| 216 |
'administer_stats', |
| 217 |
'spec_ads_views', |
| 218 |
'snp_views', |
| 219 |
'mip_post_views_count', |
| 220 |
'esml_socialcount_LAST_UPDATED', |
| 221 |
'wprss_last_update_items', |
| 222 |
); |
| 223 |
|
| 224 |
// TODO: move this to server? - these are theme support values |
| 225 |
// that should be synced as jetpack_current_theme_supports_foo option values |
| 226 |
static $default_theme_support_whitelist = array( |
| 227 |
'post-thumbnails', |
| 228 |
'post-formats', |
| 229 |
'custom-header', |
| 230 |
'custom-background', |
| 231 |
'custom-logo', |
| 232 |
'menus', |
| 233 |
'automatic-feed-links', |
| 234 |
'editor-style', |
| 235 |
'widgets', |
| 236 |
'html5', |
| 237 |
'title-tag', |
| 238 |
'jetpack-social-menu', |
| 239 |
'jetpack-responsive-videos', |
| 240 |
'infinite-scroll', |
| 241 |
'site-logo', |
| 242 |
); |
| 243 |
|
| 244 |
static function is_whitelisted_option( $option ) { |
| 245 |
foreach ( self::$default_options_whitelist as $whitelisted_option ) { |
| 246 |
if ( $whitelisted_option[0] === '/' && preg_match( $whitelisted_option, $option ) ) { |
| 247 |
return true; |
| 248 |
} elseif ( $whitelisted_option === $option ) { |
| 249 |
return true; |
| 250 |
} |
| 251 |
} |
| 252 |
|
| 253 |
return false; |
| 254 |
} |
| 255 |
|
| 256 |
static $default_network_options_whitelist = array( |
| 257 |
'site_name', |
| 258 |
'jetpack_protect_key', |
| 259 |
'jetpack_protect_global_whitelist', |
| 260 |
'active_sitewide_plugins', |
| 261 |
); |
| 262 |
static $default_taxonomy_whitelist = array(); |
| 263 |
static $default_dequeue_max_bytes = 500000; // very conservative value, 1/2 MB |
| 264 |
static $default_upload_max_bytes = 600000; // a little bigger than the upload limit to account for serialization |
| 265 |
static $default_upload_max_rows = 500; |
| 266 |
static $default_sync_wait_time = 10; // seconds, between syncs |
| 267 |
static $default_sync_wait_threshold = 5; // only wait before next send if the current send took more than X seconds |
| 268 |
static $default_max_queue_size = 1000; |
| 269 |
static $default_max_queue_lag = 900; // 15 minutes |
| 270 |
static $default_queue_max_writes_sec = 100; // 100 rows a second |
| 271 |
static $default_post_types_blacklist = array(); |
| 272 |
static $default_meta_blacklist = array(); |
| 273 |
static $default_disable = 0; // completely disable sending data to wpcom |
| 274 |
static $default_sync_callables_wait_time = MINUTE_IN_SECONDS; // seconds before sending callables again |
| 275 |
static $default_sync_constants_wait_time = HOUR_IN_SECONDS; // seconds before sending constants again |
| 276 |
} |
| 277 |
|