> id, status, message, action, dismissible. */ public static function for_plugin_pages( Connection $connection ): array { $notices = array(); $settings = Settings::all(); $check = Installation_Check::last(); // Stand ends a session at its longest lifetime however much it's used. $ends = (int) strtotime( (string) ( Connection::stored_metadata()['expires_at'] ?? '' ) ); if ( $connection->is_usable() && $ends > 0 && $ends < time() + 7 * DAY_IN_SECONDS && ! State::is_dismissed( 'connection_ends' ) ) { $notices[] = array( 'id' => 'connection_ends', 'status' => 'warning', 'message' => sprintf( /* translators: %s: date */ __( 'Stand ends this connection on %s. Reconnect before then to keep managing your AI assistant here. The chat on your site keeps working either way.', 'stand-chat' ), wp_date( (string) get_option( 'date_format' ), $ends ) ), 'action' => array( 'label' => __( 'Reconnect', 'stand-chat' ), 'kind' => 'settings_connection', ), 'dismissible' => true, ); } if ( $connection->is_connected() && Environment::is_production() && Environment::domain_mismatch() && 'copy' !== State::get( 'address_decision' ) && ! State::is_dismissed( 'address' ) ) { $notices[] = array( 'id' => 'address', 'status' => 'warning', 'message' => sprintf( /* translators: 1: new WordPress domain, 2: Stand Site domain */ __( 'Your site address changed to %1$s. Stand is connected to %2$s, so chat is hidden here.', 'stand-chat' ), Environment::home_domain(), Environment::site_domain() ), 'action' => array( 'label' => __( 'Review', 'stand-chat' ), 'kind' => 'address', ), 'dismissible' => true, ); } if ( $check && 'duplicate' === ( $check['status'] ?? '' ) && ! State::is_dismissed( 'duplicate' ) ) { $notices[] = array( 'id' => 'duplicate', 'status' => 'warning', 'message' => __( 'Another Stand script is on your site, for example in your theme\'s header or a header-code plugin. Remove it so the chat loads once.', 'stand-chat' ), 'action' => array( 'label' => __( 'Check again', 'stand-chat' ), 'kind' => 'check', ), 'dismissible' => true, ); } if ( 'consent' === $settings['consent']['mode'] && ! function_exists( 'wp_has_consent' ) && ! State::is_dismissed( 'consent_api' ) ) { $notices[] = array( 'id' => 'consent_api', 'status' => 'warning', 'message' => __( 'Chat waits for cookie consent, but the WP Consent API plugin isn\'t active, so chat won\'t load. Install WP Consent API, or set Load chat to Immediately.', 'stand-chat' ), 'action' => array( 'label' => __( 'Privacy and consent', 'stand-chat' ), 'kind' => 'settings_privacy', ), 'dismissible' => true, ); } if ( Environment::is_subdirectory_subsite() && ! State::is_dismissed( 'subdirectory' ) ) { $notices[] = array( 'id' => 'subdirectory', 'status' => 'info', 'message' => __( 'This site shares its domain with other sites in your network. Sites connected to the same Stand Site share its AI assistants, Who answers and the pages AI assistants read, which count toward one page limit. Visitors\' chats can continue across those sites, because the chat remembers conversations per domain.', 'stand-chat' ), 'action' => null, 'dismissible' => true, ); } $nobody_since = (int) State::get( 'nobody_since', 0 ); if ( $nobody_since > 0 && $nobody_since < time() - 7 * DAY_IN_SECONDS && ! State::is_dismissed( 'nobody' ) ) { $notices[] = array( 'id' => 'nobody', 'status' => 'warning', 'message' => __( 'No one has answered on this site for a week. Who answers is set to Only you, and you haven\'t been Available in the Stand app.', 'stand-chat' ), 'action' => array( 'label' => __( 'Change who answers', 'stand-chat' ), 'kind' => 'who_answers', ), 'dismissible' => true, ); } return $notices; } /** * Notices shown once on other admin pages. * * @param Connection $connection Connection. * @return array> id, status, message, link label, link. */ public static function admin_wide( Connection $connection ): array { $out = array(); $check = Installation_Check::last(); $overview = admin_url( 'admin.php?page=stand-chat' ); if ( $connection->needs_reconnect() ) { $out[] = array( 'id' => 'admin_reconnect', 'status' => 'error', 'message' => __( 'Stand Chat: reconnect needed. The chat on your site keeps working, but you can\'t manage your AI assistant from WordPress.', 'stand-chat' ), 'label' => __( 'Reconnect', 'stand-chat' ), 'link' => $overview, ); } if ( $connection->is_connected() && Environment::is_production() && Environment::domain_mismatch() && 'copy' !== State::get( 'address_decision' ) ) { $out[] = array( 'id' => 'admin_address', 'status' => 'warning', 'message' => sprintf( /* translators: 1: new domain, 2: Stand Site domain */ __( 'Stand Chat: your site address changed to %1$s. Stand is connected to %2$s, so chat is hidden here.', 'stand-chat' ), Environment::home_domain(), Environment::site_domain() ), 'label' => __( 'Review', 'stand-chat' ), 'link' => $overview, ); } if ( $check && 'duplicate' === ( $check['status'] ?? '' ) ) { $out[] = array( 'id' => 'admin_duplicate', 'status' => 'warning', 'message' => __( 'Stand Chat: another Stand script is on your site. Remove it so the chat loads once.', 'stand-chat' ), 'label' => __( 'Review', 'stand-chat' ), 'link' => $overview, ); } return array_values( array_filter( $out, static function ( $notice ) { return ! State::is_dismissed( $notice['id'] ); } ) ); } }