is_wpcom_simple() || ( new Manager( 'jetpack' ) )->is_connected(); } /** * Whether Stats has to register its own dashboard because nothing else will. * * The Jetpack plugin registers the Stats menu from its stats module, and modules are not * loaded until the site is connected. Registering the dashboard here keeps Stats reachable * before that happens, where the app offers a plan and drives the connection itself. * * @return bool */ private static function needs_own_dashboard() { return ! self::is_site_connected(); } /** * Register the stats-admin transient prefix for cleanup. * * @param array $prefixes List of transient prefixes to clean up. * @return array Modified list of prefixes. */ public function register_transient_cleanup_prefix( $prefixes ) { $prefixes[] = WPCOM_Client::CACHE_TRANSIENT_PREFIX; return $prefixes; } /** * Update New Stats status. * * @param bool $status true to enable or false to disable. * @return bool */ public static function update_new_stats_status( $status ) { $status = (bool) $status; $stats_options = array( 'enable_odyssey_stats' => $status, 'odyssey_stats_changed_at' => time(), ); $updated = Stats_Options::set_options( $stats_options ); // Track the event. $event_name = 'calypso_stats_disabled'; if ( $status ) { $event_name = 'calypso_stats_enabled'; } $connection_manager = new Manager( 'jetpack' ); $tracking = new Tracking( 'jetpack', $connection_manager ); $tracking->record_user_event( $event_name, array_merge( $stats_options, array( 'updated' => $updated ) ) ); return $updated; } }