array( 'type' => 'string', 'enum' => array( 'restore', 'delete' ), 'description' => __( 'restore overwrites current settings; delete removes the backup.', 'acrossai-abilities-manager' ), ), 'key' => array( 'type' => 'string', 'description' => __( 'Backup key from rank-math/list-backups.', 'acrossai-abilities-manager' ), ), ); } protected function output_properties(): array { return array( 'action' => array( 'type' => 'string' ), 'key' => array( 'type' => 'string' ), 'remaining' => array( 'type' => 'integer' ), ); } /** * 'confirm' is intentionally absent — see Base_Rank_Math_Ability::ability(). */ protected function required_input(): array { return array( 'action', 'key' ); } protected function annotations(): array { return array( 'readonly' => false, 'destructive' => true, 'idempotent' => true ); } /** * @param array $input * @return array|WP_Error */ protected function run( array $input ) { $result = Status_Tools_Repository::manage_backup( isset( $input['action'] ) ? sanitize_key( (string) $input['action'] ) : '', isset( $input['key'] ) ? sanitize_text_field( (string) $input['key'] ) : '' ); if ( is_wp_error( $result ) ) { return $result; } $result['message'] = 'restore' === $result['action'] ? sprintf( /* translators: %s: backup key */ __( 'Restored Rank Math settings from backup "%s". All previous settings were overwritten.', 'acrossai-abilities-manager' ), $result['key'] ) : sprintf( /* translators: %s: backup key */ __( 'Deleted Rank Math settings backup "%s".', 'acrossai-abilities-manager' ), $result['key'] ); return $result; } }