/** * Singleton * * @since 2.3.3 * @static * @return Jetpack_Heartbeat */ public static function init() { if (!self::$instance) { self::$instance = new Jetpack_Heartbeat(); } return self::$instance; }
public function test_sends_stats_data_on_heartbeat_on_multisite() { global $wpdb; if (!is_multisite()) { $this->markTestSkipped('Run it in multi site mode'); } $user_id = $this->factory->user->create(); $mu_blog_user_id = $this->factory->user->create(); // create a different blog $suppress = $wpdb->suppress_errors(); $other_blog_id = wpmu_create_blog('foo.com', '', "My Blog", $user_id); $wpdb->suppress_errors($suppress); // create a user from within that blog (won't be synced) switch_to_blog($other_blog_id); add_user_to_blog($other_blog_id, $mu_blog_user_id, 'administrator'); $heartbeat = Jetpack_Heartbeat::init(); $heartbeat->cron_exec(); $this->sender->do_sync(); $action = $this->server_event_storage->get_most_recent_event('jetpack_sync_heartbeat_stats'); restore_current_blog(); $this->assertEquals(JETPACK__VERSION, $action->args[0]['version']); $this->assertFalse(isset($action->args[0]['users'])); }
/** * Disconnects from the Jetpack servers. * Forgets all connection details and tells the Jetpack servers to do the same. * @static */ public static function disconnect($update_activated_state = true) { wp_clear_scheduled_hook('jetpack_clean_nonces'); Jetpack::clean_nonces(true); Jetpack::load_xml_rpc_client(); $xml = new Jetpack_IXR_Client(); $xml->query('jetpack.deregister'); Jetpack_Options::delete_option(array('register', 'blog_token', 'user_token', 'user_tokens', 'master_user', 'time_diff', 'fallback_no_verify_ssl_certs')); if ($update_activated_state) { Jetpack_Options::update_option('activated', 4); } // Disable the Heartbeat cron Jetpack_Heartbeat::init()->deactivate(); }
/** * @covers Jetpack_Heartbeat::jetpack_xmlrpc_methods * @since 3.9.0 */ public function test_jetpack_xmlrpc_methods() { $this->assertNotEmpty(Jetpack_Heartbeat::jetpack_xmlrpc_methods(array())); }
/** * Removes all connection options * @static */ public static function plugin_deactivation() { Jetpack::disconnect(false); Jetpack_Heartbeat::init()->deactivate(); }
public static function jetpack_check_heartbeat_data() { $raw_data = Jetpack_Heartbeat::generate_stats_array(); $good = array(); $caution = array(); $bad = array(); foreach ($raw_data as $stat => $value) { // Check jetpack version if ('version' == $stat) { if (version_compare($value, JETPACK__VERSION, '<')) { $caution[$stat] = $value . " - min supported is " . JETPACK__VERSION; continue; } } // Check WP version if ('wp-version' == $stat) { if (version_compare($value, JETPACK__MINIMUM_WP_VERSION, '<')) { $caution[$stat] = $value . " - min supported is " . JETPACK__MINIMUM_WP_VERSION; continue; } } // Check PHP version if ('php-version' == $stat) { if (version_compare(PHP_VERSION, '5.2.4', '<')) { $caution[$stat] = $value . " - min supported is 5.2.4"; continue; } } // Check ID crisis if ('identitycrisis' == $stat) { if ('yes' == $value) { $bad[$stat] = $value; continue; } } // The rest are good :) $good[$stat] = $value; } $filtered_data = array('good' => $good, 'caution' => $caution, 'bad' => $bad); return $filtered_data; }