Tribe__Events__Main::setup_date_search_in_bar( array $filters )

Set up the date search in the tribe events bar.


Parameters

$filters

(array) (Required) The current filters in the bar array.


Top ↑

Return

(array) The modified filters array.


Top ↑

Source

File: src/Tribe/Main.php

		public function setup_date_search_in_bar( $filters ) {

			$formats_full = array(
				'0'  => __( '4 digit year hyphen 2 digit month hyphen 2 digit day', 'the-events-calendar' ),
				'1'  => __( '1 digit month slash 1 digit day slash 4 digit year', 'the-events-calendar' ),
				'2'  => __( '2 digit month slash 2 digit day slash 4 digit year', 'the-events-calendar' ),
				'3'  => __( '1 digit day slash 1 digit month slash 4 digit year', 'the-events-calendar' ),
				'4'  => __( '2 digit day slash 2 digit month slash 4 digit year', 'the-events-calendar' ),
				'5'  => __( '1 digit month hyphen 1 digit day hyphen 4 digit year', 'the-events-calendar' ),
				'6'  => __( '1 digit month hyphen 2 digit day hyphen 4 digit year', 'the-events-calendar' ),
				'7'  => __( '1 digit day hyphen 1 digit month hyphen 4 digit year', 'the-events-calendar' ),
				'8'  => __( '2 digit day hyphen 2 digit month hyphen 4 digit year', 'the-events-calendar' ),
				'9'  => __( '4 digit year dot 2 digit month dot 2 digit day', 'the-events-calendar' ),
				'10' => __( '2 digit month dot 2 digit day dot 4 digit year', 'the-events-calendar' ),
				'11' => __( '2 digit day dot 2 digit month dot 4 digit year', 'the-events-calendar' ),
			);

			$formats_month = array(
				'0'  => __( '4 digit year hyphen 2 digit month', 'the-events-calendar' ),
				'1'  => __( '1 digit month slash 4 digit year', 'the-events-calendar' ),
				'2'  => __( '2 digit month slash 4 digit year', 'the-events-calendar' ),
				'3'  => __( '1 digit month slash 4 digit year', 'the-events-calendar' ),
				'4'  => __( '2 digit month slash 4 digit year', 'the-events-calendar' ),
				'5'  => __( '1 digit month hyphen 4 digit year', 'the-events-calendar' ),
				'6'  => __( '1 digit month hyphen 4 digit year', 'the-events-calendar' ),
				'7'  => __( '1 digit month hyphen 4 digit year', 'the-events-calendar' ),
				'8'  => __( '2 digit month hyphen 4 digit year', 'the-events-calendar' ),
				'9'  => __( '4 digit year dot 2 digit month', 'the-events-calendar' ),
				'10' => __( '2 digit month dot 4 digit year', 'the-events-calendar' ),
				'11' => __( '2 digit month dot 4 digit year', 'the-events-calendar' ),
			);

			if ( ! $wp_query = tribe_get_global_query_object() ) {
				return;
			}

			/**
			 * Allows for customizing the "date search" field value.
			 *
			 * @deprecated 4.6.1 Use tribe_events_bar_date_search_default_value instead.
			 *
			 * @param string $value The "date search" field value, which defaults to an empty string.
			 */
			$value = apply_filters( 'tribe-events-bar-date-search-default-value', '' );

			/**
			 * Allows for customizing the "date search" field value.
			 *
			 * @param string $value The "date search" field value, which defaults to an empty string.
			 */
			$value = apply_filters( 'tribe_events_bar_date_search_default_value', $value );

			if ( ! empty( $_REQUEST['tribe-bar-date'] ) ) {
				$value = $_REQUEST['tribe-bar-date'];
			}

			$datepicker_format = tribe_get_option( 'datepickerFormat' );

			$caption = esc_html__( 'Date', 'the-events-calendar' );
			$format  = Tribe__Utils__Array::get( $formats_full, $datepicker_format, $formats_full[0] );
			$label   = sprintf( esc_html__( 'Search for %s by Date. Please use the format %s.', 'the-events-calendar' ), $this->plural_event_label, $format );

			if ( tribe_is_month() ) {
				$caption = sprintf( esc_html__( '%s In', 'the-events-calendar' ), $this->plural_event_label );
				$format  = Tribe__Utils__Array::get( $formats_month, $datepicker_format, $formats_month[0] );
				$label   = sprintf( esc_html__( 'Search for %s by month. Please use the format %s.', 'the-events-calendar' ), $this->plural_event_label, $format );
			} elseif ( tribe_is_list_view() ) {
				$caption = sprintf( esc_html__( '%s From', 'the-events-calendar' ), $this->plural_event_label );
			} elseif ( tribe_is_day() ) {
				$caption = esc_html__( 'Day Of', 'the-events-calendar' );
				$value   = date( Tribe__Date_Utils::DBDATEFORMAT, strtotime( $wp_query->query_vars['eventDate'] ) );
			}

			/**
			 * Allows for modifying the "date search" field's caption (e.g. "in" or "from").
			 *
			 * @param string $caption The "date search" field's caption string.
			 */
			$caption = apply_filters( 'tribe_bar_datepicker_caption', $caption );

			$filters['tribe-bar-date'] = array(
				'name'    => 'tribe-bar-date',
				'caption' => $caption,
				'html'    => '<input type="text" name="tribe-bar-date" style="position: relative;" id="tribe-bar-date" aria-label="' . esc_attr( $label ) . '" value="' . esc_attr( $value ) . '" placeholder="' . esc_attr__( 'Date', 'the-events-calendar' ) . '"><input type="hidden" name="tribe-bar-date-day" id="tribe-bar-date-day" class="tribe-no-param" value="">',
			);

			return $filters;
		}