Tribe_Events::remove_request_based_context_locations( array $locations, Tribe__Context $context )
Should not be used carelessly this will remove all request based locations from the read of the context.
Contents
Which if not used properly will break all other uses of the context unless it’s a shortcode.
Parameters
- $locations
-
(array) (Required) An array of read and write location in the shape of the
Context::$locationsone,[ <location> => [ 'read' => <read_locations>, 'write' => <write_locations> ] ]. - $context
-
(Tribe__Context) (Required) Instance of the context.
Return
(array) Locations after removing the request based ones.
Source
File: src/Tribe/Views/V2/Shortcodes/Tribe_Events.php
public function remove_request_based_context_locations( array $locations, Context $context ) {
foreach ( $locations as $key => $location ) {
// no read locations we bail.
if ( empty( $location['read'] ) ) {
continue;
}
// Check if this location has a read for
if ( ! empty( $location['read'][ Context::REQUEST_VAR ] ) ) {
unset( $locations[ $key ]['read'][ Context::REQUEST_VAR ] );
}
if ( ! empty( $location['read'][ Context::QUERY_VAR ] ) ) {
unset( $locations[ $key ]['read'][ Context::QUERY_VAR ] );
}
if ( ! empty( $location['read'][ Context::WP_MATCHED_QUERY ] ) ) {
unset( $locations[ $key ]['read'][ Context::WP_MATCHED_QUERY ] );
}
if ( ! empty( $location['read'][ Context::WP_PARSED ] ) ) {
unset( $locations[ $key ]['read'][ Context::WP_PARSED ] );
}
}
return $locations;
}
Changelog
| Version | Description |
|---|---|
| 5.5.0 | Introduced. |