Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
2.08% |
2 / 96 |
|
3.12% |
2 / 64 |
CRAP | |
0.00% |
0 / 1 |
| Jetpack_Site | |
2.17% |
2 / 92 |
|
3.12% |
2 / 64 |
6071.62 | |
0.00% |
0 / 1 |
| get_mock_option | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_constant | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
| main_network_site | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| wp_version | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| max_upload_size | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| wp_memory_limit | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| wp_max_memory_limit | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_main_network | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_multisite | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_single_user_site | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_version_controlled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| file_system_write_access | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| current_theme_supports | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_theme_support | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_connection_active_plugins | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| get_updates | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_id | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| has_videopress | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| get_videopress_storage_used | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| upgraded_filetypes_enabled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_mapped_domain | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_unmapped_url | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_redirect | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_following | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_site_owner | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| has_wordads | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_frame_nonce | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_jetpack_frame_nonce | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_headstart_fresh | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| allowed_file_types | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
12 | |||
| is_private | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_coming_soon | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |||
| get_launch_status | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_atomic_cloud_site_option | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
20 | |||
| get_plan | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_subscribers_count | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_capabilities | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_locale | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_jetpack | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| is_jetpack_connection | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_jetpack_version | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_ak_vp_bundle_enabled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_jetpack_seo_front_page_description | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_jetpack_seo_title_formats | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_verification_services_codes | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_podcasting_archive | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_connected_site | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_wpforteams_site | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| current_user_can | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_fse_active | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
20 | |||
| is_fse_eligible | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
20 | |||
| is_core_site_editor_enabled | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_import_engine | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| wrap_post | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| get_anchor_podcast | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_user_interactions | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_deleted | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_a4a_client | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_wpcom_staging_site | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_wpcom_production_blog_id | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_wpcom_staging_blog_ids | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_wpcom_admin_interface | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| get_zendesk_site_meta | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| is_pending_plan | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | /** |
| 3 | * This class extends the Abstract_Jetpack_Site class, which includes providing |
| 4 | * the implementation for functions that were declared in that class. |
| 5 | * |
| 6 | * @see class.json-api-site-jetpack-base.php for more context on some of |
| 7 | * the functions extended here. |
| 8 | * |
| 9 | * @package automattic/jetpack |
| 10 | */ |
| 11 | use Automattic\Jetpack\Status\Host; |
| 12 | use Automattic\Jetpack\Sync\Functions; |
| 13 | |
| 14 | if ( ! defined( 'ABSPATH' ) ) { |
| 15 | exit( 0 ); |
| 16 | } |
| 17 | |
| 18 | require_once __DIR__ . '/class.json-api-site-jetpack-base.php'; |
| 19 | require_once __DIR__ . '/class.json-api-post-jetpack.php'; |
| 20 | |
| 21 | /** |
| 22 | * Base class for Jetpack_Site. This code runs on Jetpack (.org) sites. |
| 23 | */ |
| 24 | class Jetpack_Site extends Abstract_Jetpack_Site { |
| 25 | |
| 26 | /** |
| 27 | * Retrieves a Jetpack option's value, given the option name. |
| 28 | * |
| 29 | * @param string $name the name of the Jetpack option, without the 'jetpack' prefix (eg. 'log' for 'jetpack_log'). |
| 30 | * |
| 31 | * @return mixed |
| 32 | */ |
| 33 | protected function get_mock_option( $name ) { |
| 34 | return get_option( 'jetpack_' . $name ); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * If a Jetpack constant name has been defined, this will return the value of the constant. |
| 39 | * |
| 40 | * @param string $name the name of the Jetpack constant to check. |
| 41 | * |
| 42 | * @return mixed |
| 43 | */ |
| 44 | protected function get_constant( $name ) { |
| 45 | if ( defined( $name ) ) { |
| 46 | return constant( $name ); |
| 47 | } |
| 48 | return null; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Returns the site URL for the current network. |
| 53 | * |
| 54 | * @return string |
| 55 | */ |
| 56 | protected function main_network_site() { |
| 57 | return network_site_url(); |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Returns the WordPress version for the current site. |
| 62 | * |
| 63 | * @return string |
| 64 | */ |
| 65 | protected function wp_version() { |
| 66 | global $wp_version; |
| 67 | return $wp_version; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Returns the maximum upload size allowed in php.ini. |
| 72 | * |
| 73 | * @return int |
| 74 | */ |
| 75 | protected function max_upload_size() { |
| 76 | return wp_max_upload_size(); |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * This function returns the value of the 'WP_MEMORY_LIMIT' constant converted to an integer byte value. |
| 81 | * |
| 82 | * @return int |
| 83 | */ |
| 84 | protected function wp_memory_limit() { |
| 85 | return wp_convert_hr_to_bytes( WP_MEMORY_LIMIT ); |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * This function returns the value of the 'WP_MAX_MEMORY_LIMIT' constant converted to an integer byte value. |
| 90 | * |
| 91 | * @return int |
| 92 | */ |
| 93 | protected function wp_max_memory_limit() { |
| 94 | return wp_convert_hr_to_bytes( WP_MAX_MEMORY_LIMIT ); |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Returns true if the site is within a system with a multiple networks, false otherwise. |
| 99 | * |
| 100 | * @see /projects/packages/status/src/class-status.php |
| 101 | * |
| 102 | * @return bool |
| 103 | */ |
| 104 | protected function is_main_network() { |
| 105 | return Jetpack::is_multi_network(); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Returns true if Multisite is enabled, false otherwise. |
| 110 | * |
| 111 | * @return bool |
| 112 | */ |
| 113 | public function is_multisite() { |
| 114 | return (bool) is_multisite(); |
| 115 | } |
| 116 | |
| 117 | /** |
| 118 | * Returns true if the current site is a single user site, false otherwise. |
| 119 | * |
| 120 | * @return bool |
| 121 | */ |
| 122 | public function is_single_user_site() { |
| 123 | return (bool) Jetpack::is_single_user_site(); |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Returns true if is_vcs_checkout discovers a version control checkout, false otherwise. |
| 128 | * |
| 129 | * @see projects/packages/sync/src/class-functions.php. |
| 130 | * |
| 131 | * @return bool |
| 132 | */ |
| 133 | protected function is_version_controlled() { |
| 134 | return Functions::is_version_controlled(); |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Returns true if the site has file write access, false otherwise. |
| 139 | * |
| 140 | * @see projects/packages/sync/src/class-functions.php. |
| 141 | * |
| 142 | * @return bool |
| 143 | */ |
| 144 | protected function file_system_write_access() { |
| 145 | return Functions::file_system_write_access(); |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Returns true if the current theme supports the $feature_name, false otherwise. |
| 150 | * |
| 151 | * @param string $feature_name the name of the Jetpack feature. |
| 152 | * |
| 153 | * @return bool |
| 154 | */ |
| 155 | protected function current_theme_supports( $feature_name ) { |
| 156 | return current_theme_supports( $feature_name ); |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Gets theme support arguments to be checked against the specific Jetpack feature. |
| 161 | * |
| 162 | * @param string $feature_name the name of the Jetpack feature to check against. |
| 163 | * |
| 164 | * @return array |
| 165 | */ |
| 166 | protected function get_theme_support( $feature_name ) { |
| 167 | return get_theme_support( $feature_name ); |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Fetch a list of active plugins that are using Jetpack Connection. |
| 172 | * |
| 173 | * @return array An array of active plugins (by slug) that are using Jetpack Connection. |
| 174 | */ |
| 175 | protected function get_connection_active_plugins() { |
| 176 | $plugins = $this->get_mock_option( 'connection_active_plugins' ); |
| 177 | |
| 178 | return is_array( $plugins ) ? array_keys( $plugins ) : array(); |
| 179 | } |
| 180 | |
| 181 | /** |
| 182 | * Gets updates and then stores them in the jetpack_updates option, returning an array with the option schema. |
| 183 | * |
| 184 | * @return array |
| 185 | */ |
| 186 | public function get_updates() { |
| 187 | return (array) Jetpack::get_updates(); |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * Returns the Jetpack blog ID for a site. |
| 192 | * |
| 193 | * @return int |
| 194 | */ |
| 195 | public function get_id() { |
| 196 | return $this->platform->token->blog_id; |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * Returns true if a site has the 'videopress' option enabled, false otherwise. |
| 201 | * |
| 202 | * @return bool |
| 203 | */ |
| 204 | public function has_videopress() { |
| 205 | // TODO - this only works on wporg site - need to detect videopress option for remote Jetpack site on WPCOM. |
| 206 | $videopress = Jetpack_Options::get_option( 'videopress', array() ); |
| 207 | if ( isset( $videopress['blog_id'] ) && $videopress['blog_id'] > 0 ) { |
| 208 | return true; |
| 209 | } |
| 210 | |
| 211 | return false; |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * Returns VideoPress storage used, in MB. |
| 216 | * |
| 217 | * @see class.json-api-site-jetpack-shadow.php on WordPress.com for implementation. Only applicable on WordPress.com. |
| 218 | * |
| 219 | * @return float |
| 220 | */ |
| 221 | public function get_videopress_storage_used() { |
| 222 | return 0; |
| 223 | } |
| 224 | |
| 225 | /** |
| 226 | * Sets the upgraded_filetypes_enabled Jetpack option to true as a default. |
| 227 | * |
| 228 | * Only relevant for WordPress.com sites: |
| 229 | * See wpcom_site_has_upgraded_upload_filetypes at /wpcom/wp-content/mu-plugins/misc.php. |
| 230 | * |
| 231 | * @return bool |
| 232 | */ |
| 233 | public function upgraded_filetypes_enabled() { |
| 234 | return true; |
| 235 | } |
| 236 | |
| 237 | /** |
| 238 | * Sets the is_mapped_domain Jetpack option to true as a default. |
| 239 | * |
| 240 | * Primarily used in WordPress.com to confirm the current blog's domain does or doesn't match the primary redirect. |
| 241 | * |
| 242 | * @see /wpcom/wp-content/mu-plugins/insecure-content-helpers.php within WordPress.com. |
| 243 | * |
| 244 | * @return bool |
| 245 | */ |
| 246 | public function is_mapped_domain() { |
| 247 | return true; |
| 248 | } |
| 249 | |
| 250 | /** |
| 251 | * Fallback to the home URL since all Jetpack sites don't have an unmapped *.wordpress.com domain. |
| 252 | * |
| 253 | * @return string |
| 254 | */ |
| 255 | public function get_unmapped_url() { |
| 256 | // Fallback to the home URL since all Jetpack sites don't have an unmapped *.wordpress.com domain. |
| 257 | return $this->get_url(); |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * Whether the domain is a site redirect or not. Defaults to false on a Jetpack site. |
| 262 | * |
| 263 | * Primarily used in WordPress.com where it is determined if a HTTP status check is a redirect or not and whether an exception should be thrown. |
| 264 | * |
| 265 | * @see /wpcom/wp-includes/Requests/Response.php within WordPress.com. |
| 266 | * |
| 267 | * @return bool |
| 268 | */ |
| 269 | public function is_redirect() { |
| 270 | return false; |
| 271 | } |
| 272 | |
| 273 | /** |
| 274 | * Whether or not the current user is following this blog. Defaults to false. |
| 275 | * |
| 276 | * @return bool |
| 277 | */ |
| 278 | public function is_following() { |
| 279 | return false; |
| 280 | } |
| 281 | |
| 282 | /** |
| 283 | * Points to the user ID of the site owner |
| 284 | * |
| 285 | * @return null for Jetpack sites |
| 286 | */ |
| 287 | public function get_site_owner() { |
| 288 | return null; |
| 289 | } |
| 290 | |
| 291 | /** |
| 292 | * Whether or not the Jetpack 'wordads' module is active on the site. |
| 293 | * |
| 294 | * @return bool |
| 295 | */ |
| 296 | public function has_wordads() { |
| 297 | return Jetpack::is_module_active( 'wordads' ); |
| 298 | } |
| 299 | |
| 300 | /** |
| 301 | * Defaults to false on Jetpack sites, however is used on WordPress.com sites. This nonce is used for previews on Jetpack sites. |
| 302 | * |
| 303 | * @see /wpcom/public.api/rest/sal/class.json-api-site-jetpack-shadow.php. |
| 304 | * |
| 305 | * @return bool |
| 306 | */ |
| 307 | public function get_frame_nonce() { |
| 308 | return false; |
| 309 | } |
| 310 | |
| 311 | /** |
| 312 | * Defaults to false on Jetpack sites, however is used on WordPress.com sites, |
| 313 | * where it creates a nonce to be used with iframed block editor requests to a Jetpack site. |
| 314 | * |
| 315 | * @see /wpcom/public.api/rest/sal/class.json-api-site-jetpack-shadow.php. |
| 316 | * |
| 317 | * @return bool |
| 318 | */ |
| 319 | public function get_jetpack_frame_nonce() { |
| 320 | return false; |
| 321 | } |
| 322 | |
| 323 | /** |
| 324 | * Defaults to false on Jetpack sites, however is used on WordPress.com sites, where it returns true if the headstart-fresh blog sticker is present. |
| 325 | * |
| 326 | * @see /wpcom/public.api/rest/sal/trait.json-api-site-wpcom.php. |
| 327 | * |
| 328 | * @return bool |
| 329 | */ |
| 330 | public function is_headstart_fresh() { |
| 331 | return false; |
| 332 | } |
| 333 | |
| 334 | /** |
| 335 | * Returns the allowed mime types and file extensions for a site. |
| 336 | * |
| 337 | * @return array |
| 338 | */ |
| 339 | public function allowed_file_types() { |
| 340 | $allowed_file_types = array(); |
| 341 | |
| 342 | // https://codex.wordpress.org/Uploading_Files. |
| 343 | $mime_types = get_allowed_mime_types(); |
| 344 | foreach ( $mime_types as $type => $mime_type ) { |
| 345 | $extras = explode( '|', $type ); |
| 346 | foreach ( $extras as $extra ) { |
| 347 | $allowed_file_types[] = $extra; |
| 348 | } |
| 349 | } |
| 350 | |
| 351 | return $allowed_file_types; |
| 352 | } |
| 353 | |
| 354 | /** |
| 355 | * Return site's privacy status. |
| 356 | * |
| 357 | * @return bool Is site private? |
| 358 | */ |
| 359 | public function is_private() { |
| 360 | return (int) $this->get_atomic_cloud_site_option( 'blog_public' ) === -1; |
| 361 | } |
| 362 | |
| 363 | /** |
| 364 | * Return site's coming soon status. |
| 365 | * |
| 366 | * @return bool Is site "Coming soon"? |
| 367 | */ |
| 368 | public function is_coming_soon() { |
| 369 | return $this->is_private() && (int) $this->get_atomic_cloud_site_option( 'wpcom_coming_soon' ) === 1; |
| 370 | } |
| 371 | |
| 372 | /** |
| 373 | * Return site's launch status. |
| 374 | * |
| 375 | * @return string|bool Launch status ('launched', 'unlaunched', or false). |
| 376 | */ |
| 377 | public function get_launch_status() { |
| 378 | return $this->get_atomic_cloud_site_option( 'launch-status' ); |
| 379 | } |
| 380 | |
| 381 | /** |
| 382 | * Given an option name, returns false if the site isn't WoA or doesn't have the ability to retrieve cloud site options. |
| 383 | * Otherwise, if the option name exists amongst Jetpack options, the option value is returned. |
| 384 | * |
| 385 | * @param string $option The option name to check. |
| 386 | * |
| 387 | * @return string|bool |
| 388 | */ |
| 389 | public function get_atomic_cloud_site_option( $option ) { |
| 390 | if ( ! ( new Host() )->is_woa_site() ) { |
| 391 | return false; |
| 392 | } |
| 393 | |
| 394 | $jetpack = Jetpack::init(); |
| 395 | if ( ! method_exists( $jetpack, 'get_cloud_site_options' ) ) { |
| 396 | return false; |
| 397 | } |
| 398 | |
| 399 | $result = $jetpack->get_cloud_site_options( array( $option ) ); |
| 400 | if ( ! array_key_exists( $option, $result ) ) { |
| 401 | return false; |
| 402 | } |
| 403 | |
| 404 | return $result[ $option ]; |
| 405 | } |
| 406 | |
| 407 | /** |
| 408 | * Defaults to false instead of returning the current site plan. |
| 409 | * |
| 410 | * @return bool |
| 411 | */ |
| 412 | public function get_plan() { |
| 413 | return false; |
| 414 | } |
| 415 | |
| 416 | /** |
| 417 | * Defaults to 0 for the number of WordPress.com subscribers - this is filled in on the WordPress.com side. |
| 418 | * |
| 419 | * @see /wpcom/public.api/rest/sal/trait.json-api-site-wpcom.php. |
| 420 | * |
| 421 | * @return int |
| 422 | */ |
| 423 | public function get_subscribers_count() { |
| 424 | return 0; |
| 425 | } |
| 426 | |
| 427 | /** |
| 428 | * Defaults to false - this is filled on the WordPress.com side in multiple locations. |
| 429 | * |
| 430 | * @see WPCOM_JSON_API_GET_Site_Endpoint::decorate_jetpack_response. |
| 431 | * @return bool |
| 432 | */ |
| 433 | public function get_capabilities() { |
| 434 | return false; |
| 435 | } |
| 436 | |
| 437 | /** |
| 438 | * Returns the language code for the current site. |
| 439 | * |
| 440 | * @return string |
| 441 | */ |
| 442 | public function get_locale() { |
| 443 | return get_bloginfo( 'language' ); |
| 444 | } |
| 445 | |
| 446 | /** |
| 447 | * The flag indicates that the site has Jetpack installed. |
| 448 | * |
| 449 | * @return bool |
| 450 | */ |
| 451 | public function is_jetpack() { |
| 452 | return true; |
| 453 | } |
| 454 | |
| 455 | /** |
| 456 | * The flag indicates that the site is connected to WP.com via Jetpack Connection. |
| 457 | * |
| 458 | * @return bool |
| 459 | */ |
| 460 | public function is_jetpack_connection() { |
| 461 | return true; |
| 462 | } |
| 463 | |
| 464 | /** |
| 465 | * Returns the current site's Jetpack version. |
| 466 | * |
| 467 | * @return string |
| 468 | */ |
| 469 | public function get_jetpack_version() { |
| 470 | return JETPACK__VERSION; |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * Empty function declaration - this function is filled out on the WordPress.com side, returning true if the site has an AK / VP bundle. |
| 475 | * |
| 476 | * @see /wpcom/public.api/rest/sal/class.json-api-site-jetpack-shadow.php. |
| 477 | */ |
| 478 | public function get_ak_vp_bundle_enabled() {} |
| 479 | |
| 480 | /** |
| 481 | * Returns the front page meta description for current site. |
| 482 | * |
| 483 | * @see /modules/seo-tools/class-jetpack-seo-utils.php. |
| 484 | * |
| 485 | * @return string |
| 486 | */ |
| 487 | public function get_jetpack_seo_front_page_description() { |
| 488 | return Jetpack_SEO_Utils::get_front_page_meta_description(); |
| 489 | } |
| 490 | |
| 491 | /** |
| 492 | * Returns custom title formats from site option. |
| 493 | * |
| 494 | * @see /modules/seo-tools/class-jetpack-seo-titles.php. |
| 495 | * |
| 496 | * @return array |
| 497 | */ |
| 498 | public function get_jetpack_seo_title_formats() { |
| 499 | return Jetpack_SEO_Titles::get_custom_title_formats(); |
| 500 | } |
| 501 | |
| 502 | /** |
| 503 | * Returns website verification codes. Allowed keys include: google, pinterest, bing, yandex, facebook. |
| 504 | * |
| 505 | * @see /modules/verification-tools/blog-verification-tools.php. |
| 506 | * |
| 507 | * @return array |
| 508 | */ |
| 509 | public function get_verification_services_codes() { |
| 510 | return get_option( 'verification_services_codes', null ); |
| 511 | } |
| 512 | |
| 513 | /** |
| 514 | * Returns null for Jetpack sites. For WordPress.com sites this returns the value of the 'podcasting_archive' option. |
| 515 | * |
| 516 | * @see /wpcom/public.api/rest/sal/class.json-api-site-wpcom.php. |
| 517 | * |
| 518 | * @return null |
| 519 | */ |
| 520 | public function get_podcasting_archive() { |
| 521 | return null; |
| 522 | } |
| 523 | |
| 524 | /** |
| 525 | * Defaulting to true, this function is expanded out on the WordPress.com side, returning an error if the site is not connected or not communicating to us. |
| 526 | * |
| 527 | * @see /wpcom/public.api/rest/sal/class.json-api-site-jetpack-shadow.php. |
| 528 | * |
| 529 | * @return bool |
| 530 | */ |
| 531 | public function is_connected_site() { |
| 532 | return true; |
| 533 | } |
| 534 | |
| 535 | /** |
| 536 | * Defaulting to false and not relevant for Jetpack sites, this is expanded on the WordPress.com side for a specific wp.com/start 'WP for teams' flow. |
| 537 | * |
| 538 | * @see /wpcom/public.api/rest/sal/class.json-api-site-wpcom.php. |
| 539 | * |
| 540 | * @return bool |
| 541 | */ |
| 542 | public function is_wpforteams_site() { |
| 543 | return false; |
| 544 | } |
| 545 | |
| 546 | /** |
| 547 | * Returns true if a user has got the capability that is being checked, false otherwise. |
| 548 | * |
| 549 | * @param string $role The capability to check. |
| 550 | * |
| 551 | * @return bool |
| 552 | */ |
| 553 | public function current_user_can( $role ) { |
| 554 | return current_user_can( $role ); |
| 555 | } |
| 556 | |
| 557 | /** |
| 558 | * Check if full site editing should be considered as currently active. Full site editing |
| 559 | * requires the FSE plugin to be installed and activated, as well the current |
| 560 | * theme to be FSE compatible. The plugin can also be explicitly disabled via the |
| 561 | * a8c_disable_full_site_editing filter. |
| 562 | * |
| 563 | * @since 7.7.0 |
| 564 | * |
| 565 | * @return bool true if full site editing is currently active. |
| 566 | */ |
| 567 | public function is_fse_active() { |
| 568 | if ( ! Jetpack::is_plugin_active( 'full-site-editing/full-site-editing-plugin.php' ) ) { |
| 569 | return false; |
| 570 | } |
| 571 | if ( function_exists( '\Automattic\Jetpack\Jetpack_Mu_Wpcom\Wpcom_Legacy_FSE\is_full_site_editing_active' ) ) { |
| 572 | // @phan-suppress-next-line PhanUndeclaredFunction |
| 573 | return \Automattic\Jetpack\Jetpack_Mu_Wpcom\Wpcom_Legacy_FSE\is_full_site_editing_active(); |
| 574 | } |
| 575 | return function_exists( '\A8C\FSE\is_full_site_editing_active' ) && \A8C\FSE\is_full_site_editing_active(); |
| 576 | } |
| 577 | |
| 578 | /** |
| 579 | * Check if site should be considered as eligible for full site editing. Full site editing |
| 580 | * requires the FSE plugin to be installed and activated. For this method to return true |
| 581 | * the current theme does not need to be FSE compatible. The plugin can also be explicitly |
| 582 | * disabled via the a8c_disable_full_site_editing filter. |
| 583 | * |
| 584 | * @since 8.1.0 |
| 585 | * |
| 586 | * @return bool true if site is eligible for full site editing |
| 587 | */ |
| 588 | public function is_fse_eligible() { |
| 589 | if ( ! Jetpack::is_plugin_active( 'full-site-editing/full-site-editing-plugin.php' ) ) { |
| 590 | return false; |
| 591 | } |
| 592 | if ( function_exists( '\Automattic\Jetpack\Jetpack_Mu_Wpcom\Wpcom_Legacy_FSE\is_site_eligible_for_full_site_editing' ) ) { |
| 593 | // @phan-suppress-next-line PhanUndeclaredFunction |
| 594 | return \Automattic\Jetpack\Jetpack_Mu_Wpcom\Wpcom_Legacy_FSE\is_site_eligible_for_full_site_editing(); |
| 595 | } |
| 596 | return function_exists( '\A8C\FSE\is_site_eligible_for_full_site_editing' ) && \A8C\FSE\is_site_eligible_for_full_site_editing(); |
| 597 | } |
| 598 | |
| 599 | /** |
| 600 | * Check if site should be considered as eligible for use of the core Site Editor. |
| 601 | * The Site Editor requires a block based theme to be active. |
| 602 | * |
| 603 | * @since 12.2 Uses wp_is_block_theme() to determine if site is eligible instead of gutenberg_is_fse_theme(). |
| 604 | * @return bool true if site is eligible for the Site Editor |
| 605 | */ |
| 606 | public function is_core_site_editor_enabled() { |
| 607 | return wp_is_block_theme(); |
| 608 | } |
| 609 | |
| 610 | /** |
| 611 | * Return the last engine used for an import on the site. Not used in Jetpack. |
| 612 | * |
| 613 | * @see /wpcom/public.api/rest/sal/class.json-api-site-wpcom.php. |
| 614 | * |
| 615 | * @return null |
| 616 | */ |
| 617 | public function get_import_engine() { |
| 618 | return null; |
| 619 | } |
| 620 | |
| 621 | /** |
| 622 | * Post functions |
| 623 | */ |
| 624 | |
| 625 | /** |
| 626 | * Wrap a WP_Post object with SAL methods, returning a Jetpack_Post object. |
| 627 | * |
| 628 | * @param WP_Post $post A WP_Post object. |
| 629 | * @param string $context The post request context (for example 'edit' or 'display'). |
| 630 | * |
| 631 | * @return Jetpack_Post |
| 632 | */ |
| 633 | public function wrap_post( $post, $context ) { |
| 634 | return new Jetpack_Post( $this, $post, $context ); |
| 635 | } |
| 636 | |
| 637 | /** |
| 638 | * Get the option storing the Anchor podcast ID that identifies a site as a podcasting site. |
| 639 | * |
| 640 | * @return string |
| 641 | */ |
| 642 | public function get_anchor_podcast() { |
| 643 | return $this->get_atomic_cloud_site_option( 'anchor_podcast' ); |
| 644 | } |
| 645 | |
| 646 | /** |
| 647 | * Get user interactions with a site. Not used in Jetpack. |
| 648 | * |
| 649 | * @see /wpcom/public.api/rest/sal/trait.json-api-site-wpcom.php. |
| 650 | * |
| 651 | * @return null |
| 652 | */ |
| 653 | public function get_user_interactions() { |
| 654 | return null; |
| 655 | } |
| 656 | |
| 657 | /** |
| 658 | * Get site deleted status. Not used in Jetpack. |
| 659 | * |
| 660 | * @see /wpcom/public.api/rest/sal/trait.json-api-site-wpcom.php. |
| 661 | * |
| 662 | * @return bool |
| 663 | */ |
| 664 | public function is_deleted() { |
| 665 | return false; |
| 666 | } |
| 667 | |
| 668 | /** |
| 669 | * Indicates that a site is an A4A client. Not used in Jetpack. |
| 670 | * |
| 671 | * @see /wpcom/public.api/rest/sal/trait.json-api-site-wpcom.php. |
| 672 | * |
| 673 | * @return bool |
| 674 | */ |
| 675 | public function is_a4a_client() { |
| 676 | return false; |
| 677 | } |
| 678 | |
| 679 | /** |
| 680 | * Detect whether a site is WordPress.com Staging Site. Not used in Jetpack. |
| 681 | * |
| 682 | * @see /wpcom/public.api/rest/sal/trait.json-api-site-wpcom.php. |
| 683 | * |
| 684 | * @return false |
| 685 | */ |
| 686 | public function is_wpcom_staging_site() { |
| 687 | return false; |
| 688 | } |
| 689 | |
| 690 | /** |
| 691 | * Get site option for the production blog id (if is a WP.com Staging Site). Not used in Jetpack. |
| 692 | * |
| 693 | * @see /wpcom/public.api/rest/sal/trait.json-api-site-wpcom.php. |
| 694 | * |
| 695 | * @return null |
| 696 | */ |
| 697 | public function get_wpcom_production_blog_id() { |
| 698 | return null; |
| 699 | } |
| 700 | |
| 701 | /** |
| 702 | * Get site option for the staging blog ids (if it has them). Not used in Jetpack. |
| 703 | * |
| 704 | * @see /wpcom/public.api/rest/sal/trait.json-api-site-wpcom.php. |
| 705 | * |
| 706 | * @return null |
| 707 | */ |
| 708 | public function get_wpcom_staging_blog_ids() { |
| 709 | return null; |
| 710 | } |
| 711 | |
| 712 | /** |
| 713 | * Get site option for the admin interface on WordPress.com Atomic sites. Not used in Jetpack. |
| 714 | * |
| 715 | * @return null |
| 716 | */ |
| 717 | public function get_wpcom_admin_interface() { |
| 718 | return null; |
| 719 | } |
| 720 | |
| 721 | /** |
| 722 | * Get Zendesk site meta. Not used in Jetpack. |
| 723 | * |
| 724 | * @return null |
| 725 | */ |
| 726 | public function get_zendesk_site_meta() { |
| 727 | return null; |
| 728 | } |
| 729 | |
| 730 | /** |
| 731 | * Detect whether there's a pending plan for this site. Not used in Jetpack. |
| 732 | * |
| 733 | * @return false |
| 734 | */ |
| 735 | public function is_pending_plan() { |
| 736 | return false; |
| 737 | } |
| 738 | } |