isset( $_POST['actor_name'] ) ? sanitize_text_field( wp_unslash( $_POST['actor_name'] ) ) : '', 'type' => isset( $_POST['actor_type'] ) ? sanitize_text_field( wp_unslash( $_POST['actor_type'] ) ) : '', 'persona' => isset( $_POST['actor_persona'] ) ? sanitize_textarea_field( wp_unslash( $_POST['actor_persona'] ) ) : '', 'scope' => isset( $_POST['actor_scope'] ) ? sanitize_textarea_field( wp_unslash( $_POST['actor_scope'] ) ) : '', ]; $result = SA_Orch_Actor_Registry::create_actor( $data ); if ( is_wp_error( $result ) ) { $msg = 'error&msg=' . rawurlencode( $result->get_error_message() ); } else { $msg = 'created&id=' . (int) $result; } wp_safe_redirect( admin_url( 'admin.php?page=' . self::SUBMENU_SLUG . '¬ice=' . $msg ) ); exit; } if ( $action === 'archive' || $action === 'unarchive' ) { $id = isset( $_POST['actor_id'] ) ? (int) $_POST['actor_id'] : 0; if ( $id > 0 ) { if ( $action === 'archive' ) SA_Orch_Actor_Registry::archive_actor( $id ); if ( $action === 'unarchive' ) SA_Orch_Actor_Registry::unarchive_actor( $id ); } wp_safe_redirect( admin_url( 'admin.php?page=' . self::SUBMENU_SLUG . '¬ice=' . $action . 'd' ) ); exit; } } /** Single-page render with view dispatching. */ public static function render_page() { if ( ! current_user_can( SA_Orch_Admin::CAP ) ) { wp_die( __( 'Insufficient permissions.', 'sa-orchestration' ) ); } $view = isset( $_GET['view'] ) ? sanitize_text_field( wp_unslash( $_GET['view'] ) ) : 'list'; echo '
' . esc_html( $body ) . '
'; echo '+ Create Actor '; echo '' . ( $include_archived ? 'Hide archived' : 'Show archived' ) . ''; echo '
'; echo '| Name | Type | Owner | Status | Persona (excerpt) | Created | Actions | '; echo '
|---|---|---|---|---|---|---|
| No actors yet. Create the first one with intent. | ||||||
| ' . esc_html( $a['name'] ) . ' ' . esc_html( $a['login'] ) . ' | ';
echo '' . esc_html( $a['type'] ) . ' | '; echo '' . esc_html( $a['owner_login'] ?: '—' ) . ' | '; echo '' . $status_label . ' | '; // status_label is pre-built; safe echo '' . esc_html( $persona_excerpt ) . ( strlen( $a['persona'] ) > 80 ? '…' : '' ) . ' | '; echo '' . esc_html( $a['created_at'] ) . ' | '; echo ''; if ( $a['is_active'] ) { self::render_post_button( 'archive', $a['user_id'], 'Archive' ); } else { self::render_post_button( 'unarchive', $a['user_id'], 'Unarchive' ); } echo ' | '; echo '
Actor not found. Back to list
'; return; } echo '| Type | ' . esc_html( $a['type'] ) . ' |
|---|---|
| Status | ' . ( $a['is_active'] ? 'active' : 'archived' ) . ' |
| Owner | ' . esc_html( $a['owner_login'] ?: '—' ) . ' (user_id=' . (int) $a['owner_user_id'] . ') |
| Persona | ' . esc_html( $a['persona'] ) . ' |
| Scope | ' . esc_html( $a['scope'] ?: '—' ) . ' |
| Subscription tier | ' . esc_html( $a['subscription_tier'] ?: '— (reserved for future)' ) . ' |
| Created | ' . esc_html( $a['created_at'] ) . ' |