Hooks::filter_context_locations( TribeEventsFilterbarViewsV2_1array $locations )
Filters the Context locations to add the ones required by the Filters.
Contents
Parameters
- $locations
-
(<span class="TribeEventsFilterbarViewsV2_1array">TribeEventsFilterbarViewsV2_1array) (Required) The current context locations.
Return
(TribeEventsFilterbarViewsV2_1array<string,mixed>) The filtered context locations.
Source
File: src/Tribe/Views/V2_1/Hooks.php
public function filter_context_locations( $locations ) { if ( ! is_array( $locations ) ) { return $locations; } // The state of the whole Filter Bar. If found then it will be one of `open` or `closed`. $locations['fbar_state'] = [ 'read' => [ Context::FUNC => [ static function () { $var = tribe_get_request_var( 'tribe_filter_bar_state', Context::NOT_FOUND ); if ( Context::NOT_FOUND === $var ) { return $var; } return tribe_is_truthy( $var ) ? 'open' : 'closed'; }, ], ], ]; // The state of each Filter Bar filter, an integer representing a bitmask. $locations['fbar_filters_state'] = [ 'read' => [ Context::REQUEST_VAR => [ 'tribe_filters_state' ], ], ]; // Add some extra locations to read the current and previous URL from. foreach ( [ 'view_url' => 'url', 'view_prev_url' => 'prev_url' ] as $location => $request_var ) { if ( isset( $locations[ $location ]['read'] ) ) { $prev = Arr::get( $locations[ $location ]['read'], Context::REQUEST_VAR, [] ); $locations[ $location ]['read'][ Context::REQUEST_VAR ] = array_merge( $prev, [ $request_var ] ); } } return $locations; }
Changelog
Version | Description |
---|---|
5.0.0 | Introduced. |