a xmlrpc method * * @param array $methods The list of methods to be filtered. * @return array $methods */ public static function jetpack_xmlrpc_methods( $methods ) { $methods['jetpack.getHeartbeatData'] = array( __CLASS__, 'xmlrpc_data_response' ); return $methods; } /** * Handles the response for the jetpack.getHeartbeatData xmlrpc method * * @param array $params The parameters received in the request. * @return array $params all the stats that heartbeat handles. */ public static function xmlrpc_data_response( $params = array() ) { // The WordPress XML-RPC server sets a default param of array() // if no argument is passed on the request and the method handlers get this array in $params. // generate_stats_array() needs a string as first argument. $params = empty( $params ) ? '' : $params; return self::generate_stats_array( $params ); } /** * Clear scheduled events * * @return void */ public function deactivate() { // Deal with the old pre-3.0 weekly one. $timestamp = wp_next_scheduled( 'jetpack_heartbeat' ); if ( $timestamp ) { wp_unschedule_event( $timestamp, 'jetpack_heartbeat' ); } $timestamp = wp_next_scheduled( $this->cron_name ); wp_unschedule_event( $timestamp, $this->cron_name ); } /** * Interact with the Heartbeat * * ## OPTIONS * * inspect (default): Gets the list of data that is going to be sent in the heartbeat and the date/time of the last heartbeat * * @param array $args Arguments passed via CLI. * * @return void */ public function cli_callback( $args ) { $allowed_args = array( 'inspect', ); if ( isset( $args[0] ) && ! in_array( $args[0], $allowed_args, true ) ) { /* translators: %s is a command like "prompt" */ WP_CLI::error( sprintf( __( '%s is not a valid command.', 'jetpack-connection' ), $args[0] ) ); } $stats = self::generate_stats_array(); $formatted_stats = array(); foreach ( $stats as $stat_name => $bin ) { $formatted_stats[] = array( 'Stat name' => $stat_name, 'Bin' => $bin, ); } WP_CLI\Utils\format_items( 'table', $formatted_stats, array( 'Stat name', 'Bin' ) ); $last_heartbeat = Jetpack_Options::get_option( 'last_heartbeat' ); if ( $last_heartbeat ) { $last_date = gmdate( 'Y-m-d H:i:s', $last_heartbeat ); /* translators: %s is the full datetime of the last heart beat e.g. 2020-01-01 12:21:23 */ WP_CLI::line( sprintf( __( 'Last heartbeat sent at: %s', 'jetpack-connection' ), $last_date ) ); } } /** * Initialize the heartbeat REST API. * * @return void */ public function initialize_rest_api() { register_rest_route( 'jetpack/v4', '/heartbeat/data', array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'rest_heartbeat_data' ), 'permission_callback' => array( $this, 'rest_heartbeat_data_permission_check' ), 'args' => array( 'prefix' => array( 'description' => __( 'Prefix to add before the stats identifiers.', 'jetpack-connection' ), 'type' => 'string', ), ), ) ); } /** * Endpoint to retrieve the heartbeat data. * * @param WP_REST_Request $request The request data. * * @since 2.7.0 * * @return array */ public function rest_heartbeat_data( WP_REST_Request $request ) { return static::generate_stats_array( $request->get_param( 'prefix' ) ); } /** * Check permissions for the `get_heartbeat_data` endpoint. * * @return true|WP_Error */ public function rest_heartbeat_data_permission_check() { if ( current_user_can( 'jetpack_connect' ) ) { return true; } return Rest_Authentication::is_signed_with_blog_token() ? true : new WP_Error( 'invalid_permission_heartbeat_data', REST_Connector::get_user_permissions_error_msg(), array( 'status' => rest_authorization_required_code() ) ); } }
Fatal error: Uncaught Error: Class "Automattic\Jetpack\Heartbeat" not found in /htdocs/wp-content/plugins/jetpack/class.jetpack-heartbeat.php:42 Stack trace: #0 /htdocs/wp-content/plugins/jetpack/class.jetpack.php(831): Jetpack_Heartbeat::init() #1 /htdocs/wp-includes/class-wp-hook.php(324): Jetpack->configure('') #2 /htdocs/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters('', Array) #3 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #4 /htdocs/wp-settings.php(559): do_action('plugins_loaded') #5 /htdocs/wp-config.php(97): require_once('/htdocs/wp-sett...') #6 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #7 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #8 /htdocs/index.php(17): require('/htdocs/wp-blog...') #9 {main} thrown in /htdocs/wp-content/plugins/jetpack/class.jetpack-heartbeat.php on line 42