@@ -18,48 +18,48 @@ |
||
18 | 18 | class ActivationRequests extends PrimaryRoute |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * returns true if the current request matches this route |
|
23 | - * |
|
24 | - * @return bool |
|
25 | - * @since $VID:$ |
|
26 | - */ |
|
27 | - public function matchesCurrentRequest() |
|
28 | - { |
|
29 | - return $this->request->isActivation(); |
|
30 | - } |
|
21 | + /** |
|
22 | + * returns true if the current request matches this route |
|
23 | + * |
|
24 | + * @return bool |
|
25 | + * @since $VID:$ |
|
26 | + */ |
|
27 | + public function matchesCurrentRequest() |
|
28 | + { |
|
29 | + return $this->request->isActivation(); |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * @since $VID:$ |
|
35 | - */ |
|
36 | - protected function registerDependencies() |
|
37 | - { |
|
33 | + /** |
|
34 | + * @since $VID:$ |
|
35 | + */ |
|
36 | + protected function registerDependencies() |
|
37 | + { |
|
38 | 38 | |
39 | - $this->dependency_map->registerDependencies( |
|
40 | - 'EventEspresso\core\domain\entities\routing\handlers\admin\AdminRoute', |
|
41 | - ['EE_Admin_Config' => EE_Dependency_Map::load_from_cache] + Route::$default_dependencies |
|
42 | - ); |
|
43 | - $this->dependency_map->registerDependencies( |
|
44 | - 'EventEspresso\core\domain\entities\routing\handlers\admin\PueRequests', |
|
45 | - Route::$default_dependencies |
|
46 | - ); |
|
47 | - $this->dependency_map->registerDependencies( |
|
48 | - 'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage', |
|
49 | - Route::$default_dependencies |
|
50 | - ); |
|
51 | - } |
|
39 | + $this->dependency_map->registerDependencies( |
|
40 | + 'EventEspresso\core\domain\entities\routing\handlers\admin\AdminRoute', |
|
41 | + ['EE_Admin_Config' => EE_Dependency_Map::load_from_cache] + Route::$default_dependencies |
|
42 | + ); |
|
43 | + $this->dependency_map->registerDependencies( |
|
44 | + 'EventEspresso\core\domain\entities\routing\handlers\admin\PueRequests', |
|
45 | + Route::$default_dependencies |
|
46 | + ); |
|
47 | + $this->dependency_map->registerDependencies( |
|
48 | + 'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage', |
|
49 | + Route::$default_dependencies |
|
50 | + ); |
|
51 | + } |
|
52 | 52 | |
53 | 53 | |
54 | - /** |
|
55 | - * implements logic required to run during request |
|
56 | - * |
|
57 | - * @return bool |
|
58 | - * @since $VID:$ |
|
59 | - */ |
|
60 | - protected function requestHandler() |
|
61 | - { |
|
62 | - $this->setRouteRequestType(PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION); |
|
63 | - return true; |
|
64 | - } |
|
54 | + /** |
|
55 | + * implements logic required to run during request |
|
56 | + * |
|
57 | + * @return bool |
|
58 | + * @since $VID:$ |
|
59 | + */ |
|
60 | + protected function requestHandler() |
|
61 | + { |
|
62 | + $this->setRouteRequestType(PrimaryRoute::ROUTE_REQUEST_TYPE_ACTIVATION); |
|
63 | + return true; |
|
64 | + } |
|
65 | 65 | } |
@@ -18,122 +18,122 @@ |
||
18 | 18 | class RegularRequests extends PrimaryRoute |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * called just before matchesCurrentRequest() |
|
23 | - * and allows Route to perform any setup required such as calling setSpecification() |
|
24 | - * |
|
25 | - * @since $VID:$ |
|
26 | - */ |
|
27 | - public function initialize() |
|
28 | - { |
|
29 | - $basic_nodes = [ |
|
30 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\Api', |
|
31 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\CurrentUser', |
|
32 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\GeneralSettings', |
|
33 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\Locale', |
|
34 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteUrls', |
|
35 | - ]; |
|
36 | - foreach ($basic_nodes as $basic_node) { |
|
37 | - $this->dependency_map->registerDependencies( |
|
38 | - $basic_node, |
|
39 | - ['EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache] |
|
40 | - ); |
|
41 | - } |
|
42 | - $this->dependency_map->registerDependencies( |
|
43 | - 'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData', |
|
44 | - [ |
|
45 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\Api' => EE_Dependency_Map::load_from_cache, |
|
46 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\Config' => EE_Dependency_Map::load_from_cache, |
|
47 | - 'EventEspresso\core\services\assets\JedLocaleData' => EE_Dependency_Map::load_from_cache, |
|
48 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
49 | - ] |
|
50 | - ); |
|
51 | - $this->dependency_map->registerDependencies( |
|
52 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\Config', |
|
53 | - [ |
|
54 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
55 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\EspressoCoreDomain' => EE_Dependency_Map::load_from_cache, |
|
56 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\GeneralSettings' => EE_Dependency_Map::load_from_cache, |
|
57 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\Locale' => EE_Dependency_Map::load_from_cache, |
|
58 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteCurrency' => EE_Dependency_Map::load_from_cache, |
|
59 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteUrls' => EE_Dependency_Map::load_from_cache, |
|
60 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
61 | - ] |
|
62 | - ); |
|
63 | - $this->dependency_map->registerDependencies( |
|
64 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\EspressoCoreDomain', |
|
65 | - [ |
|
66 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
67 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
68 | - ] |
|
69 | - ); |
|
70 | - $this->dependency_map->registerDependencies( |
|
71 | - 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteCurrency', |
|
72 | - [ |
|
73 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
74 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
75 | - ] |
|
76 | - ); |
|
77 | - $this->setDataNode( |
|
78 | - $this->loader->getShared('EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData') |
|
79 | - ); |
|
80 | - } |
|
21 | + /** |
|
22 | + * called just before matchesCurrentRequest() |
|
23 | + * and allows Route to perform any setup required such as calling setSpecification() |
|
24 | + * |
|
25 | + * @since $VID:$ |
|
26 | + */ |
|
27 | + public function initialize() |
|
28 | + { |
|
29 | + $basic_nodes = [ |
|
30 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\Api', |
|
31 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\CurrentUser', |
|
32 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\GeneralSettings', |
|
33 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\Locale', |
|
34 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteUrls', |
|
35 | + ]; |
|
36 | + foreach ($basic_nodes as $basic_node) { |
|
37 | + $this->dependency_map->registerDependencies( |
|
38 | + $basic_node, |
|
39 | + ['EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache] |
|
40 | + ); |
|
41 | + } |
|
42 | + $this->dependency_map->registerDependencies( |
|
43 | + 'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData', |
|
44 | + [ |
|
45 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\Api' => EE_Dependency_Map::load_from_cache, |
|
46 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\Config' => EE_Dependency_Map::load_from_cache, |
|
47 | + 'EventEspresso\core\services\assets\JedLocaleData' => EE_Dependency_Map::load_from_cache, |
|
48 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
49 | + ] |
|
50 | + ); |
|
51 | + $this->dependency_map->registerDependencies( |
|
52 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\Config', |
|
53 | + [ |
|
54 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
55 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\EspressoCoreDomain' => EE_Dependency_Map::load_from_cache, |
|
56 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\GeneralSettings' => EE_Dependency_Map::load_from_cache, |
|
57 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\Locale' => EE_Dependency_Map::load_from_cache, |
|
58 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteCurrency' => EE_Dependency_Map::load_from_cache, |
|
59 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteUrls' => EE_Dependency_Map::load_from_cache, |
|
60 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
61 | + ] |
|
62 | + ); |
|
63 | + $this->dependency_map->registerDependencies( |
|
64 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\EspressoCoreDomain', |
|
65 | + [ |
|
66 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
67 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
68 | + ] |
|
69 | + ); |
|
70 | + $this->dependency_map->registerDependencies( |
|
71 | + 'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteCurrency', |
|
72 | + [ |
|
73 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
74 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
75 | + ] |
|
76 | + ); |
|
77 | + $this->setDataNode( |
|
78 | + $this->loader->getShared('EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData') |
|
79 | + ); |
|
80 | + } |
|
81 | 81 | |
82 | 82 | |
83 | - /** |
|
84 | - * returns true if the current request matches this route |
|
85 | - * |
|
86 | - * @return bool |
|
87 | - * @since $VID:$ |
|
88 | - */ |
|
89 | - public function matchesCurrentRequest() |
|
90 | - { |
|
91 | - return ! $this->request->isActivation() || $this->request->isUnitTesting(); |
|
92 | - } |
|
83 | + /** |
|
84 | + * returns true if the current request matches this route |
|
85 | + * |
|
86 | + * @return bool |
|
87 | + * @since $VID:$ |
|
88 | + */ |
|
89 | + public function matchesCurrentRequest() |
|
90 | + { |
|
91 | + return ! $this->request->isActivation() || $this->request->isUnitTesting(); |
|
92 | + } |
|
93 | 93 | |
94 | 94 | |
95 | - /** |
|
96 | - * @since $VID:$ |
|
97 | - */ |
|
98 | - protected function registerDependencies() |
|
99 | - { |
|
100 | - $admin = ['EE_Admin_Config' => EE_Dependency_Map::load_from_cache] + Route::$default_dependencies; |
|
101 | - $public = ['EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache] + Route::$default_dependencies; |
|
102 | - $default_routes = [ |
|
103 | - // default dependencies |
|
104 | - 'EventEspresso\core\domain\entities\routing\handlers\admin\PueRequests' => Route::$default_dependencies, |
|
105 | - 'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage' => Route::$default_dependencies, |
|
106 | - 'EventEspresso\core\domain\entities\routing\handlers\frontend\ShortcodeRequests' => Route::$default_dependencies, |
|
107 | - 'EventEspresso\core\domain\entities\routing\handlers\shared\AssetRequests' => Route::$default_dependencies, |
|
108 | - 'EventEspresso\core\domain\entities\routing\handlers\shared\GQLRequests' => Route::$default_dependencies, |
|
109 | - 'EventEspresso\core\domain\entities\routing\handlers\shared\RestApiRequests' => Route::$default_dependencies, |
|
110 | - 'EventEspresso\core\domain\entities\routing\handlers\shared\SessionRequests' => Route::$default_dependencies, |
|
111 | - 'EventEspresso\core\domain\entities\routing\handlers\shared\WordPressHeartbeat' => Route::$default_dependencies, |
|
112 | - // admin dependencies |
|
113 | - 'EventEspresso\core\domain\entities\routing\handlers\admin\AdminRoute' => $admin, |
|
114 | - 'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventsAdmin' => $admin, |
|
115 | - 'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventEditor' => $admin, |
|
116 | - 'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoLegacyAdmin' => $admin, |
|
117 | - 'EventEspresso\core\domain\entities\routing\handlers\admin\GutenbergEditor' => $admin, |
|
118 | - // public dependencies |
|
119 | - 'EventEspresso\core\domain\entities\routing\handlers\admin\PersonalDataRequests' => $public, |
|
120 | - 'EventEspresso\core\domain\entities\routing\handlers\frontend\FrontendRequests' => $public, |
|
121 | - ]; |
|
122 | - foreach ($default_routes as $route => $dependencies) { |
|
123 | - $this->dependency_map->registerDependencies($route, $dependencies); |
|
124 | - } |
|
125 | - } |
|
95 | + /** |
|
96 | + * @since $VID:$ |
|
97 | + */ |
|
98 | + protected function registerDependencies() |
|
99 | + { |
|
100 | + $admin = ['EE_Admin_Config' => EE_Dependency_Map::load_from_cache] + Route::$default_dependencies; |
|
101 | + $public = ['EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache] + Route::$default_dependencies; |
|
102 | + $default_routes = [ |
|
103 | + // default dependencies |
|
104 | + 'EventEspresso\core\domain\entities\routing\handlers\admin\PueRequests' => Route::$default_dependencies, |
|
105 | + 'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage' => Route::$default_dependencies, |
|
106 | + 'EventEspresso\core\domain\entities\routing\handlers\frontend\ShortcodeRequests' => Route::$default_dependencies, |
|
107 | + 'EventEspresso\core\domain\entities\routing\handlers\shared\AssetRequests' => Route::$default_dependencies, |
|
108 | + 'EventEspresso\core\domain\entities\routing\handlers\shared\GQLRequests' => Route::$default_dependencies, |
|
109 | + 'EventEspresso\core\domain\entities\routing\handlers\shared\RestApiRequests' => Route::$default_dependencies, |
|
110 | + 'EventEspresso\core\domain\entities\routing\handlers\shared\SessionRequests' => Route::$default_dependencies, |
|
111 | + 'EventEspresso\core\domain\entities\routing\handlers\shared\WordPressHeartbeat' => Route::$default_dependencies, |
|
112 | + // admin dependencies |
|
113 | + 'EventEspresso\core\domain\entities\routing\handlers\admin\AdminRoute' => $admin, |
|
114 | + 'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventsAdmin' => $admin, |
|
115 | + 'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventEditor' => $admin, |
|
116 | + 'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoLegacyAdmin' => $admin, |
|
117 | + 'EventEspresso\core\domain\entities\routing\handlers\admin\GutenbergEditor' => $admin, |
|
118 | + // public dependencies |
|
119 | + 'EventEspresso\core\domain\entities\routing\handlers\admin\PersonalDataRequests' => $public, |
|
120 | + 'EventEspresso\core\domain\entities\routing\handlers\frontend\FrontendRequests' => $public, |
|
121 | + ]; |
|
122 | + foreach ($default_routes as $route => $dependencies) { |
|
123 | + $this->dependency_map->registerDependencies($route, $dependencies); |
|
124 | + } |
|
125 | + } |
|
126 | 126 | |
127 | 127 | |
128 | - /** |
|
129 | - * implements logic required to run during request |
|
130 | - * |
|
131 | - * @return bool |
|
132 | - * @since $VID:$ |
|
133 | - */ |
|
134 | - protected function requestHandler() |
|
135 | - { |
|
136 | - $this->setRouteRequestType(PrimaryRoute::ROUTE_REQUEST_TYPE_REGULAR); |
|
137 | - return true; |
|
138 | - } |
|
128 | + /** |
|
129 | + * implements logic required to run during request |
|
130 | + * |
|
131 | + * @return bool |
|
132 | + * @since $VID:$ |
|
133 | + */ |
|
134 | + protected function requestHandler() |
|
135 | + { |
|
136 | + $this->setRouteRequestType(PrimaryRoute::ROUTE_REQUEST_TYPE_REGULAR); |
|
137 | + return true; |
|
138 | + } |
|
139 | 139 | } |
@@ -16,238 +16,238 @@ |
||
16 | 16 | class RequestTypeContextChecker extends ContextChecker implements RequestTypeContextCheckerInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var RequestTypeContext $request_type |
|
21 | - */ |
|
22 | - private $request_type; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * RequestTypeContextChecker constructor. |
|
27 | - * |
|
28 | - * @param RequestTypeContext $request_type |
|
29 | - */ |
|
30 | - public function __construct(RequestTypeContext $request_type) |
|
31 | - { |
|
32 | - $this->request_type = $request_type; |
|
33 | - parent::__construct( |
|
34 | - 'RequestTypeContextChecker', |
|
35 | - $this->request_type->validRequestTypes() |
|
36 | - ); |
|
37 | - } |
|
38 | - |
|
39 | - |
|
40 | - /** |
|
41 | - * true if the current request involves some form of activation |
|
42 | - * |
|
43 | - * @return bool |
|
44 | - */ |
|
45 | - public function isActivation() |
|
46 | - { |
|
47 | - return $this->request_type->isActivation(); |
|
48 | - } |
|
49 | - |
|
50 | - |
|
51 | - /** |
|
52 | - * @param $is_activation |
|
53 | - */ |
|
54 | - public function setIsActivation($is_activation) |
|
55 | - { |
|
56 | - $this->request_type->setIsActivation($is_activation); |
|
57 | - } |
|
58 | - |
|
59 | - |
|
60 | - /** |
|
61 | - * true if the current request is for the admin and is not being made via AJAX |
|
62 | - * |
|
63 | - * @return bool |
|
64 | - */ |
|
65 | - public function isAdmin() |
|
66 | - { |
|
67 | - return $this->request_type->slug() === RequestTypeContext::ADMIN && ! $this->isActivation(); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * true if the current request is for the admin AND is being made via AJAX |
|
73 | - * |
|
74 | - * @return bool |
|
75 | - */ |
|
76 | - public function isAdminAjax() |
|
77 | - { |
|
78 | - return $this->request_type->slug() === RequestTypeContext::AJAX_ADMIN && ! $this->isActivation(); |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - /** |
|
83 | - * true if the current request is being made via AJAX... any AJAX |
|
84 | - * |
|
85 | - * @return bool |
|
86 | - */ |
|
87 | - public function isAjax() |
|
88 | - { |
|
89 | - return $this->isEeAjax() || $this->isOtherAjax(); |
|
90 | - } |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * true if the current request is for either the EE admin or EE frontend AND is being made via AJAX |
|
95 | - * |
|
96 | - * @return bool |
|
97 | - */ |
|
98 | - public function isEeAjax() |
|
99 | - { |
|
100 | - return $this->isAdminAjax() || $this->isFrontAjax(); |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - /** |
|
105 | - * true if the current request is being made via AJAX but is NOT for EE related logic |
|
106 | - * |
|
107 | - * @return bool |
|
108 | - */ |
|
109 | - public function isOtherAjax() |
|
110 | - { |
|
111 | - return $this->request_type->slug() === RequestTypeContext::AJAX_OTHER && ! $this->isActivation(); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * true if the current request is for the EE REST API |
|
116 | - * |
|
117 | - * @return bool |
|
118 | - */ |
|
119 | - public function isApi() |
|
120 | - { |
|
121 | - return $this->request_type->slug() === RequestTypeContext::API && ! $this->isActivation(); |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * true if the current request is from the command line |
|
127 | - * |
|
128 | - * @return bool |
|
129 | - */ |
|
130 | - public function isCli() |
|
131 | - { |
|
132 | - return $this->request_type->slug() === RequestTypeContext::CLI && ! $this->isActivation(); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - /** |
|
137 | - * true if the current request is for a WP_Cron |
|
138 | - * |
|
139 | - * @return bool |
|
140 | - */ |
|
141 | - public function isCron() |
|
142 | - { |
|
143 | - return $this->request_type->slug() === RequestTypeContext::CRON && ! $this->isActivation(); |
|
144 | - } |
|
145 | - |
|
146 | - |
|
147 | - /** |
|
148 | - * true if the current request is for a feed (ie: RSS) |
|
149 | - * |
|
150 | - * @return bool |
|
151 | - */ |
|
152 | - public function isFeed() |
|
153 | - { |
|
154 | - return $this->request_type->slug() === RequestTypeContext::FEED && ! $this->isActivation(); |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * true if the current request is for the frontend and is not being made via AJAX |
|
160 | - * |
|
161 | - * @return bool |
|
162 | - */ |
|
163 | - public function isFrontend() |
|
164 | - { |
|
165 | - return $this->request_type->slug() === RequestTypeContext::FRONTEND && ! $this->isActivation(); |
|
166 | - } |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * true if the current request is for the frontend AND is being made via AJAX |
|
171 | - * |
|
172 | - * @return bool |
|
173 | - */ |
|
174 | - public function isFrontAjax() |
|
175 | - { |
|
176 | - return $this->request_type->slug() === RequestTypeContext::AJAX_FRONT && ! $this->isActivation(); |
|
177 | - } |
|
178 | - |
|
179 | - |
|
180 | - /** |
|
181 | - * true if the current request is for the EE GraphQL manager |
|
182 | - * |
|
183 | - * @return bool |
|
184 | - */ |
|
185 | - public function isGQL() |
|
186 | - { |
|
187 | - return $this->request_type->slug() === RequestTypeContext::GQL && ! $this->isActivation(); |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * true if the current request is for content that is to be displayed within an iframe |
|
193 | - * |
|
194 | - * @return bool |
|
195 | - */ |
|
196 | - public function isIframe() |
|
197 | - { |
|
198 | - return $this->request_type->slug() === RequestTypeContext::IFRAME && ! $this->isActivation(); |
|
199 | - } |
|
200 | - |
|
201 | - |
|
202 | - /** |
|
203 | - * true if the current request is occurring while unit testing |
|
204 | - * |
|
205 | - * @return bool |
|
206 | - */ |
|
207 | - public function isUnitTesting() |
|
208 | - { |
|
209 | - return $this->request_type->isUnitTesting() && ! $this->isActivation(); |
|
210 | - } |
|
211 | - |
|
212 | - |
|
213 | - /** |
|
214 | - * true if the current request is for the WP REST API |
|
215 | - * |
|
216 | - * @return bool |
|
217 | - */ |
|
218 | - public function isWordPressApi() |
|
219 | - { |
|
220 | - return $this->request_type->slug() === RequestTypeContext::WP_API && ! $this->isActivation(); |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * true if the current request is being made via AJAX for the WP Heartbeat |
|
226 | - * |
|
227 | - * @return bool |
|
228 | - */ |
|
229 | - public function isWordPressHeartbeat() |
|
230 | - { |
|
231 | - return $this->request_type->slug() === RequestTypeContext::AJAX_HEARTBEAT && ! $this->isActivation(); |
|
232 | - } |
|
233 | - |
|
234 | - |
|
235 | - /** |
|
236 | - * true if the current request is a loopback sent from WP core to test for errors |
|
237 | - * |
|
238 | - * @return bool |
|
239 | - */ |
|
240 | - public function isWordPressScrape() |
|
241 | - { |
|
242 | - return $this->request_type->slug() === RequestTypeContext::WP_SCRAPE; |
|
243 | - } |
|
244 | - |
|
245 | - |
|
246 | - /** |
|
247 | - * @return string |
|
248 | - */ |
|
249 | - public function slug() |
|
250 | - { |
|
251 | - return $this->request_type->slug(); |
|
252 | - } |
|
19 | + /** |
|
20 | + * @var RequestTypeContext $request_type |
|
21 | + */ |
|
22 | + private $request_type; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * RequestTypeContextChecker constructor. |
|
27 | + * |
|
28 | + * @param RequestTypeContext $request_type |
|
29 | + */ |
|
30 | + public function __construct(RequestTypeContext $request_type) |
|
31 | + { |
|
32 | + $this->request_type = $request_type; |
|
33 | + parent::__construct( |
|
34 | + 'RequestTypeContextChecker', |
|
35 | + $this->request_type->validRequestTypes() |
|
36 | + ); |
|
37 | + } |
|
38 | + |
|
39 | + |
|
40 | + /** |
|
41 | + * true if the current request involves some form of activation |
|
42 | + * |
|
43 | + * @return bool |
|
44 | + */ |
|
45 | + public function isActivation() |
|
46 | + { |
|
47 | + return $this->request_type->isActivation(); |
|
48 | + } |
|
49 | + |
|
50 | + |
|
51 | + /** |
|
52 | + * @param $is_activation |
|
53 | + */ |
|
54 | + public function setIsActivation($is_activation) |
|
55 | + { |
|
56 | + $this->request_type->setIsActivation($is_activation); |
|
57 | + } |
|
58 | + |
|
59 | + |
|
60 | + /** |
|
61 | + * true if the current request is for the admin and is not being made via AJAX |
|
62 | + * |
|
63 | + * @return bool |
|
64 | + */ |
|
65 | + public function isAdmin() |
|
66 | + { |
|
67 | + return $this->request_type->slug() === RequestTypeContext::ADMIN && ! $this->isActivation(); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * true if the current request is for the admin AND is being made via AJAX |
|
73 | + * |
|
74 | + * @return bool |
|
75 | + */ |
|
76 | + public function isAdminAjax() |
|
77 | + { |
|
78 | + return $this->request_type->slug() === RequestTypeContext::AJAX_ADMIN && ! $this->isActivation(); |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + /** |
|
83 | + * true if the current request is being made via AJAX... any AJAX |
|
84 | + * |
|
85 | + * @return bool |
|
86 | + */ |
|
87 | + public function isAjax() |
|
88 | + { |
|
89 | + return $this->isEeAjax() || $this->isOtherAjax(); |
|
90 | + } |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * true if the current request is for either the EE admin or EE frontend AND is being made via AJAX |
|
95 | + * |
|
96 | + * @return bool |
|
97 | + */ |
|
98 | + public function isEeAjax() |
|
99 | + { |
|
100 | + return $this->isAdminAjax() || $this->isFrontAjax(); |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + /** |
|
105 | + * true if the current request is being made via AJAX but is NOT for EE related logic |
|
106 | + * |
|
107 | + * @return bool |
|
108 | + */ |
|
109 | + public function isOtherAjax() |
|
110 | + { |
|
111 | + return $this->request_type->slug() === RequestTypeContext::AJAX_OTHER && ! $this->isActivation(); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * true if the current request is for the EE REST API |
|
116 | + * |
|
117 | + * @return bool |
|
118 | + */ |
|
119 | + public function isApi() |
|
120 | + { |
|
121 | + return $this->request_type->slug() === RequestTypeContext::API && ! $this->isActivation(); |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * true if the current request is from the command line |
|
127 | + * |
|
128 | + * @return bool |
|
129 | + */ |
|
130 | + public function isCli() |
|
131 | + { |
|
132 | + return $this->request_type->slug() === RequestTypeContext::CLI && ! $this->isActivation(); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + /** |
|
137 | + * true if the current request is for a WP_Cron |
|
138 | + * |
|
139 | + * @return bool |
|
140 | + */ |
|
141 | + public function isCron() |
|
142 | + { |
|
143 | + return $this->request_type->slug() === RequestTypeContext::CRON && ! $this->isActivation(); |
|
144 | + } |
|
145 | + |
|
146 | + |
|
147 | + /** |
|
148 | + * true if the current request is for a feed (ie: RSS) |
|
149 | + * |
|
150 | + * @return bool |
|
151 | + */ |
|
152 | + public function isFeed() |
|
153 | + { |
|
154 | + return $this->request_type->slug() === RequestTypeContext::FEED && ! $this->isActivation(); |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * true if the current request is for the frontend and is not being made via AJAX |
|
160 | + * |
|
161 | + * @return bool |
|
162 | + */ |
|
163 | + public function isFrontend() |
|
164 | + { |
|
165 | + return $this->request_type->slug() === RequestTypeContext::FRONTEND && ! $this->isActivation(); |
|
166 | + } |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * true if the current request is for the frontend AND is being made via AJAX |
|
171 | + * |
|
172 | + * @return bool |
|
173 | + */ |
|
174 | + public function isFrontAjax() |
|
175 | + { |
|
176 | + return $this->request_type->slug() === RequestTypeContext::AJAX_FRONT && ! $this->isActivation(); |
|
177 | + } |
|
178 | + |
|
179 | + |
|
180 | + /** |
|
181 | + * true if the current request is for the EE GraphQL manager |
|
182 | + * |
|
183 | + * @return bool |
|
184 | + */ |
|
185 | + public function isGQL() |
|
186 | + { |
|
187 | + return $this->request_type->slug() === RequestTypeContext::GQL && ! $this->isActivation(); |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * true if the current request is for content that is to be displayed within an iframe |
|
193 | + * |
|
194 | + * @return bool |
|
195 | + */ |
|
196 | + public function isIframe() |
|
197 | + { |
|
198 | + return $this->request_type->slug() === RequestTypeContext::IFRAME && ! $this->isActivation(); |
|
199 | + } |
|
200 | + |
|
201 | + |
|
202 | + /** |
|
203 | + * true if the current request is occurring while unit testing |
|
204 | + * |
|
205 | + * @return bool |
|
206 | + */ |
|
207 | + public function isUnitTesting() |
|
208 | + { |
|
209 | + return $this->request_type->isUnitTesting() && ! $this->isActivation(); |
|
210 | + } |
|
211 | + |
|
212 | + |
|
213 | + /** |
|
214 | + * true if the current request is for the WP REST API |
|
215 | + * |
|
216 | + * @return bool |
|
217 | + */ |
|
218 | + public function isWordPressApi() |
|
219 | + { |
|
220 | + return $this->request_type->slug() === RequestTypeContext::WP_API && ! $this->isActivation(); |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * true if the current request is being made via AJAX for the WP Heartbeat |
|
226 | + * |
|
227 | + * @return bool |
|
228 | + */ |
|
229 | + public function isWordPressHeartbeat() |
|
230 | + { |
|
231 | + return $this->request_type->slug() === RequestTypeContext::AJAX_HEARTBEAT && ! $this->isActivation(); |
|
232 | + } |
|
233 | + |
|
234 | + |
|
235 | + /** |
|
236 | + * true if the current request is a loopback sent from WP core to test for errors |
|
237 | + * |
|
238 | + * @return bool |
|
239 | + */ |
|
240 | + public function isWordPressScrape() |
|
241 | + { |
|
242 | + return $this->request_type->slug() === RequestTypeContext::WP_SCRAPE; |
|
243 | + } |
|
244 | + |
|
245 | + |
|
246 | + /** |
|
247 | + * @return string |
|
248 | + */ |
|
249 | + public function slug() |
|
250 | + { |
|
251 | + return $this->request_type->slug(); |
|
252 | + } |
|
253 | 253 | } |