@@ -13,45 +13,45 @@ |
||
13 | 13 | class EE_Detect_File_Editor_Request extends EE_Middleware |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * Converts a Request to a Response |
|
18 | - * |
|
19 | - * @param EE_Request $request |
|
20 | - * @param EE_Response $response |
|
21 | - * @return EE_Response |
|
22 | - */ |
|
23 | - public function handle_request(EE_Request $request, EE_Response $response) |
|
24 | - { |
|
25 | - $this->_request = $request; |
|
26 | - $this->_response = $response; |
|
27 | - $this->setFiltersForRequest(); |
|
28 | - $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
29 | - return $this->_response; |
|
30 | - } |
|
16 | + /** |
|
17 | + * Converts a Request to a Response |
|
18 | + * |
|
19 | + * @param EE_Request $request |
|
20 | + * @param EE_Response $response |
|
21 | + * @return EE_Response |
|
22 | + */ |
|
23 | + public function handle_request(EE_Request $request, EE_Response $response) |
|
24 | + { |
|
25 | + $this->_request = $request; |
|
26 | + $this->_response = $response; |
|
27 | + $this->setFiltersForRequest(); |
|
28 | + $this->_response = $this->process_request_stack($this->_request, $this->_response); |
|
29 | + return $this->_response; |
|
30 | + } |
|
31 | 31 | |
32 | 32 | |
33 | - /** |
|
34 | - * This sets any filters that need set on this request. |
|
35 | - */ |
|
36 | - protected function setFiltersForRequest() |
|
37 | - { |
|
38 | - if (! $this->isFileEditorRequest()) { |
|
39 | - return; |
|
40 | - } |
|
41 | - add_filter('FHEE_load_EE_Session', '__return_false', 999); |
|
42 | - } |
|
33 | + /** |
|
34 | + * This sets any filters that need set on this request. |
|
35 | + */ |
|
36 | + protected function setFiltersForRequest() |
|
37 | + { |
|
38 | + if (! $this->isFileEditorRequest()) { |
|
39 | + return; |
|
40 | + } |
|
41 | + add_filter('FHEE_load_EE_Session', '__return_false', 999); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - /** |
|
46 | - * Conditions for a "file editor request" |
|
47 | - * @see wp-admin/includes/file.php |
|
48 | - * The file editor does a loopback request to the admin AND to the frontend when checking active theme or |
|
49 | - * active plugin edits. So these conditions consider that. |
|
50 | - * @return bool |
|
51 | - */ |
|
52 | - protected function isFileEditorRequest() |
|
53 | - { |
|
54 | - return $this->_request->get('wp_scrape_key') |
|
55 | - && $this->_request->get('wp_scrape_nonce'); |
|
56 | - } |
|
45 | + /** |
|
46 | + * Conditions for a "file editor request" |
|
47 | + * @see wp-admin/includes/file.php |
|
48 | + * The file editor does a loopback request to the admin AND to the frontend when checking active theme or |
|
49 | + * active plugin edits. So these conditions consider that. |
|
50 | + * @return bool |
|
51 | + */ |
|
52 | + protected function isFileEditorRequest() |
|
53 | + { |
|
54 | + return $this->_request->get('wp_scrape_key') |
|
55 | + && $this->_request->get('wp_scrape_nonce'); |
|
56 | + } |
|
57 | 57 | } |
@@ -35,7 +35,7 @@ |
||
35 | 35 | */ |
36 | 36 | protected function setFiltersForRequest() |
37 | 37 | { |
38 | - if (! $this->isFileEditorRequest()) { |
|
38 | + if ( ! $this->isFileEditorRequest()) { |
|
39 | 39 | return; |
40 | 40 | } |
41 | 41 | add_filter('FHEE_load_EE_Session', '__return_false', 999); |
@@ -29,192 +29,192 @@ |
||
29 | 29 | class EE_Bootstrap |
30 | 30 | { |
31 | 31 | |
32 | - /** |
|
33 | - * @var EE_Request $request |
|
34 | - */ |
|
35 | - protected $request; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var EE_Response $response |
|
39 | - */ |
|
40 | - protected $response; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var EE_Request_Stack_Builder $request_stack_builder |
|
44 | - */ |
|
45 | - protected $request_stack_builder; |
|
46 | - |
|
47 | - /** |
|
48 | - * @var EE_Request_Stack $_request_stack |
|
49 | - */ |
|
50 | - protected $request_stack; |
|
51 | - |
|
52 | - |
|
53 | - |
|
54 | - public function __construct(EE_Request $request, EE_Response $response) |
|
55 | - { |
|
56 | - $this->request = $request; |
|
57 | - $this->response = $response; |
|
58 | - // construct request stack and run middleware apps as soon as all WP plugins are loaded |
|
59 | - add_action('plugins_loaded', array($this, 'run_request_stack'), 0); |
|
60 | - // set framework for the rest of EE to hook into when loading |
|
61 | - add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1); |
|
62 | - add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3); |
|
63 | - add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5); |
|
64 | - add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7); |
|
65 | - add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9); |
|
66 | - } |
|
67 | - |
|
68 | - |
|
69 | - |
|
70 | - /** |
|
71 | - * run_request_stack |
|
72 | - * construct request stack and run middleware apps |
|
73 | - * |
|
74 | - * @throws EE_Error |
|
75 | - * @throws InvalidArgumentException |
|
76 | - */ |
|
77 | - public function run_request_stack() |
|
78 | - { |
|
79 | - $this->load_autoloader(); |
|
80 | - $this->set_autoloaders_for_required_files(); |
|
81 | - $this->request_stack_builder = $this->build_request_stack(); |
|
82 | - $this->request_stack = $this->request_stack_builder->resolve( |
|
83 | - new EE_Load_Espresso_Core() |
|
84 | - ); |
|
85 | - $this->request_stack->handle_request($this->request, $this->response); |
|
86 | - $this->request_stack->handle_response(); |
|
87 | - } |
|
88 | - |
|
89 | - |
|
90 | - |
|
91 | - /** |
|
92 | - * load_autoloader |
|
93 | - */ |
|
94 | - protected function load_autoloader() |
|
95 | - { |
|
96 | - // load interfaces |
|
97 | - espresso_load_required( |
|
98 | - 'EEH_Autoloader', |
|
99 | - EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' |
|
100 | - ); |
|
101 | - EEH_Autoloader::instance(); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - |
|
106 | - /** |
|
107 | - * load_required_files |
|
108 | - * |
|
109 | - * @throws EE_Error |
|
110 | - */ |
|
111 | - protected function set_autoloaders_for_required_files() |
|
112 | - { |
|
113 | - // load interfaces |
|
114 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
115 | - // load helpers |
|
116 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
117 | - // load request stack |
|
118 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack' . DS); |
|
119 | - // load middleware |
|
120 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware' . DS); |
|
121 | - } |
|
122 | - |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * build_request_stack |
|
127 | - * |
|
128 | - * @return EE_Request_Stack_Builder |
|
129 | - * @throws InvalidArgumentException |
|
130 | - */ |
|
131 | - public function build_request_stack() |
|
132 | - { |
|
133 | - $request_stack_builder = new EE_Request_Stack_Builder(); |
|
134 | - $stack_apps = apply_filters( |
|
135 | - 'FHEE__EE_Bootstrap__build_request_stack__stack_apps', |
|
136 | - array( |
|
137 | - 'EE_Detect_File_Editor_Request', |
|
138 | - 'EE_Detect_Login', |
|
139 | - 'EE_Recommended_Versions', |
|
140 | - 'EE_Alpha_Banner_Warning', |
|
141 | - ) |
|
142 | - ); |
|
143 | - // load middleware onto stack : FILO (First In Last Out) |
|
144 | - foreach ((array)$stack_apps as $stack_app) { |
|
145 | - //$request_stack_builder->push( $stack_app ); |
|
146 | - $request_stack_builder->unshift($stack_app); |
|
147 | - } |
|
148 | - return apply_filters( |
|
149 | - 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
|
150 | - $request_stack_builder |
|
151 | - ); |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - |
|
156 | - /** |
|
157 | - * load_espresso_addons |
|
158 | - * runs during the WP 'plugins_loaded' action at priority 1 |
|
159 | - * and is the initial loading phase for EE addons |
|
160 | - * no other logic should be performed at this point |
|
161 | - */ |
|
162 | - public static function load_espresso_addons() |
|
163 | - { |
|
164 | - do_action('AHEE__EE_Bootstrap__load_espresso_addons'); |
|
165 | - } |
|
166 | - |
|
167 | - |
|
168 | - |
|
169 | - /** |
|
170 | - * detect_activations_or_upgrades |
|
171 | - * runs during the WP 'plugins_loaded' action at priority 3 |
|
172 | - * Now that all of the addons have been loaded, |
|
173 | - * we can determine if anything needs activating or upgrading |
|
174 | - */ |
|
175 | - public static function detect_activations_or_upgrades() |
|
176 | - { |
|
177 | - do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades'); |
|
178 | - } |
|
179 | - |
|
180 | - |
|
181 | - |
|
182 | - /** |
|
183 | - * load_core_configuration |
|
184 | - * runs during the WP 'plugins_loaded' action at priority 5 |
|
185 | - * Now that the database is assumed to be at the correct version |
|
186 | - * we can load and set all of the system configurations |
|
187 | - */ |
|
188 | - public static function load_core_configuration() |
|
189 | - { |
|
190 | - do_action('AHEE__EE_Bootstrap__load_core_configuration'); |
|
191 | - } |
|
192 | - |
|
193 | - |
|
194 | - |
|
195 | - /** |
|
196 | - * register_shortcodes_modules_and_widgets |
|
197 | - * runs during the WP 'plugins_loaded' action at priority 7 |
|
198 | - * and handles registering all o four shortcodes, modules and widgets |
|
199 | - * so that they are ready to be used throughout the system |
|
200 | - */ |
|
201 | - public static function register_shortcodes_modules_and_widgets() |
|
202 | - { |
|
203 | - do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'); |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - |
|
208 | - /** |
|
209 | - * brew_espresso |
|
210 | - * runs during the WP 'plugins_loaded' action at priority 9 |
|
211 | - * bootstrapping is considered complete at this point, |
|
212 | - * so let the fun begin... |
|
213 | - */ |
|
214 | - public static function brew_espresso() |
|
215 | - { |
|
216 | - do_action('AHEE__EE_Bootstrap__brew_espresso'); |
|
217 | - } |
|
32 | + /** |
|
33 | + * @var EE_Request $request |
|
34 | + */ |
|
35 | + protected $request; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var EE_Response $response |
|
39 | + */ |
|
40 | + protected $response; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var EE_Request_Stack_Builder $request_stack_builder |
|
44 | + */ |
|
45 | + protected $request_stack_builder; |
|
46 | + |
|
47 | + /** |
|
48 | + * @var EE_Request_Stack $_request_stack |
|
49 | + */ |
|
50 | + protected $request_stack; |
|
51 | + |
|
52 | + |
|
53 | + |
|
54 | + public function __construct(EE_Request $request, EE_Response $response) |
|
55 | + { |
|
56 | + $this->request = $request; |
|
57 | + $this->response = $response; |
|
58 | + // construct request stack and run middleware apps as soon as all WP plugins are loaded |
|
59 | + add_action('plugins_loaded', array($this, 'run_request_stack'), 0); |
|
60 | + // set framework for the rest of EE to hook into when loading |
|
61 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_espresso_addons'), 1); |
|
62 | + add_action('plugins_loaded', array('EE_Bootstrap', 'detect_activations_or_upgrades'), 3); |
|
63 | + add_action('plugins_loaded', array('EE_Bootstrap', 'load_core_configuration'), 5); |
|
64 | + add_action('plugins_loaded', array('EE_Bootstrap', 'register_shortcodes_modules_and_widgets'), 7); |
|
65 | + add_action('plugins_loaded', array('EE_Bootstrap', 'brew_espresso'), 9); |
|
66 | + } |
|
67 | + |
|
68 | + |
|
69 | + |
|
70 | + /** |
|
71 | + * run_request_stack |
|
72 | + * construct request stack and run middleware apps |
|
73 | + * |
|
74 | + * @throws EE_Error |
|
75 | + * @throws InvalidArgumentException |
|
76 | + */ |
|
77 | + public function run_request_stack() |
|
78 | + { |
|
79 | + $this->load_autoloader(); |
|
80 | + $this->set_autoloaders_for_required_files(); |
|
81 | + $this->request_stack_builder = $this->build_request_stack(); |
|
82 | + $this->request_stack = $this->request_stack_builder->resolve( |
|
83 | + new EE_Load_Espresso_Core() |
|
84 | + ); |
|
85 | + $this->request_stack->handle_request($this->request, $this->response); |
|
86 | + $this->request_stack->handle_response(); |
|
87 | + } |
|
88 | + |
|
89 | + |
|
90 | + |
|
91 | + /** |
|
92 | + * load_autoloader |
|
93 | + */ |
|
94 | + protected function load_autoloader() |
|
95 | + { |
|
96 | + // load interfaces |
|
97 | + espresso_load_required( |
|
98 | + 'EEH_Autoloader', |
|
99 | + EE_CORE . 'helpers' . DS . 'EEH_Autoloader.helper.php' |
|
100 | + ); |
|
101 | + EEH_Autoloader::instance(); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + |
|
106 | + /** |
|
107 | + * load_required_files |
|
108 | + * |
|
109 | + * @throws EE_Error |
|
110 | + */ |
|
111 | + protected function set_autoloaders_for_required_files() |
|
112 | + { |
|
113 | + // load interfaces |
|
114 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces', true); |
|
115 | + // load helpers |
|
116 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
117 | + // load request stack |
|
118 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'request_stack' . DS); |
|
119 | + // load middleware |
|
120 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'middleware' . DS); |
|
121 | + } |
|
122 | + |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * build_request_stack |
|
127 | + * |
|
128 | + * @return EE_Request_Stack_Builder |
|
129 | + * @throws InvalidArgumentException |
|
130 | + */ |
|
131 | + public function build_request_stack() |
|
132 | + { |
|
133 | + $request_stack_builder = new EE_Request_Stack_Builder(); |
|
134 | + $stack_apps = apply_filters( |
|
135 | + 'FHEE__EE_Bootstrap__build_request_stack__stack_apps', |
|
136 | + array( |
|
137 | + 'EE_Detect_File_Editor_Request', |
|
138 | + 'EE_Detect_Login', |
|
139 | + 'EE_Recommended_Versions', |
|
140 | + 'EE_Alpha_Banner_Warning', |
|
141 | + ) |
|
142 | + ); |
|
143 | + // load middleware onto stack : FILO (First In Last Out) |
|
144 | + foreach ((array)$stack_apps as $stack_app) { |
|
145 | + //$request_stack_builder->push( $stack_app ); |
|
146 | + $request_stack_builder->unshift($stack_app); |
|
147 | + } |
|
148 | + return apply_filters( |
|
149 | + 'FHEE__EE_Bootstrap__build_request_stack__request_stack_builder', |
|
150 | + $request_stack_builder |
|
151 | + ); |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + |
|
156 | + /** |
|
157 | + * load_espresso_addons |
|
158 | + * runs during the WP 'plugins_loaded' action at priority 1 |
|
159 | + * and is the initial loading phase for EE addons |
|
160 | + * no other logic should be performed at this point |
|
161 | + */ |
|
162 | + public static function load_espresso_addons() |
|
163 | + { |
|
164 | + do_action('AHEE__EE_Bootstrap__load_espresso_addons'); |
|
165 | + } |
|
166 | + |
|
167 | + |
|
168 | + |
|
169 | + /** |
|
170 | + * detect_activations_or_upgrades |
|
171 | + * runs during the WP 'plugins_loaded' action at priority 3 |
|
172 | + * Now that all of the addons have been loaded, |
|
173 | + * we can determine if anything needs activating or upgrading |
|
174 | + */ |
|
175 | + public static function detect_activations_or_upgrades() |
|
176 | + { |
|
177 | + do_action('AHEE__EE_Bootstrap__detect_activations_or_upgrades'); |
|
178 | + } |
|
179 | + |
|
180 | + |
|
181 | + |
|
182 | + /** |
|
183 | + * load_core_configuration |
|
184 | + * runs during the WP 'plugins_loaded' action at priority 5 |
|
185 | + * Now that the database is assumed to be at the correct version |
|
186 | + * we can load and set all of the system configurations |
|
187 | + */ |
|
188 | + public static function load_core_configuration() |
|
189 | + { |
|
190 | + do_action('AHEE__EE_Bootstrap__load_core_configuration'); |
|
191 | + } |
|
192 | + |
|
193 | + |
|
194 | + |
|
195 | + /** |
|
196 | + * register_shortcodes_modules_and_widgets |
|
197 | + * runs during the WP 'plugins_loaded' action at priority 7 |
|
198 | + * and handles registering all o four shortcodes, modules and widgets |
|
199 | + * so that they are ready to be used throughout the system |
|
200 | + */ |
|
201 | + public static function register_shortcodes_modules_and_widgets() |
|
202 | + { |
|
203 | + do_action('AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'); |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + |
|
208 | + /** |
|
209 | + * brew_espresso |
|
210 | + * runs during the WP 'plugins_loaded' action at priority 9 |
|
211 | + * bootstrapping is considered complete at this point, |
|
212 | + * so let the fun begin... |
|
213 | + */ |
|
214 | + public static function brew_espresso() |
|
215 | + { |
|
216 | + do_action('AHEE__EE_Bootstrap__brew_espresso'); |
|
217 | + } |
|
218 | 218 | |
219 | 219 | |
220 | 220 |