array( 'type' => 'object', 'description' => __( 'Payload from rank-math/export-settings. Keys are panel names.', 'acrossai-abilities-manager' ), 'additionalProperties' => true, ), ); } protected function output_properties(): array { return array( 'panels_imported' => array( 'type' => 'array' ), 'backup_key' => array( 'type' => 'string' ), ); } /** * 'confirm' is intentionally absent — see Base_Rank_Math_Ability::ability(). */ protected function required_input(): array { return array( 'data' ); } protected function annotations(): array { return array( 'readonly' => false, 'destructive' => true, 'idempotent' => false ); } /** * @param array $input * @return array|WP_Error */ protected function run( array $input ) { if ( ! isset( $input['data'] ) || ! is_array( $input['data'] ) ) { return new WP_Error( 'invalid_input', __( 'data must be an object of settings panels.', 'acrossai-abilities-manager' ) ); } $result = Status_Tools_Repository::import_settings( $input['data'] ); if ( is_wp_error( $result ) ) { return $result; } $result['message'] = '' !== $result['backup_key'] ? sprintf( /* translators: 1: comma-separated panel names, 2: backup key */ __( 'Imported settings for %1$s. A backup was created first with key "%2$s" — restore it with rank-math/manage-backup to undo.', 'acrossai-abilities-manager' ), implode( ', ', $result['panels_imported'] ), $result['backup_key'] ) : sprintf( /* translators: %s: comma-separated panel names */ __( 'Imported settings for %s. No backup key was reported, so this change may not be undoable.', 'acrossai-abilities-manager' ), implode( ', ', $result['panels_imported'] ) ); return $result; } }