PluginProbe
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More / 2.6.2
Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More v2.6.2
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.10 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 47 releases
content-control / classes / Controllers / Compatibility / TheEventsCalendar.php

TheEventsCalendar.php in Content Control – The Ultimate Content Restriction Plugin! Restrict Content, Create Conditional Blocks & More 2.6.2, at classes/Controllers/Compatibility/TheEventsCalendar.php

52 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The Events Calendar
4 *
5 * @package ContentControl
6 */
7
8 namespace ContentControl\Controllers\Compatibility;
9
10 use ContentControl\Base\Controller;
11
12 /**
13 * TheEventsCalendar controller class.
14 */
15 class TheEventsCalendar extends Controller {
16
17 /**
18 * Initiate hooks & filter.
19 *
20 * @return void
21 */
22 public function init() {
23 // 'wp_redirect'
24 add_action( 'content_control/restrict_main_query', [ $this, 'restrict_main_query' ], 10 );
25 }
26
27 /**
28 * Check if controller is enabled.
29 *
30 * @return bool
31 */
32 public function controller_enabled() {
33 return class_exists( '\Tribe__Events__Main' ) && defined( 'TRIBE_EVENTS_FILE' );
34 }
35
36 /**
37 * Handle restrictions on the main query.
38 *
39 * When the main query is set to be redirected, TEC was cancelling the redirect. Returing true will allow the redirect to happen.
40 *
41 * @return void
42 */
43 public function restrict_main_query() {
44 // If during the main query, a redirect is called on the events page, we need to allow it to happen.
45 add_filter( 'wp_redirect', function ( $location ) {
46 // Only call this filter within the redirect filter. Limiting the scope of the filter.
47 add_filter( 'tec_events_views_v2_redirected', '__return_true' );
48 return $location;
49 }, 0 );
50 }
51 }
52