health = $health; $this->sites = $sites; } /** * Admin notice for managers while any connection is failing. * * Shown on the WordPress Dashboard, the Plugins screen and TurtleReport * screens, so it is seen without nagging on every page. * * @return void */ public function render() { if ( ! current_user_can( Capabilities::MANAGE ) ) { return; } $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; $id = $screen ? (string) $screen->id : ''; if ( ! in_array( $id, array( 'dashboard', 'plugins' ), true ) && false === strpos( $id, 'turtlereport' ) ) { return; } $failing = $this->health->failing(); if ( ! $failing ) { return; } $ids = array(); foreach ( $failing as $connection ) { $ids = array_merge( $ids, array_keys( $this->sites->using_connection( $connection->id ) ) ); } $sites = count( array_unique( $ids ) ); $message = sprintf( /* translators: %d: number of Google connections. */ _n( '%d Google connection isn\'t working.', '%d Google connections aren\'t working.', count( $failing ), 'turtlereport' ), count( $failing ) ); if ( $sites ) { $message .= ' ' . sprintf( /* translators: %d: number of sites. */ _n( 'Reports for %d site can\'t load.', 'Reports for %d sites can\'t load.', $sites, 'turtlereport' ), $sites ); } printf( '
%1$s %2$s %4$s