*/ protected function input_properties(): array { return array( 'panel' => array( 'type' => 'string', 'enum' => Status_Repository::PANELS, 'default' => 'status', 'description' => __( 'Which panel to read. "tools" returns the live maintenance-tool catalogue; "google" returns Search Console / GA4 connection state.', 'acrossai-abilities-manager' ), ), 'include_sites' => array( 'type' => 'boolean', 'default' => false, 'description' => __( 'Only for panel=google. When true, also list the Search Console properties. This makes a live Google API request, so it is off by default.', 'acrossai-abilities-manager' ), ), ); } /** * @return array */ protected function output_properties(): array { return array( 'panel' => array( 'type' => 'string' ), 'data' => array( 'type' => 'object' ), ); } /** * @return string[] */ protected function required_input(): array { return array(); } /** * @return array{readonly:bool,destructive:bool,idempotent:bool} */ protected function annotations(): array { return array( 'readonly' => true, 'destructive' => false, 'idempotent' => true ); } /** * @param array $input * @return array|WP_Error */ protected function run( array $input ) { $panel = isset( $input['panel'] ) ? sanitize_key( (string) $input['panel'] ) : 'status'; if ( ! in_array( $panel, Status_Repository::PANELS, true ) ) { return new WP_Error( 'invalid_input', sprintf( /* translators: 1: submitted panel name, 2: comma-separated list of valid panels */ __( 'Unknown panel "%1$s". Valid panels: %2$s.', 'acrossai-abilities-manager' ), $panel, implode( ', ', Status_Repository::PANELS ) ) ); } $data = Status_Repository::panel( $panel, ! empty( $input['include_sites'] ) ); if ( is_wp_error( $data ) ) { return $data; } return array( 'panel' => $panel, 'data' => $data, /* translators: %s: panel name */ 'message' => sprintf( __( 'Returned the Rank Math "%s" panel.', 'acrossai-abilities-manager' ), $panel ), ); } }