PluginProbe
My WP Customize Admin/Frontend / 1.14
My WP Customize Admin/Frontend v1.14
1.27.4 1.27.3 trunk 1.0 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.10 1.10.1 1.10.2 1.11 1.12 1.12.1 1.12.2 1.13 1.13.1 1.13.2 1.14 1.15.0 1.16 1.17.0 All 76 releases
my-wp / developer / modules / mywp.developer.module.dev.frontend.php

mywp.developer.module.dev.frontend.php in My WP Customize Admin/Frontend 1.14, at developer/modules/mywp.developer.module.dev.frontend.php

636 lines 14.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 if( ! class_exists( 'MywpDeveloperAbstractModule' ) ) {
8 return false;
9 }
10
11 if ( ! class_exists( 'MywpDeveloperModuleDevFrontend' ) ) :
12
13 final class MywpDeveloperModuleDevFrontend extends MywpDeveloperAbstractModule {
14
15 static protected $id = 'dev_frontend';
16
17 static protected $priority = 20;
18
19 static protected $find_templates = array();
20
21 static protected $header_templates = array();
22
23 static protected $sidebar_templates = array();
24
25 static protected $footer_templates = array();
26
27 protected static function after_init() {
28
29 $template_types = array(
30 'embed',
31 '404',
32 'search',
33 'frontpage',
34 'home',
35 'taxonomy',
36 'attachment',
37 'single',
38 'page',
39 'singular',
40 'category',
41 'tag',
42 'author',
43 'date',
44 'archive',
45 'index',
46 );
47
48 foreach( $template_types as $template_type ) {
49
50 add_filter( "{$template_type}_template_hierarchy" , array( __CLASS__ , 'regist_template_hierarchy' ) , 100 );
51
52 }
53
54 add_action( 'get_header' , array( __CLASS__ , 'regist_header_templates' ) , 100 );
55
56 add_action( 'get_sidebar' , array( __CLASS__ , 'regist_sidebar_templates' ) , 100 );
57
58 add_action( 'get_footer' , array( __CLASS__ , 'regist_footer_templates' ) , 100 );
59
60 }
61
62 public static function regist_template_hierarchy( $templates ) {
63
64 $find_templates = $templates;
65
66 if( is_array( $find_templates ) ) {
67
68 foreach( $find_templates as $find_template ) {
69
70 self::$find_templates[] = $find_template;
71
72 }
73
74 }
75
76 return $templates;
77
78 }
79
80 public static function regist_header_templates( $name ) {
81
82 $name = (string) $name;
83
84 if ( '' !== $name ) {
85
86 self::$header_templates[] = "header-{$name}.php";
87
88 }
89
90 self::$header_templates[] = 'header.php';
91
92 }
93
94 public static function regist_sidebar_templates( $name ) {
95
96 $name = (string) $name;
97
98 if ( '' !== $name ) {
99
100 self::$sidebar_templates[] = "sidebar-{$name}.php";
101
102 }
103
104 self::$sidebar_templates[] = 'sidebar.php';
105
106 }
107
108 public static function regist_footer_templates( $name ) {
109
110 $name = (string) $name;
111
112 if ( '' !== $name ) {
113
114 self::$footer_templates[] = "footer-{$name}.php";
115
116 }
117
118 self::$footer_templates[] = 'footer.php';
119
120 }
121
122 public static function mywp_debug_renders( $debug_renders ) {
123
124 if( is_admin() ) {
125
126 return $debug_renders;
127
128 }
129
130 $debug_renders[ self::$id ] = array(
131 'debug_type' => 'dev',
132 'title' => __( 'Current Frontend Information' , 'my-wp' ),
133 );
134
135 return $debug_renders;
136
137 }
138
139 protected static function get_debug_lists() {
140
141 global $wpdb;
142 global $post;
143 global $template;
144
145 $debug_lists = array(
146 'is_front_page()' => is_front_page(),
147 'is_home()' => is_home(),
148 'is_single()' => is_single(),
149 'is_page()' => is_page(),
150 'is_singular()' => is_singular(),
151 'is_category()' => is_category(),
152 'is_tag()' => is_tag(),
153 'is_tax()' => is_tax(),
154 'is_author()' => is_author(),
155 'is_date()' => is_date(),
156 'is_archive()' => is_archive(),
157 'is_search()' => is_search(),
158 'is_404()' => is_404(),
159 'is_attachment()' => is_attachment(),
160 'is_paged()' => is_paged(),
161 'is_post_type_archive()' => is_post_type_archive(),
162 'is_page_template()' => is_page_template(),
163 'is_embed' => is_embed(),
164 'is_main_query()' => is_main_query(),
165 'is_preview()' => is_preview(),
166 );
167
168 $current_template = false;
169
170 $all_templates = array();
171
172 if( ! empty( self::$find_templates ) ) {
173
174 foreach( self::$find_templates as $key => $find_template ) {
175
176 if( empty( $find_template ) ) {
177
178 continue;
179
180 }
181
182 $current_theme_template = STYLESHEETPATH . '/' . $find_template;
183 $parent_theme_template = TEMPLATEPATH . '/' . $find_template;
184 $wp_compat_template = ABSPATH . WPINC . '/theme-compat/' . $find_template;
185
186 $all_templates[ $current_theme_template ] = array( 'found' => 0 );
187
188 if( file_exists( $current_theme_template ) ) {
189
190 $all_templates[ $current_theme_template ]['found'] = 1;
191
192 if( empty( $current_template ) ) {
193
194 $current_template = $current_theme_template;
195
196 }
197
198 }
199
200 if( is_child_theme() ) {
201
202 $all_templates[ $parent_theme_template ] = array( 'found' => 0 );
203
204 if( file_exists( $parent_theme_template ) ) {
205
206 $all_templates[ $parent_theme_template ]['found'] = 1;
207
208 if( empty( $current_template ) ) {
209
210 $current_template = $parent_theme_template;
211
212 }
213
214 }
215
216 }
217
218 $all_templates[ $wp_compat_template ] = array( 'found' => 0 );
219
220 if( file_exists( $wp_compat_template ) ) {
221
222 $all_templates[ $wp_compat_template ]['found'] = 1;
223
224 if( empty( $current_template ) ) {
225
226 $current_template = $wp_compat_template;
227
228 }
229
230 }
231
232 }
233
234 }
235
236 $debug_lists['current_template'] = sprintf( '<strong>%s</strong> (%s)' , basename( $template ) , $current_template );
237
238 $debug_lists['find_locate_templates'] = array();
239
240 foreach( $all_templates as $template_file => $template_vals ) {
241
242 $debug_lists['find_locate_templates'][ $template_file ] = $template_vals['found'];
243
244 }
245
246 $current_header_template = false;
247
248 $all_header_templates = array();
249
250 if( ! empty( self::$header_templates ) ) {
251
252 foreach( self::$header_templates as $key => $find_header_template ) {
253
254 if( empty( $find_header_template ) ) {
255
256 continue;
257
258 }
259
260 $current_theme_header_template = STYLESHEETPATH . '/' . $find_header_template;
261 $parent_theme_header_template = TEMPLATEPATH . '/' . $find_header_template;
262 $wp_compat_header_template = ABSPATH . WPINC . '/theme-compat/' . $find_header_template;
263
264 $all_header_templates[ $current_theme_header_template ] = array( 'found' => 0 );
265
266 if( file_exists( $current_theme_header_template ) ) {
267
268 $all_header_templates[ $current_theme_header_template ]['found'] = 1;
269
270 if( empty( $current_header_template ) ) {
271
272 $current_header_template = $current_theme_header_template;
273
274 }
275
276 }
277
278 if( is_child_theme() ) {
279
280 $all_header_templates[ $parent_theme_header_template ] = array( 'found' => 0 );
281
282 if( file_exists( $parent_theme_header_template ) ) {
283
284 $all_header_templates[ $parent_theme_header_template ]['found'] = 1;
285
286 if( empty( $current_header_template ) ) {
287
288 $current_header_template = $parent_theme_header_template;
289
290 }
291
292 }
293
294 }
295
296 $all_header_templates[ $wp_compat_header_template ] = array( 'found' => 0 );
297
298 if( file_exists( $wp_compat_header_template ) ) {
299
300 $all_header_templates[ $wp_compat_header_template ]['found'] = 1;
301
302 if( empty( $current_header_template ) ) {
303
304 $current_header_template = $wp_compat_header_template;
305
306 }
307
308 }
309
310 }
311
312 }
313
314 $debug_lists['current_header_template'] = sprintf( '<strong>%s</strong> (%s)' , basename( $current_header_template ) , $current_header_template );
315
316 $debug_lists['find_locate_header_templates'] = array();
317
318 foreach( $all_header_templates as $template_file => $template_vals ) {
319
320 $debug_lists['find_locate_header_templates'][ $template_file ] = $template_vals['found'];
321
322 }
323
324 $current_sidebar_template = false;
325
326 $all_sidebar_templates = array();
327
328 if( ! empty( self::$sidebar_templates ) ) {
329
330 foreach( self::$sidebar_templates as $key => $find_sidebar_template ) {
331
332 if( empty( $find_sidebar_template ) ) {
333
334 continue;
335
336 }
337
338 $current_theme_sidebar_template = STYLESHEETPATH . '/' . $find_sidebar_template;
339 $parent_theme_sidebar_template = TEMPLATEPATH . '/' . $find_sidebar_template;
340 $wp_compat_sidebar_template = ABSPATH . WPINC . '/theme-compat/' . $find_sidebar_template;
341
342 $all_sidebar_templates[ $current_theme_sidebar_template ] = array( 'found' => 0 );
343
344 if( file_exists( $current_theme_sidebar_template ) ) {
345
346 $all_sidebar_templates[ $current_theme_sidebar_template ]['found'] = 1;
347
348 if( empty( $current_sidebar_template ) ) {
349
350 $current_sidebar_template = $current_theme_sidebar_template;
351
352 }
353
354 }
355
356 if( is_child_theme() ) {
357
358 $all_sidebar_templates[ $parent_theme_sidebar_template ] = array( 'found' => 0 );
359
360 if( file_exists( $parent_theme_sidebar_template ) ) {
361
362 $all_sidebar_templates[ $parent_theme_sidebar_template ]['found'] = 1;
363
364 if( empty( $current_sidebar_template ) ) {
365
366 $current_sidebar_template = $parent_theme_sidebar_template;
367
368 }
369
370 }
371
372 }
373
374 $all_sidebar_templates[ $wp_compat_sidebar_template ] = array( 'found' => 0 );
375
376 if( file_exists( $wp_compat_sidebar_template ) ) {
377
378 $all_sidebar_templates[ $wp_compat_sidebar_template ]['found'] = 1;
379
380 if( empty( $current_sidebar_template ) ) {
381
382 $current_sidebar_template = $wp_compat_sidebar_template;
383
384 }
385
386 }
387
388 }
389
390 }
391
392 $debug_lists['current_sidebar_template'] = sprintf( '<strong>%s</strong> (%s)' , basename( $current_sidebar_template ) , $current_sidebar_template );
393
394 $debug_lists['find_locate_sidebar_templates'] = array();
395
396 foreach( $all_sidebar_templates as $template_file => $template_vals ) {
397
398 $debug_lists['find_locate_sidebar_templates'][ $template_file ] = $template_vals['found'];
399
400 }
401
402 $current_footer_template = false;
403
404 $all_footer_templates = array();
405
406 if( ! empty( self::$footer_templates ) ) {
407
408 foreach( self::$footer_templates as $key => $find_footer_template ) {
409
410 if( empty( $find_footer_template ) ) {
411
412 continue;
413
414 }
415
416 $current_theme_footer_template = STYLESHEETPATH . '/' . $find_footer_template;
417 $parent_theme_footer_template = TEMPLATEPATH . '/' . $find_footer_template;
418 $wp_compat_footer_template = ABSPATH . WPINC . '/theme-compat/' . $find_footer_template;
419
420 $all_footer_templates[ $current_theme_footer_template ] = array( 'found' => 0 );
421
422 if( file_exists( $current_theme_footer_template ) ) {
423
424 $all_footer_templates[ $current_theme_footer_template ]['found'] = 1;
425
426 if( empty( $current_footer_template ) ) {
427
428 $current_footer_template = $current_theme_footer_template;
429
430 }
431
432 }
433
434 if( is_child_theme() ) {
435
436 $all_footer_templates[ $parent_theme_footer_template ] = array( 'found' => 0 );
437
438 if( file_exists( $parent_theme_footer_template ) ) {
439
440 $all_footer_templates[ $parent_theme_footer_template ]['found'] = 1;
441
442 if( empty( $current_footer_template ) ) {
443
444 $current_footer_template = $parent_theme_footer_template;
445
446 }
447
448 }
449
450 }
451
452 $all_footer_templates[ $wp_compat_footer_template ] = array( 'found' => 0 );
453
454 if( file_exists( $wp_compat_footer_template ) ) {
455
456 $all_footer_templates[ $wp_compat_footer_template ]['found'] = 1;
457
458 if( empty( $current_footer_template ) ) {
459
460 $current_footer_template = $wp_compat_footer_template;
461
462 }
463
464 }
465
466 }
467
468 }
469
470 $debug_lists['current_footer_template'] = sprintf( '<strong>%s</strong> (%s)' , basename( $current_footer_template ) , $current_footer_template );
471
472 $debug_lists['find_locate_footer_templates'] = array();
473
474 foreach( $all_footer_templates as $template_file => $template_vals ) {
475
476 $debug_lists['find_locate_footer_templates'][ $template_file ] = $template_vals['found'];
477
478 }
479
480 /*
481 if( is_front_page() ) {
482
483 } elseif( is_home() ) {
484
485 } elseif( is_single() ) {
486
487 } elseif( is_page() ) {
488
489 } elseif( is_singular() ) {
490
491 } elseif( is_category() ) {
492
493 } elseif( is_tag() ) {
494
495 } elseif( is_tax() ) {
496
497 } elseif( is_author() ) {
498
499 } elseif( is_date() ) {
500
501 } elseif( is_archive() ) {
502
503 } elseif( is_search() ) {
504
505 } elseif( is_404() ) {
506
507 } elseif( is_attachment() ) {
508
509 } elseif( is_paged() ) {
510
511 } elseif( is_post_type_archive() ) {
512
513 } elseif( is_page_template() ) {
514
515 } elseif( is_embed() ) {
516
517 }
518 */
519
520 if( is_singular() ) {
521
522 $debug_lists['post'] = $post;
523
524 if( ! empty( $post ) && is_object( $post ) ) {
525
526 $debug_lists['post_id'] = intval( $post->ID );
527 $debug_lists['custom_fields'] = get_post_meta( $post->ID );
528
529 $debug_lists['taxonomies'] = array();
530 $debug_lists['terms'] = array();
531
532 $post_taxonomies = get_post_taxonomies( $post->ID );
533
534 if( ! empty( $post_taxonomies ) ) {
535
536 foreach( $post_taxonomies as $taxonomy_name ) {
537
538 $debug_lists['taxonomies'][ $taxonomy_name ] = false;
539 $debug_lists['terms'][ $taxonomy_name ] = false;
540
541 $taxonomy = get_taxonomy( $taxonomy_name );
542
543 $terms = wp_get_post_terms( $post->ID , $taxonomy_name );
544
545 if( empty( $taxonomy ) ) {
546
547 continue;
548
549 }
550
551 $debug_lists['taxonomies'][ $taxonomy_name ] = $taxonomy;
552
553 if( ! empty( $terms ) ) {
554
555 $debug_lists['terms'][ $taxonomy_name ] = $terms;
556
557 }
558
559 }
560
561 }
562
563 $debug_lists['get_post( ' . $post->ID . ' )'] = get_post( $post->ID );
564 $debug_lists['MywpPostType::get_post( ' . $post->ID . ' )'] = MywpPostType::get_post( $post->ID );
565 $debug_lists['SELECT * FROM $wpdb->posts WHERE ID = ' . $post->ID] = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", $post->ID ) );
566
567 }
568
569 $debug_lists['get_permalink'] = esc_url( get_permalink( $post->ID ) );
570 $debug_lists['get_page_link'] = esc_url( get_page_link( $post->ID ) );
571
572 } elseif( is_archive() ) {
573
574 if( is_category() or is_tag() or is_tax() ) {
575
576 $term = get_queried_object();
577
578 $debug_lists['term'] = $term;
579
580 if( ! empty( $term ) && is_object( $term ) ) {
581
582 $debug_lists['taxonomy'] = $term->taxonomy;
583 $debug_lists['term_id'] = $term->term_id;
584 $debug_lists['custom_meta'] = get_term_meta( $term->term_id );
585
586 }
587
588 } elseif( is_date() ) {
589
590 $debug_lists['get_query_var("year")'] = get_query_var("year");
591 $debug_lists['get_query_var("m")'] = get_query_var("m");
592 $debug_lists['get_query_var("monthnum")'] = get_query_var("monthnum");
593 $debug_lists['get_query_var("day")'] = get_query_var("day");
594
595 }
596
597 } elseif( is_search() ) {
598
599 $debug_lists['get_search_query()'] = get_search_query();
600
601 }
602
603 return $debug_lists;
604
605 }
606
607 protected static function mywp_developer_debug() {
608
609 if( is_admin() ) {
610
611 return false;
612
613 }
614
615 parent::mywp_developer_debug();
616
617 }
618
619 protected static function mywp_debug_render() {
620
621 if( is_admin() ) {
622
623 return false;
624
625 }
626
627 parent::mywp_debug_render();
628
629 }
630
631 }
632
633 MywpDeveloperModuleDevFrontend::init();
634
635 endif;
636