jetpack
Last commit date
3rd-party
1 month ago
_inc
1 day ago
css
2 months ago
extensions
1 day ago
images
3 months ago
jetpack_vendor
1 day ago
json-endpoints
1 week ago
modules
1 day ago
sal
1 week ago
src
1 month ago
vendor
1 day ago
views
3 months ago
CHANGELOG.md
1 day ago
LICENSE.txt
7 months ago
SECURITY.md
1 month ago
class-jetpack-connection-status.php
2 years ago
class-jetpack-gallery-settings.php
8 months ago
class-jetpack-newsletter-dashboard-widget.php
8 months ago
class-jetpack-pre-connection-jitms.php
2 years ago
class-jetpack-stats-dashboard-widget.php
4 months ago
class-jetpack-xmlrpc-methods.php
1 month ago
class.frame-nonce-preview.php
8 months ago
class.jetpack-admin.php
1 month ago
class.jetpack-autoupdate.php
8 months ago
class.jetpack-cli.php
1 month ago
class.jetpack-client-server.php
2 years ago
class.jetpack-gutenberg.php
3 weeks ago
class.jetpack-heartbeat.php
1 week ago
class.jetpack-modules-list-table.php
8 months ago
class.jetpack-network-sites-list-table.php
1 month ago
class.jetpack-network.php
1 month ago
class.jetpack-plan.php
3 years ago
class.jetpack-post-images.php
4 months ago
class.jetpack-twitter-cards.php
5 months ago
class.jetpack-user-agent.php
1 month ago
class.jetpack.php
1 day ago
class.json-api-endpoints.php
1 week ago
class.json-api.php
3 weeks ago
class.photon.php
3 years ago
composer.json
1 day ago
enhanced-open-graph.php
2 months ago
functions.compat.php
5 months ago
functions.cookies.php
2 years ago
functions.global.php
1 month ago
functions.is-mobile.php
2 years ago
functions.opengraph.php
4 months ago
functions.photon.php
2 years ago
jetpack.php
1 day ago
json-api-config.php
3 years ago
json-endpoints.php
2 years ago
load-jetpack.php
1 month ago
locales.php
8 months ago
readme.txt
1 day ago
unauth-file-upload.php
4 weeks ago
uninstall.php
1 month ago
wpml-config.xml
4 years ago
class.jetpack-heartbeat.php
100 lines
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | /** |
| 3 | * Jetpack Heartbeat. |
| 4 | * |
| 5 | * @package automattic/jetpack |
| 6 | */ |
| 7 | |
| 8 | use Automattic\Jetpack\Heartbeat; |
| 9 | |
| 10 | /** |
| 11 | * Jetpack Heartbeat. |
| 12 | */ |
| 13 | class Jetpack_Heartbeat { |
| 14 | |
| 15 | /** |
| 16 | * Holds the singleton instance of this class |
| 17 | * |
| 18 | * @since 2.3.3 |
| 19 | * @var Jetpack_Heartbeat |
| 20 | */ |
| 21 | private static $instance = false; |
| 22 | |
| 23 | /** |
| 24 | * Holds the singleton instance of the proxied class |
| 25 | * |
| 26 | * @since 8.9.0 |
| 27 | * @var Automattic\Jetpack\Heartbeat |
| 28 | */ |
| 29 | private static $proxied_instance = false; |
| 30 | |
| 31 | /** |
| 32 | * Singleton |
| 33 | * |
| 34 | * @since 2.3.3 |
| 35 | * @static |
| 36 | * @return Jetpack_Heartbeat |
| 37 | */ |
| 38 | public static function init() { |
| 39 | if ( ! self::$instance ) { |
| 40 | self::$instance = new Jetpack_Heartbeat(); |
| 41 | self::$proxied_instance = Heartbeat::init(); |
| 42 | } |
| 43 | |
| 44 | return self::$instance; |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * Constructor for singleton |
| 49 | * |
| 50 | * @since 2.3.3 |
| 51 | */ |
| 52 | private function __construct() { |
| 53 | add_filter( 'jetpack_heartbeat_stats_array', array( $this, 'add_stats_to_heartbeat' ) ); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * Generates Jetpack plugin heartbeat stats data. |
| 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 | * |
| 63 | * @param string $prefix Prefix to add before stats identifier. |
| 64 | * |
| 65 | * @return array The stats array. |
| 66 | */ |
| 67 | public static function generate_stats_array( $prefix = '' ) { |
| 68 | $return = array(); |
| 69 | |
| 70 | $return[ "{$prefix}version" ] = JETPACK__VERSION; |
| 71 | $return[ "{$prefix}branch" ] = (float) JETPACK__VERSION; |
| 72 | $return[ "{$prefix}manage-enabled" ] = true; |
| 73 | |
| 74 | foreach ( Jetpack::get_available_modules() as $slug ) { |
| 75 | $return[ "{$prefix}module-{$slug}" ] = Jetpack::is_module_active( $slug ) ? 'on' : 'off'; |
| 76 | } |
| 77 | |
| 78 | return $return; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * Add Jetpack Stats array to Heartbeat if Jetpack is connected |
| 83 | * |
| 84 | * @since 8.9.0 |
| 85 | * |
| 86 | * @param array $stats Jetpack Heartbeat stats. |
| 87 | * @return array $stats |
| 88 | */ |
| 89 | public function add_stats_to_heartbeat( $stats ) { |
| 90 | |
| 91 | if ( ! Jetpack::is_connection_ready() ) { |
| 92 | return $stats; |
| 93 | } |
| 94 | |
| 95 | $jetpack_stats = self::generate_stats_array(); |
| 96 | |
| 97 | return array_merge( $stats, $jetpack_stats ); |
| 98 | } |
| 99 | } |
| 100 |