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( |
||
103 | |||
104 | |||
105 | /** |
||
106 | * @return EE_Request_Handler |
||
107 | */ |
||
108 | public function Request_Handler() |
||
112 | |||
113 | |||
114 | /** |
||
115 | * @return EE_Module_Request_Router |
||
116 | */ |
||
117 | public function Module_Request_Router() |
||
121 | |||
122 | |||
123 | |||
124 | /** |
||
125 | * @return LegacyShortcodesManager |
||
126 | */ |
||
127 | public function getLegacyShortcodesManager() |
||
131 | |||
132 | |||
133 | |||
134 | |||
135 | |||
136 | /*********************************************** INIT ACTION HOOK ***********************************************/ |
||
137 | |||
138 | |||
139 | |||
140 | /** |
||
141 | * filter_wp_comments |
||
142 | * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
||
143 | * widgets/queries done on frontend |
||
144 | * |
||
145 | * @param array $clauses array of comment clauses setup by WP_Comment_Query |
||
146 | * @return array array of comment clauses with modifications. |
||
147 | */ |
||
148 | public function filter_wp_comments($clauses) |
||
159 | |||
160 | |||
161 | /** |
||
162 | * employ_CPT_Strategy |
||
163 | * |
||
164 | * @access public |
||
165 | * @return void |
||
166 | */ |
||
167 | public function employ_CPT_Strategy() |
||
173 | |||
174 | |||
175 | /** |
||
176 | * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
||
177 | * |
||
178 | * @param string $url incoming url |
||
179 | * @return string final assembled url |
||
180 | */ |
||
181 | public function maybe_force_admin_ajax_ssl($url) |
||
188 | |||
189 | |||
190 | |||
191 | |||
192 | |||
193 | |||
194 | /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
||
195 | |||
196 | |||
197 | /** |
||
198 | * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
||
199 | * default priority init phases have run |
||
200 | * |
||
201 | * @access public |
||
202 | * @return void |
||
203 | */ |
||
204 | public function wp_loaded() |
||
207 | |||
208 | |||
209 | |||
210 | |||
211 | |||
212 | /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
||
213 | /** |
||
214 | * _get_request |
||
215 | * |
||
216 | * @access public |
||
217 | * @param WP $WP |
||
218 | * @return void |
||
219 | */ |
||
220 | public function get_request(WP $WP) |
||
226 | |||
227 | |||
228 | |||
229 | /** |
||
230 | * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
||
231 | * |
||
232 | * @access public |
||
233 | * @param WP_Query $WP_Query |
||
234 | * @return void |
||
235 | */ |
||
236 | public function pre_get_posts($WP_Query) |
||
258 | |||
259 | |||
260 | |||
261 | |||
262 | |||
263 | /*********************************************** WP HOOK ***********************************************/ |
||
264 | |||
265 | |||
266 | /** |
||
267 | * wp - basically last chance to do stuff before headers sent |
||
268 | * |
||
269 | * @access public |
||
270 | * @return void |
||
271 | */ |
||
272 | public function wp() |
||
275 | |||
276 | |||
277 | |||
278 | /*********************** GET_HEADER && WP_HEAD HOOK ***********************/ |
||
279 | |||
280 | |||
281 | |||
282 | /** |
||
283 | * callback for the "template_redirect" hook point |
||
284 | * checks sidebars for EE widgets |
||
285 | * loads resources and assets accordingly |
||
286 | * |
||
287 | * @return void |
||
288 | */ |
||
289 | public function templateRedirect() |
||
304 | |||
305 | |||
306 | |||
307 | /** |
||
308 | * builds list of active widgets then scans active sidebars looking for them |
||
309 | * returns true is an EE widget is found in an active sidebar |
||
310 | * Please Note: this does NOT mean that the sidebar or widget |
||
311 | * is actually in use in a given template, as that is unfortunately not known |
||
312 | * until a sidebar and it's widgets are actually loaded |
||
313 | * |
||
314 | * @return boolean |
||
315 | */ |
||
316 | private function espresso_widgets_in_active_sidebars() |
||
339 | |||
340 | |||
341 | |||
342 | |||
343 | /** |
||
344 | * header_meta_tag |
||
345 | * |
||
346 | * @access public |
||
347 | * @return void |
||
348 | */ |
||
349 | public function header_meta_tag() |
||
375 | |||
376 | |||
377 | |||
378 | /** |
||
379 | * wp_print_scripts |
||
380 | * |
||
381 | * @return void |
||
382 | */ |
||
383 | public function wp_print_scripts() |
||
395 | |||
396 | |||
397 | |||
398 | public function enqueueStyle() |
||
403 | |||
404 | |||
405 | |||
406 | |||
407 | /*********************************************** THE_CONTENT FILTER HOOK ********************************************** |
||
408 | |||
409 | |||
410 | |||
411 | // /** |
||
412 | // * the_content |
||
413 | // * |
||
414 | // * @access public |
||
415 | // * @param $the_content |
||
416 | // * @return string |
||
417 | // */ |
||
418 | // public function the_content( $the_content ) { |
||
419 | // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
||
420 | // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
||
421 | // } |
||
422 | // return $the_content; |
||
423 | // } |
||
424 | |||
425 | |||
426 | |||
427 | /*********************************************** WP_FOOTER ***********************************************/ |
||
428 | |||
429 | |||
430 | |||
431 | public function enqueueScripts() |
||
435 | |||
436 | |||
437 | |||
438 | /** |
||
439 | * display_errors |
||
440 | * |
||
441 | * @access public |
||
442 | * @return void |
||
443 | * @throws DomainException |
||
444 | */ |
||
445 | public function display_errors() |
||
463 | |||
464 | |||
465 | |||
466 | |||
467 | |||
468 | /*********************************************** UTILITIES ***********************************************/ |
||
469 | /** |
||
470 | * template_include |
||
471 | * |
||
472 | * @access public |
||
473 | * @param string $template_include_path |
||
474 | * @return string |
||
475 | */ |
||
476 | public function template_include($template_include_path = null) |
||
487 | |||
488 | |||
489 | /** |
||
490 | * get_selected_template |
||
491 | * |
||
492 | * @access public |
||
493 | * @param bool $with_path |
||
494 | * @return string |
||
495 | */ |
||
496 | public function get_selected_template($with_path = false) |
||
500 | |||
501 | |||
502 | |||
503 | /** |
||
504 | * @deprecated 4.9.26 |
||
505 | * @param string $shortcode_class |
||
506 | * @param \WP $wp |
||
507 | */ |
||
508 | public function initialize_shortcode($shortcode_class = '', WP $wp = null) |
||
520 | |||
521 | } |
||
522 | // End of file EE_Front_Controller.core.php |
||
524 |