*/ public static function site_status( $site_id ) { switch_to_blog( $site_id ); $connection = TokenStore::get_connection(); $status = array( 'id' => (int) $site_id, 'name' => get_bloginfo( 'name' ), 'url' => home_url(), 'domain' => Onboarding::site_domain(), 'subfolder' => Onboarding::is_in_subfolder(), 'plugin_active' => self::plugin_active_here(), 'connected' => null !== $connection, 'reconnect' => (bool) get_option( Onboarding::RECONNECT_OPTION ), 'installation' => null !== $connection ? (string) $connection['installation_id'] : '', 'activated' => (bool) State::get( 'activated' ), 'config_version' => (int) State::get( 'config_version' ), 'last_check_in' => (int) State::get( 'last_health_at' ), 'banner' => null !== CategoryMap::get(), 'admin_url' => admin_url( 'admin.php?page=' . Screens::SLUG ), ); restore_current_blog(); return $status; } /** * @return void */ public function render() { if ( ! current_user_can( 'manage_network_options' ) ) { wp_die( esc_html__( 'You do not have permission to view this page.', 'consiva-ai' ), '', array( 'response' => 403 ) ); } // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only pagination. $page = isset( $_GET['paged'] ) ? max( 1, absint( $_GET['paged'] ) ) : 1; $total = (int) get_sites( array( 'count' => true ) ); $ids = get_sites( array( 'fields' => 'ids', 'number' => self::PER_PAGE, 'offset' => ( $page - 1 ) * self::PER_PAGE, ) ); $rows = array_map( array( __CLASS__, 'site_status' ), $ids ); $connected = count( array_filter( wp_list_pluck( $rows, 'connected' ) ) ); ?> $row Site status. * @return string */ private static function connection_text( array $row ) { if ( ! $row['plugin_active'] ) { return __( 'Plugin not active on this site', 'consiva-ai' ); } if ( $row['subfolder'] ) { return __( 'Cannot connect: site is in a subfolder', 'consiva-ai' ); } if ( $row['reconnect'] ) { return __( 'Needs reconnecting', 'consiva-ai' ); } return $row['connected'] ? __( 'Connected', 'consiva-ai' ) : __( 'Not connected', 'consiva-ai' ); } /** * Whether the plugin runs on the current site (network-activated, or activated on this site). * * @return bool */ private static function plugin_active_here() { $basename = plugin_basename( CONSIVA_CONSENT_FILE ); $network = (array) get_site_option( 'active_sitewide_plugins', array() ); return isset( $network[ $basename ] ) || in_array( $basename, (array) get_option( 'active_plugins', array() ), true ); } }