array( 'type' => 'string', 'enum' => Maintenance_Tools::tool_ids(), 'description' => __( 'Which tool to run. delete_redirections and delete_log remove ALL rows in those tables, not a selection.', 'acrossai-abilities-manager' ), ), ); } protected function output_properties(): array { return array( 'tool' => array( 'type' => 'string' ), 'completed' => array( 'type' => 'boolean' ), 'async' => array( 'type' => 'boolean' ), 'tool_message' => array( 'type' => 'string' ), 'poll_hint' => array( 'type' => 'string' ), ); } /** * 'confirm' is intentionally absent — see Base_Rank_Math_Ability::ability(). */ protected function required_input(): array { return array( 'tool' ); } protected function annotations(): array { return array( 'readonly' => false, 'destructive' => true, 'idempotent' => false ); } /** * @param array $input * @return array|WP_Error */ protected function run( array $input ) { $tool = isset( $input['tool'] ) ? sanitize_key( (string) $input['tool'] ) : ''; $result = Maintenance_Tools::dispatch( $tool ); if ( is_wp_error( $result ) ) { return $result; } if ( $result['async'] ) { $result['message'] = sprintf( /* translators: %s: tool id */ __( 'Started the "%s" tool. Work continues in the background, so the change may not be visible yet.', 'acrossai-abilities-manager' ), $tool ); } elseif ( $result['completed'] ) { $result['message'] = '' !== $result['tool_message'] ? sprintf( /* translators: 1: tool id, 2: message returned by Rank Math */ __( 'Ran the "%1$s" tool: %2$s', 'acrossai-abilities-manager' ), $tool, $result['tool_message'] ) : sprintf( /* translators: %s: tool id */ __( 'Ran the "%s" tool.', 'acrossai-abilities-manager' ), $tool ); } else { $result['message'] = sprintf( /* translators: 1: tool id, 2: message returned by Rank Math */ __( 'The "%1$s" tool reported a problem: %2$s', 'acrossai-abilities-manager' ), $tool, '' !== $result['tool_message'] ? $result['tool_message'] : __( 'no detail provided', 'acrossai-abilities-manager' ) ); } return $result; } }