| @@ -4,9 +4,8 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * @package automattic/jetpack |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -use Automattic\Jetpack\Connection\Manager; | |
| 9 | 8 | use Automattic\Jetpack\Heartbeat; |
| 10 | 9 | |
| 11 | 10 | /** |
| 12 | 11 | * Jetpack Heartbeat. |
| @@ -54,10 +53,14 @@ | ||
| 54 | 53 | add_filter( 'jetpack_heartbeat_stats_array', array( $this, 'add_stats_to_heartbeat' ) ); |
| 55 | 54 | } |
| 56 | 55 | |
| 57 | 56 | /** |
| 58 | - * Generates heartbeat stats data. | |
| 57 | + * Generates Jetpack plugin heartbeat stats data. | |
| 59 | 58 | * |
| 59 | + * Site environment stats (WordPress/PHP versions, site configuration, etc.) are generated by | |
| 60 | + * the Connection package via `Automattic\Jetpack\Heartbeat::get_environment_stats()` so they are | |
| 61 | + * reported for every connected site. This method only returns Jetpack-plugin-specific stats. | |
| 62 | + * | |
| 60 | 63 | * @param string $prefix Prefix to add before stats identifier. |
| 61 | 64 | * |
| 62 | 65 | * @return array The stats array. |
| 63 | 66 | */ |
| @@ -64,59 +67,10 @@ | ||
| 64 | 67 | public static function generate_stats_array( $prefix = '' ) { |
| 65 | 68 | $return = array(); |
| 66 | 69 | |
| 67 | 70 | $return[ "{$prefix}version" ] = JETPACK__VERSION; |
| 68 | - $return[ "{$prefix}wp-version" ] = get_bloginfo( 'version' ); | |
| 69 | - $return[ "{$prefix}php-version" ] = PHP_VERSION; | |
| 70 | 71 | $return[ "{$prefix}branch" ] = (float) JETPACK__VERSION; |
| 71 | - $return[ "{$prefix}wp-branch" ] = (float) get_bloginfo( 'version' ); | |
| 72 | - $return[ "{$prefix}php-branch" ] = (float) PHP_VERSION; | |
| 73 | - $return[ "{$prefix}public" ] = Jetpack_Options::get_option( 'public' ); | |
| 74 | - $return[ "{$prefix}ssl" ] = Jetpack::permit_ssl(); | |
| 75 | - $return[ "{$prefix}is-https" ] = is_ssl() ? 'https' : 'http'; | |
| 76 | - $return[ "{$prefix}language" ] = get_bloginfo( 'language' ); | |
| 77 | - $return[ "{$prefix}charset" ] = get_bloginfo( 'charset' ); | |
| 78 | - $return[ "{$prefix}is-multisite" ] = is_multisite() ? 'multisite' : 'singlesite'; | |
| 79 | - $return[ "{$prefix}identitycrisis" ] = Jetpack::check_identity_crisis() ? 'yes' : 'no'; | |
| 80 | - $return[ "{$prefix}plugins" ] = implode( ',', Jetpack::get_active_plugins() ); | |
| 81 | - if ( function_exists( 'get_mu_plugins' ) ) { | |
| 82 | - $return[ "{$prefix}mu-plugins" ] = implode( ',', array_keys( get_mu_plugins() ) ); | |
| 83 | - } | |
| 84 | 72 | $return[ "{$prefix}manage-enabled" ] = true; |
| 85 | - | |
| 86 | - if ( function_exists( 'get_space_used' ) ) { // Only available in multisite. | |
| 87 | - $space_used = get_space_used(); | |
| 88 | - } else { | |
| 89 | - // This is the same as `get_space_used`, except it does not apply the short-circuit filter. | |
| 90 | - $upload_dir = wp_upload_dir(); | |
| 91 | - $space_used = get_dirsize( $upload_dir['basedir'] ) / MB_IN_BYTES; | |
| 92 | - } | |
| 93 | - | |
| 94 | - $return[ "{$prefix}space-used" ] = $space_used; | |
| 95 | - | |
| 96 | - $xmlrpc_errors = Jetpack_Options::get_option( 'xmlrpc_errors', array() ); | |
| 97 | - if ( $xmlrpc_errors ) { | |
| 98 | - $return[ "{$prefix}xmlrpc-errors" ] = implode( ',', array_keys( $xmlrpc_errors ) ); | |
| 99 | - Jetpack_Options::delete_option( 'xmlrpc_errors' ); | |
| 100 | - } | |
| 101 | - | |
| 102 | - // Missing the connection owner? | |
| 103 | - $connection_manager = new Manager(); | |
| 104 | - $return[ "{$prefix}missing-owner" ] = $connection_manager->is_missing_connection_owner(); | |
| 105 | - | |
| 106 | - // is-multi-network can have three values, `single-site`, `single-network`, and `multi-network`. | |
| 107 | - $return[ "{$prefix}is-multi-network" ] = 'single-site'; | |
| 108 | - if ( is_multisite() ) { | |
| 109 | - $return[ "{$prefix}is-multi-network" ] = Jetpack::is_multi_network() ? 'multi-network' : 'single-network'; | |
| 110 | - } | |
| 111 | - | |
| 112 | - if ( ! empty( $_SERVER['SERVER_ADDR'] ) || ! empty( $_SERVER['LOCAL_ADDR'] ) ) { | |
| 113 | - $ip = ! empty( $_SERVER['SERVER_ADDR'] ) ? wp_unslash( $_SERVER['SERVER_ADDR'] ) : wp_unslash( $_SERVER['LOCAL_ADDR'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Sanitized just below. | |
| 114 | - $ip_arr = array_map( 'intval', explode( '.', $ip ) ); | |
| 115 | - if ( 4 === count( $ip_arr ) ) { | |
| 116 | - $return[ "{$prefix}ip-2-octets" ] = implode( '.', array_slice( $ip_arr, 0, 2 ) ); | |
| 117 | - } | |
| 118 | - } | |
| 119 | 73 | |
| 120 | 74 | foreach ( Jetpack::get_available_modules() as $slug ) { |
| 121 | 75 | $return[ "{$prefix}module-{$slug}" ] = Jetpack::is_module_active( $slug ) ? 'on' : 'off'; |
| 122 | 76 | } |