| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | use \Automattic\Jetpack\Options\Manager as Options_Manager; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | if ( class_exists( '\Automattic\Jetpack\Options\Manager' ) ) : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * The option manager class that will eventually replace Jetpack_Options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | class Jetpack_Options_Manager extends Options_Manager { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | 	 * Returns an array of option names for a given type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | 	 * @param string $type The type of option to return. Defaults to 'compact'. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | 	 * @return array | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 18 |  |  | 	 */ | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  | 	public function get_option_names( $type = 'compact' ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  | 		switch ( $type ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  | 			case 'non-compact': | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  | 			case 'non_compact': | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  | 				return array( 'secrets' ); | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  | 			case 'private': | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  | 				return array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  | 			case 'network': | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  | 				return array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  | 		} | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  | 		return array(); | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | endif; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | class Jetpack_Options { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  | 	 * An array that maps a grouped option type to an option name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  | 	 * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  | 	private static $grouped_options = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | 		'compact' => 'jetpack_options', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | 		'private' => 'jetpack_private_options' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  | 	); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  | 	 * Returns an array of option names for a given type. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  | 	 * @param string $type The type of option to return. Defaults to 'compact'. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  | 	public static function get_option_names( $type = 'compact' ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  | 		switch ( $type ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  | 		case 'non-compact' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  | 		case 'non_compact' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  | 			return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  | 				'activated', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  | 				'active_modules', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  | 				'allowed_xsite_search_ids', // (array) Array of WP.com blog ids that are allowed to search the content of this site | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  | 				'available_modules', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  | 				'do_activate', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  | 				'edit_links_calypso_redirect', // (bool) Whether post/page edit links on front end should point to Calypso. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  | 				'log', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  | 				'slideshow_background_color', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  | 				'widget_twitter', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  | 				'wpcc_options', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  | 				'relatedposts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  | 				'file_data', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  | 				'autoupdate_plugins',          // (array)  An array of plugin ids ( eg. jetpack/jetpack ) that should be autoupdated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  | 				'autoupdate_plugins_translations', // (array)  An array of plugin ids ( eg. jetpack/jetpack ) that should be autoupdated translation files. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  | 				'autoupdate_themes',           // (array)  An array of theme ids ( eg. twentyfourteen ) that should be autoupdated | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  | 				'autoupdate_themes_translations', // (array)  An array of theme ids ( eg. twentyfourteen ) that should autoupdated translation files. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  | 				'autoupdate_core',             // (bool)   Whether or not to autoupdate core | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  | 				'autoupdate_translations',     // (bool)   Whether or not to autoupdate all translations | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  | 				'json_api_full_management',    // (bool)   Allow full management (eg. Activate, Upgrade plugins) of the site via the JSON API. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  | 				'sync_non_public_post_stati',  // (bool)   Allow synchronisation of posts and pages with non-public status. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  | 				'site_icon_url',               // (string) url to the full site icon | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  | 				'site_icon_id',                // (int)    Attachment id of the site icon file | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  | 				'dismissed_manage_banner',     // (bool) Dismiss Jetpack manage banner allows the user to dismiss the banner permanently | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  | 				'restapi_stats_cache',         // (array) Stats Cache data. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  | 				'unique_connection',           // (array)  A flag to determine a unique connection to wordpress.com two values "connected" and "disconnected" with values for how many times each has occured | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  | 				'protect_whitelist',           // (array) IP Address for the Protect module to ignore | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  | 				'sync_error_idc',              // (bool|array) false or array containing the site's home and siteurl at time of IDC error | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  | 				'safe_mode_confirmed',         // (bool) True if someone confirms that this site was correctly put into safe mode automatically after an identity crisis is discovered. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  | 				'migrate_for_idc',             // (bool) True if someone confirms that this site should migrate stats and subscribers from its previous URL | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  | 				'dismissed_connection_banner', // (bool) True if the connection banner has been dismissed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  | 				'ab_connect_banner_green_bar', // (int) Version displayed of the A/B test for the green bar at the top of the connect banner. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  | 				'onboarding',                  // (string) Auth token to be used in the onboarding connection flow | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  | 				'tos_agreed',                  // (bool)   Whether or not the TOS for connection has been agreed upon. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  | 				'static_asset_cdn_files',      // (array) An nested array of files that we can swap out for cdn versions. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  | 				'mapbox_api_key',              // (string) Mapbox API Key, for use with Map block. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  | 				'mailchimp',                   // (string) Mailchimp keyring data, for mailchimp block. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  | 		case 'private' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  | 			return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  | 				'blog_token',  // (string) The Client Secret/Blog Token of this site. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  | 				'user_token',  // (string) The User Token of this site. (deprecated) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  | 				'user_tokens'  // (array)  User Tokens for each user of this site who has connected to jetpack.wordpress.com. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  | 		case 'network' : | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  | 			return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  | 				'onboarding',                   // (string) Auth token to be used in the onboarding connection flow | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  | 				'file_data'                     // (array) List of absolute paths to all Jetpack modules | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  | 		return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  | 			'id',                           // (int)    The Client ID/WP.com Blog ID of this site. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  | 			'publicize_connections',        // (array)  An array of Publicize connections from WordPress.com | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  | 			'master_user',                  // (int)    The local User ID of the user who connected this site to jetpack.wordpress.com. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  | 			'version',                      // (string) Used during upgrade procedure to auto-activate new modules. version:time | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  | 			'old_version',                  // (string) Used to determine which modules are the most recently added. previous_version:time | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  | 			'fallback_no_verify_ssl_certs', // (int)    Flag for determining if this host must skip SSL Certificate verification due to misconfigured SSL. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  | 			'time_diff',                    // (int)    Offset between Jetpack server's clocks and this server's clocks. Jetpack Server Time = time() + (int) Jetpack_Options::get_option( 'time_diff' ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  | 			'public',                       // (int|bool) If we think this site is public or not (1, 0), false if we haven't yet tried to figure it out. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  | 			'videopress',                   // (array)  VideoPress options array. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  | 			'is_network_site',              // (int|bool) If we think this site is a network or a single blog (1, 0), false if we haven't yet tried to figue it out. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  | 			'social_links',                 // (array)  The specified links for each social networking site. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  | 			'identity_crisis_whitelist',    // (array)  An array of options, each having an array of the values whitelisted for it. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  | 			'gplus_authors',                // (array)  The Google+ authorship information for connected users. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  | 			'last_heartbeat',               // (int)    The timestamp of the last heartbeat that fired. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  | 			'jumpstart',                    // (string) A flag for whether or not to show the Jump Start.  Accepts: new_connection, jumpstart_activated, jumpstart_dismissed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  | 			'hide_jitm',                    // (array)  A list of just in time messages that we should not show because they have been dismissed by the user | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  | 			'custom_css_4.7_migration',     // (bool)   Whether Custom CSS has scanned for and migrated any legacy CSS CPT entries to the new Core format. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  | 			'image_widget_migration',       // (bool)   Whether any legacy Image Widgets have been converted to the new Core widget | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  | 			'gallery_widget_migration',     // (bool)   Whether any legacy Gallery Widgets have been converted to the new Core widget | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  | 			'sso_first_login',              // (bool)   Is this the first time the user logins via SSO. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  | 			'dismissed_hints',              // (array)  Part of Plugin Search Hints. List of cards that have been dismissed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  | 			'first_admin_view',             // (bool)   Set to true the first time the user views the admin. Usually after the initial connection. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  | 	 * Is the option name valid? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  | 	 * @param string      $name  The name of the option | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  | 	 * @param string|null $group The name of the group that the option is in. Default to null, which will search non_compact. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  | 	 * @return bool Is the option name valid? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  | 	public static function is_valid( $name, $group = null ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | 		if ( is_array( $name ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  | 			$compact_names = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  | 			foreach ( array_keys( self::$grouped_options ) as $_group ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  | 				$compact_names = array_merge( $compact_names, self::get_option_names( $_group ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | 			$result = array_diff( $name, self::get_option_names( 'non_compact' ), $compact_names ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  | 			return empty( $result ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 159 |  | View Code Duplication | 		if ( is_null( $group ) || 'non_compact' === $group ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  | 			if ( in_array( $name, self::get_option_names( $group ) ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  | 				return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  | 		foreach ( array_keys( self::$grouped_options ) as $_group ) { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 166 |  | View Code Duplication | 			if ( is_null( $group ) || $group === $_group ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  | 				if ( in_array( $name, self::get_option_names( $_group ) ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  | 					return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  | 		return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  | 	 * Checks if an option must be saved for the whole network in WP Multisite | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  | 	 * @param string $option_name Option name. It must come _without_ `jetpack_%` prefix. The method will prefix the option name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  | 	 * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  | 	public static function is_network_option( $option_name ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  | 		if ( ! is_multisite() ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  | 		return in_array( $option_name, self::get_option_names( 'network' ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  | 	 * Returns the requested option.  Looks in jetpack_options or jetpack_$name as appropriate. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  | 	 * @param string $name Option name. It must come _without_ `jetpack_%` prefix. The method will prefix the option name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  | 	 * @param mixed $default (optional) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  | 	 * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  | 	public static function get_option( $name, $default = false ) { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 199 |  | View Code Duplication | 		if ( self::is_valid( $name, 'non_compact' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  | 			if ( self::is_network_option( $name ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  | 				return get_site_option( "jetpack_$name", $default ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  | 			return get_option( "jetpack_$name", $default ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  | 		foreach ( array_keys( self::$grouped_options ) as $group ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  | 			if ( self::is_valid( $name, $group ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  | 				return self::get_grouped_option( $group, $name, $default ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  | 		trigger_error( sprintf( 'Invalid Jetpack option name: %s', $name ), E_USER_WARNING ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  | 		return $default; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  | 	 * Returns the requested option, and ensures it's autoloaded in the future. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  | 	 * This does _not_ adjust the prefix in any way (does not prefix jetpack_%) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  | 	 * @param string $name Option name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  | 	 * @param mixed $default (optional) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  | 	 * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  | 	public static function get_option_and_ensure_autoload( $name, $default ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  | 		// In this function the name is not adjusted by prefixing jetpack_ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  | 		// so if it has already prefixed, we'll replace it and then | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  | 		// check if the option name is a network option or not | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  | 		$jetpack_name = preg_replace( '/^jetpack_/', '', $name, 1 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  | 		$is_network_option = self::is_network_option( $jetpack_name ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  | 		$value = $is_network_option ? get_site_option( $name ) : get_option( $name ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  | 		if ( false === $value && false !== $default ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  | 			if ( $is_network_option ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  | 				add_site_option( $name, $default ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  | 				add_option( $name, $default ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  | 			$value = $default; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  | 		return $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  | 	private static function update_grouped_option( $group, $name, $value ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  | 		$options = get_option( self::$grouped_options[ $group ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  | 		if ( ! is_array( $options ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  | 			$options = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  | 		$options[ $name ] = $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  | 		return update_option( self::$grouped_options[ $group ], $options ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  | 	 * Updates the single given option.  Updates jetpack_options or jetpack_$name as appropriate. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  | 	 * @param string $name Option name. It must come _without_ `jetpack_%` prefix. The method will prefix the option name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  | 	 * @param mixed $value Option value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  | 	 * @param string $autoload If not compact option, allows specifying whether to autoload or not. | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  | 	 * @return bool Was the option successfully updated? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  | 	public static function update_option( $name, $value, $autoload = null ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  | 		 * Fires before Jetpack updates a specific option. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  | 		 * @since 3.0.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  | 		 * @param str $name The name of the option being updated. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  | 		 * @param mixed $value The new value of the option. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  | 		do_action( 'pre_update_jetpack_option_' . $name, $name, $value ); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 276 |  | View Code Duplication | 		if ( self::is_valid( $name, 'non_compact' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  | 			if ( self::is_network_option( $name ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  | 				return update_site_option( "jetpack_$name", $value ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  | 			return update_option( "jetpack_$name", $value, $autoload ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  | 		foreach ( array_keys( self::$grouped_options ) as $group ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  | 			if ( self::is_valid( $name, $group ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | 				return self::update_grouped_option( $group, $name, $value ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  | 		trigger_error( sprintf( 'Invalid Jetpack option name: %s', $name ), E_USER_WARNING ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | 		return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | 	 * Updates the multiple given options.  Updates jetpack_options and/or jetpack_$name as appropriate. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | 	 * @param array $array array( option name => option value, ... ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | 	public static function update_options( $array ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | 		$names = array_keys( $array ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | 		foreach ( array_diff( $names, self::get_option_names(), self::get_option_names( 'non_compact' ), self::get_option_names( 'private' ) ) as $unknown_name ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  | 			trigger_error( sprintf( 'Invalid Jetpack option name: %s', $unknown_name ), E_USER_WARNING ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | 			unset( $array[ $unknown_name ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | 		foreach ( $names as $name ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | 			self::update_option( $name, $array[ $name ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | 	 * Deletes the given option.  May be passed multiple option names as an array. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | 	 * Updates jetpack_options and/or deletes jetpack_$name as appropriate. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | 	 * @param string|array $names Option names. They must come _without_ `jetpack_%` prefix. The method will prefix the option names. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | 	 * @return bool Was the option successfully deleted? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | 	public static function delete_option( $names ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | 		$result = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  | 		$names  = (array) $names; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  | 		if ( ! self::is_valid( $names ) ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | 			trigger_error( sprintf( 'Invalid Jetpack option names: %s', print_r( $names, 1 ) ), E_USER_WARNING ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | 		foreach ( array_intersect( $names, self::get_option_names( 'non_compact' ) ) as $name ) { | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 332 |  | View Code Duplication | 			if ( self::is_network_option( $name ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | 				$result = delete_site_option( "jetpack_$name" ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | 			} else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | 				$result = delete_option( "jetpack_$name" ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  | 		foreach ( array_keys( self::$grouped_options ) as $group ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  | 			if ( ! self::delete_grouped_option( $group, $names ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  | 				$result = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  | 		return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 349 |  | View Code Duplication | 	private static function get_grouped_option( $group, $name, $default ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  | 		$options = get_option( self::$grouped_options[ $group ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  | 		if ( is_array( $options ) && isset( $options[ $name ] ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  | 			return $options[ $name ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  | 		return $default; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  | 	private static function delete_grouped_option( $group, $names ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  | 		$options = get_option( self::$grouped_options[ $group ], array() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  | 		$to_delete = array_intersect( $names, self::get_option_names( $group ), array_keys( $options ) ); | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 362 |  | View Code Duplication | 		if ( $to_delete ) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  | 			foreach ( $to_delete as $name ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  | 				unset( $options[ $name ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  | 			return update_option( self::$grouped_options[ $group ], $options ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  | 		return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  | 	// Raw option methods allow Jetpack to get / update / delete options via direct DB queries, including options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  | 	// that are not created by the Jetpack plugin. This is helpful only in rare cases when we need to bypass | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  | 	// cache and filters. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  | 	 * Deletes an option via $wpdb query. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  | 	 * @param string $name Option name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  | 	 * @return bool Is the option deleted? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  | 	static function delete_raw_option( $name ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  | 		if ( self::bypass_raw_option( $name ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  | 			return delete_option( $name ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  | 		global $wpdb; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  | 		$result = $wpdb->query( $wpdb->prepare( "DELETE FROM $wpdb->options WHERE option_name = %s", $name ) ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  | 		return $result; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  | 	 * Updates an option via $wpdb query. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  | 	 * @param string $name Option name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  | 	 * @param mixed $value Option value. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  | 	 * @param bool $autoload Specifying whether to autoload or not. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  | 	 * @return bool Is the option updated? | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  | 	static function update_raw_option( $name, $value, $autoload = false ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  | 		if ( self::bypass_raw_option( $name ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  | 			return update_option( $name, $value, $autoload ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  | 		global $wpdb; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  | 		$autoload_value = $autoload ? 'yes' : 'no'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  | 		$old_value = $wpdb->get_var( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  | 			$wpdb->prepare( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  | 				"SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  | 				$name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  | 		if ( $old_value === $value ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  | 			return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  | 		$serialized_value = maybe_serialize( $value ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  | 		// below we used "insert ignore" to at least suppress the resulting error | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  | 		$updated_num = $wpdb->query( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  | 			$wpdb->prepare( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  | 				"UPDATE $wpdb->options SET option_value = %s WHERE option_name = %s", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  | 				$serialized_value, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  | 				$name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  | 		// Try inserting the option if the value doesn't exits. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  | 		if ( ! $updated_num ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  | 			$updated_num = $wpdb->query( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  | 				$wpdb->prepare( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  | 					"INSERT IGNORE INTO $wpdb->options ( option_name, option_value, autoload ) VALUES ( %s, %s, '$autoload_value' )", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  | 					$name, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  | 					$serialized_value | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  | 				) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  | 		return (bool) $updated_num; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  | 	 * Gets an option via $wpdb query. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  | 	 * @since 5.4.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  | 	 * @param string $name Option name. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  | 	 * @param mixed $default Default option value if option is not found. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  | 	 * @return mixed Option value, or null if option is not found and default is not specified. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 452 |  | View Code Duplication | 	static function get_raw_option( $name, $default = null ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  | 		if ( self::bypass_raw_option( $name ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  | 			return get_option( $name, $default ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  | 		global $wpdb; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  | 		$value = $wpdb->get_var( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  | 			$wpdb->prepare( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  | 				"SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  | 				$name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  | 			) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  | 		$value = maybe_unserialize( $value ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  | 		if ( $value === null && $default !== null ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  | 			return $default; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  | 		return $value; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  | 	 * This function checks for a constant that, if present, will disable direct DB queries Jetpack uses to manage certain options and force Jetpack to always use Options API instead. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  | 	 * Options can be selectively managed via a blacklist by filtering option names via the jetpack_disabled_raw_option filter. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  | 	 * @param $name Option name | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  | 	 * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 481 |  | View Code Duplication | 	static function bypass_raw_option( $name ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  | 		if ( Jetpack_Constants::get_constant( 'JETPACK_DISABLE_RAW_OPTIONS' ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  | 			return true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  | 		/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  | 		 * Allows to disable particular raw options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  | 		 * @since 5.5.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  | 		 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  | 		 * @param array $disabled_raw_options An array of option names that you can selectively blacklist from being managed via direct database queries. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  | 		 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  | 		$disabled_raw_options = apply_filters( 'jetpack_disabled_raw_options', array() ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  | 		return isset( $disabled_raw_options[ $name ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  | 	 * Gets all known options that are used by Jetpack and managed by Jetpack_Options. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  | 	 * @since 5.4.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  | 	 * @param boolean $strip_unsafe_options If true, and by default, will strip out options necessary for the connection to WordPress.com. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  | 	 * @return array An array of all options managed via the Jetpack_Options class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  | 	static function get_all_jetpack_options( $strip_unsafe_options = true ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  | 		$jetpack_options            = self::get_option_names(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  | 		$jetpack_options_non_compat = self::get_option_names( 'non_compact' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  | 		$jetpack_options_private    = self::get_option_names( 'private' ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  | 		$all_jp_options = array_merge( $jetpack_options, $jetpack_options_non_compat, $jetpack_options_private ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  | 		if ( $strip_unsafe_options ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  | 			// Flag some Jetpack options as unsafe | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  | 			$unsafe_options = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  | 				'id',                           // (int)    The Client ID/WP.com Blog ID of this site. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  | 				'master_user',                  // (int)    The local User ID of the user who connected this site to jetpack.wordpress.com. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  | 				'version',                      // (string) Used during upgrade procedure to auto-activate new modules. version:time | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  | 				'jumpstart',                    // (string) A flag for whether or not to show the Jump Start.  Accepts: new_connection, jumpstart_activated, jumpstart_dismissed. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  | 				// non_compact | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  | 				'activated', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  | 				// private | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  | 				'register', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  | 				'blog_token',                  // (string) The Client Secret/Blog Token of this site. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  | 				'user_token',                  // (string) The User Token of this site. (deprecated) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  | 				'user_tokens' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  | 			); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  | 			// Remove the unsafe Jetpack options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  | 			foreach ( $unsafe_options as $unsafe_option ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  | 				if ( false !== ( $key = array_search( $unsafe_option, $all_jp_options ) ) ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  | 					unset( $all_jp_options[ $key ] ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  | 				} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  | 			} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  | 		return $all_jp_options; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  | 	 * Get all options that are not managed by the Jetpack_Options class that are used by Jetpack. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  | 	 * @since 5.4.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  | 	 * @return array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  | 	static function get_all_wp_options() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  | 		// A manual build of the wp options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  | 		return array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  | 			'sharing-options', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  | 			'disabled_likes', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  | 			'disabled_reblogs', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  | 			'jetpack_comments_likes_enabled', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  | 			'wp_mobile_excerpt', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  | 			'wp_mobile_featured_images', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  | 			'wp_mobile_app_promos', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  | 			'stats_options', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  | 			'stats_dashboard_widget', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  | 			'safecss_preview_rev', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  | 			'safecss_rev', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  | 			'safecss_revision_migrated', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  | 			'nova_menu_order', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  | 			'jetpack_portfolio', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  | 			'jetpack_portfolio_posts_per_page', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  | 			'jetpack_testimonial', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  | 			'jetpack_testimonial_posts_per_page', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  | 			'wp_mobile_custom_css', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  | 			'sharedaddy_disable_resources', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  | 			'sharing-options', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  | 			'sharing-services', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  | 			'site_icon_temp_data', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  | 			'featured-content', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  | 			'site_logo', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  | 			'jetpack_dismissed_notices', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  | 			'jetpack-twitter-cards-site-tag', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  | 			'jetpack-sitemap-state', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  | 			'jetpack_sitemap_post_types', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  | 			'jetpack_sitemap_location', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  | 			'jetpack_protect_key', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  | 			'jetpack_protect_blocked_attempts', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  | 			'jetpack_protect_activating', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  | 			'jetpack_connection_banner_ab', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  | 			'jetpack_active_plan', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  | 			'jetpack_activation_source', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  | 			'jetpack_sso_match_by_email', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  | 			'jetpack_sso_require_two_step', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  | 			'jetpack_sso_remove_login_form', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  | 			'jetpack_last_connect_url_check', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  | 			'jpo_business_address', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  | 			'jpo_site_type', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  | 			'jpo_homepage_format', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  | 			'jpo_contact_page', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  | 			'jetpack_excluded_extensions', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  | 	 * Gets all options that can be safely reset by CLI. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  | 	 * @since 5.4.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  | 	 * @return array array Associative array containing jp_options which are managed by the Jetpack_Options class and wp_options which are not. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  | 	static function get_options_for_reset() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  | 		$all_jp_options = self::get_all_jetpack_options(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  | 		$wp_options = self::get_all_wp_options(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  | 		$options = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  | 			'jp_options' => $all_jp_options, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  | 			'wp_options' => $wp_options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  | 		); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  | 		return $options; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  | 	/** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  | 	 * Delete all known options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  | 	 * @since 5.4.0 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  | 	 * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  | 	 * @return void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  | 	 */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  | 	static function delete_all_known_options() { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  | 		// Delete all compact options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  | 		foreach ( (array) self::$grouped_options as $option_name ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  | 			delete_option( $option_name ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  | 		// Delete all non-compact Jetpack options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  | 		foreach ( (array) self::get_option_names( 'non-compact' ) as $option_name ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  | 			Jetpack_Options::delete_option( $option_name ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  | 		// Delete all options that can be reset via CLI, that aren't Jetpack options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  | 		foreach ( (array) self::get_all_wp_options() as $option_name ) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  | 			delete_option( $option_name ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  | 		} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  | 	} | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 640 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 641 |  |  |  | 
            
                        
This check looks for
@paramannotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.