Form_Query::map_args( array $args )

Maps form query arguments to regular post query arguments.

Description

See also

Parameters

$args

(array) (Required) Arguments as $query_var => $value pairs.

Return

(array) Mapped arguments.

Source

File: src/db-objects/forms/form-query.php

	protected function map_args( $args ) {
		if ( is_array( $args['orderby'] ) && ! empty( $args['orderby'] ) ) {
			$args['order'] = array_values( $args['orderby'] )[0];
			$args['orderby'] = array_keys( $args['orderby'] )[0];
		}

		$mapped_args = $args;
		foreach ( $args as $query_var => $value ) {
			switch ( $query_var ) {
				case 'search':
					$mapped_args['s'] = $value;
					unset( $mapped_args['search'] );
					break;
				case 'slug':
					$mapped_args['name'] = $value;
					unset( $mapped_args['slug'] );
					break;
				case 'timestamp':
					unset( $mapped_args['timestamp'] );
					break;
				case 'timestamp_modified':
					unset( $mapped_args['timestamp_modified'] );
					break;
				case 'orderby':
					if ( 'slug' === $value ) {
						$mapped_args[ $query_var ] = 'name';
					} elseif ( 'timestamp' === $value ) {
						$mapped_args[ $query_var ] = 'date';
					} elseif ( 'timestamp_modified' === $value ) {
						$mapped_args[ $query_var ] = 'modified';
					}
					break;
				case 'status':
					$mapped_args[ 'post_' . $query_var ] = $value;
			}
		}

		$mapped_args['post_type'] = $this->manager->get_prefix() . 'form';

		return $mapped_args;
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.