Complex classes like EE_Front_Controller often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use EE_Front_Controller, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
26 | final class EE_Front_Controller |
||
27 | { |
||
28 | |||
29 | /** |
||
30 | * @var string $_template_path |
||
31 | */ |
||
32 | private $_template_path; |
||
33 | |||
34 | /** |
||
35 | * @var string $_template |
||
36 | */ |
||
37 | private $_template; |
||
38 | |||
39 | /** |
||
40 | * @type EE_Registry $Registry |
||
41 | */ |
||
42 | protected $Registry; |
||
43 | |||
44 | /** |
||
45 | * @type EE_Request_Handler $Request_Handler |
||
46 | */ |
||
47 | protected $Request_Handler; |
||
48 | |||
49 | /** |
||
50 | * @type EE_Module_Request_Router $Module_Request_Router |
||
51 | */ |
||
52 | protected $Module_Request_Router; |
||
53 | |||
54 | |||
55 | /** |
||
56 | * class constructor |
||
57 | * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
||
58 | * |
||
59 | * @access public |
||
60 | * @param \EE_Registry $Registry |
||
61 | * @param \EE_Request_Handler $Request_Handler |
||
62 | * @param \EE_Module_Request_Router $Module_Request_Router |
||
63 | */ |
||
64 | public function __construct( |
||
104 | |||
105 | |||
106 | /** |
||
107 | * @return EE_Request_Handler |
||
108 | */ |
||
109 | public function Request_Handler() |
||
113 | |||
114 | |||
115 | /** |
||
116 | * @return EE_Module_Request_Router |
||
117 | */ |
||
118 | public function Module_Request_Router() |
||
122 | |||
123 | |||
124 | |||
125 | /** |
||
126 | * @return LegacyShortcodesManager |
||
127 | */ |
||
128 | public function getLegacyShortcodesManager() |
||
132 | |||
133 | |||
134 | |||
135 | |||
136 | |||
137 | /*********************************************** INIT ACTION HOOK ***********************************************/ |
||
138 | |||
139 | |||
140 | |||
141 | /** |
||
142 | * filter_wp_comments |
||
143 | * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
||
144 | * widgets/queries done on frontend |
||
145 | * |
||
146 | * @param array $clauses array of comment clauses setup by WP_Comment_Query |
||
147 | * @return array array of comment clauses with modifications. |
||
148 | */ |
||
149 | public function filter_wp_comments($clauses) |
||
160 | |||
161 | |||
162 | /** |
||
163 | * employ_CPT_Strategy |
||
164 | * |
||
165 | * @access public |
||
166 | * @return void |
||
167 | */ |
||
168 | public function employ_CPT_Strategy() |
||
174 | |||
175 | |||
176 | /** |
||
177 | * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
||
178 | * |
||
179 | * @param string $url incoming url |
||
180 | * @return string final assembled url |
||
181 | */ |
||
182 | public function maybe_force_admin_ajax_ssl($url) |
||
189 | |||
190 | |||
191 | |||
192 | |||
193 | |||
194 | |||
195 | /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
||
196 | |||
197 | |||
198 | /** |
||
199 | * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
||
200 | * default priority init phases have run |
||
201 | * |
||
202 | * @access public |
||
203 | * @return void |
||
204 | */ |
||
205 | public function wp_loaded() |
||
208 | |||
209 | |||
210 | |||
211 | |||
212 | |||
213 | /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
||
214 | /** |
||
215 | * _get_request |
||
216 | * |
||
217 | * @access public |
||
218 | * @param WP $WP |
||
219 | * @return void |
||
220 | */ |
||
221 | public function get_request(WP $WP) |
||
227 | |||
228 | |||
229 | |||
230 | /** |
||
231 | * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
||
232 | * |
||
233 | * @access public |
||
234 | * @param WP_Query $WP_Query |
||
235 | * @return void |
||
236 | */ |
||
237 | public function pre_get_posts($WP_Query) |
||
259 | |||
260 | |||
261 | |||
262 | |||
263 | |||
264 | /*********************************************** WP HOOK ***********************************************/ |
||
265 | |||
266 | |||
267 | /** |
||
268 | * wp - basically last chance to do stuff before headers sent |
||
269 | * |
||
270 | * @access public |
||
271 | * @return void |
||
272 | */ |
||
273 | public function wp() |
||
276 | |||
277 | |||
278 | |||
279 | /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
||
280 | |||
281 | |||
282 | |||
283 | /** |
||
284 | * callback for the WP "get_header" hook point |
||
285 | * checks sidebars for EE widgets |
||
286 | * loads resources and assets accordingly |
||
287 | * |
||
288 | * @return void |
||
289 | */ |
||
290 | public function get_header() |
||
306 | |||
307 | |||
308 | |||
309 | /** |
||
310 | * builds list of active widgets then scans active sidebars looking for them |
||
311 | * returns true is an EE widget is found in an active sidebar |
||
312 | * Please Note: this does NOT mean that the sidebar or widget |
||
313 | * is actually in use in a given template, as that is unfortunately not known |
||
314 | * until a sidebar and it's widgets are actually loaded |
||
315 | * |
||
316 | * @return boolean |
||
317 | */ |
||
318 | private function espresso_widgets_in_active_sidebars() |
||
341 | |||
342 | |||
343 | |||
344 | |||
345 | /** |
||
346 | * header_meta_tag |
||
347 | * |
||
348 | * @access public |
||
349 | * @return void |
||
350 | */ |
||
351 | public function header_meta_tag() |
||
377 | |||
378 | |||
379 | |||
380 | /** |
||
381 | * wp_print_scripts |
||
382 | * |
||
383 | * @return void |
||
384 | */ |
||
385 | public function wp_print_scripts() |
||
397 | |||
398 | |||
399 | |||
400 | |||
401 | /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
||
402 | |||
403 | |||
404 | |||
405 | // /** |
||
406 | // * the_content |
||
407 | // * |
||
408 | // * @access public |
||
409 | // * @param $the_content |
||
410 | // * @return string |
||
411 | // */ |
||
412 | // public function the_content( $the_content ) { |
||
413 | // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
||
414 | // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
||
415 | // } |
||
416 | // return $the_content; |
||
417 | // } |
||
418 | |||
419 | |||
420 | |||
421 | /*********************************************** WP_FOOTER ***********************************************/ |
||
422 | |||
423 | |||
424 | /** |
||
425 | * display_errors |
||
426 | * |
||
427 | * @access public |
||
428 | * @return void |
||
429 | */ |
||
430 | public function display_errors() |
||
448 | |||
449 | |||
450 | |||
451 | |||
452 | |||
453 | /*********************************************** UTILITIES ***********************************************/ |
||
454 | /** |
||
455 | * template_include |
||
456 | * |
||
457 | * @access public |
||
458 | * @param string $template_include_path |
||
459 | * @return string |
||
460 | */ |
||
461 | public function template_include($template_include_path = null) |
||
472 | |||
473 | |||
474 | /** |
||
475 | * get_selected_template |
||
476 | * |
||
477 | * @access public |
||
478 | * @param bool $with_path |
||
479 | * @return string |
||
480 | */ |
||
481 | public function get_selected_template($with_path = false) |
||
485 | |||
486 | |||
487 | |||
488 | /** |
||
489 | * @deprecated 4.9.26 |
||
490 | * @param string $shortcode_class |
||
491 | * @param \WP $wp |
||
492 | */ |
||
493 | public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
||
505 | |||
506 | } |
||
507 | // End of file EE_Front_Controller.core.php |
||
509 |