# my-wp/1.8/developer/modules/mywp.developer.module.dev.frontend.php

My WP Customize Admin/Frontend, version 1.8. 343 lines.

- Page: https://pluginprobe.com/plugins/my-wp/1.8/code/developer/modules/mywp.developer.module.dev.frontend.php
- Raw: https://pluginprobe.com/plugins/my-wp/1.8/raw/developer/modules/mywp.developer.module.dev.frontend.php
- Modified: 2018-08-09T07:14:58+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/my-wp/1.8/code/developer/modules/mywp.developer.module.dev.frontend.php#L10-L20`.

```php
<?php

if ( ! defined( 'ABSPATH' ) ) {
  exit;
}

if( ! class_exists( 'MywpDeveloperAbstractModule' ) ) {
  return false;
}

if ( ! class_exists( 'MywpDeveloperModuleDevFrontend' ) ) :

final class MywpDeveloperModuleDevFrontend extends MywpDeveloperAbstractModule {

  static protected $id = 'dev_frontend';

  static protected $priority = 20;

  static protected $find_templates = array();

  protected static function after_init() {

    $template_types = array(
      'embed',
      '404',
      'search',
      'frontpage',
      'home',
      'taxonomy',
      'attachment',
      'single',
      'page',
      'singular',
      'category',
      'tag',
      'author',
      'date',
      'archive',
      'index',
    );

    foreach( $template_types as $template_type ) {

      add_filter( "{$template_type}_template_hierarchy" , array( __CLASS__ , 'regist_template_hierarchy' ) , 100 );

    }

  }

  public static function regist_template_hierarchy( $templates ) {

    $find_templates = $templates;

    if( is_array( $find_templates ) ) {

      foreach( $find_templates as $find_template ) {

        self::$find_templates[] = $find_template;

      }

    }

    return $templates;

  }

  public static function mywp_debug_renders( $debug_renders ) {

    if( is_admin() ) {

      return $debug_renders;

    }

    $debug_renders[ self::$id ] = array(
      'debug_type' => 'dev',
      'title' => __( 'Current Frontend Information' , 'my-wp' ),
    );

    return $debug_renders;

  }

  protected static function get_debug_lists() {

    global $post;
    global $template;

    $debug_lists = array(
      'is_front_page()' => is_front_page(),
      'is_home()' => is_home(),
      'is_single()' => is_single(),
      'is_page()' => is_page(),
      'is_singular()' => is_singular(),
      'is_category()' => is_category(),
      'is_tag()' => is_tag(),
      'is_tax()' => is_tax(),
      'is_author()' => is_author(),
      'is_date()' => is_date(),
      'is_archive()' => is_archive(),
      'is_search()' => is_search(),
      'is_404()' => is_404(),
      'is_attachment()' => is_attachment(),
      'is_paged()' => is_paged(),
      'is_post_type_archive()' => is_post_type_archive(),
      'is_page_template()' => is_page_template(),
      'is_embed' => is_embed(),
      'is_main_query()' => is_main_query(),
      'is_preview()' => is_preview(),
    );

    $current_template = false;

    $all_templates = array();

    if( ! empty( self::$find_templates ) ) {

      foreach( self::$find_templates as $key => $find_template ) {

        if( empty( $find_template ) ) {

          continue;

        }

        $current_theme_template = STYLESHEETPATH . '/' . $find_template;
        $parent_theme_template = TEMPLATEPATH . '/' . $find_template;
        $wp_compat_template = ABSPATH . WPINC . '/theme-compat/' . $find_template;

        $all_templates[ $current_theme_template ] = array( 'found' => 0 );

        if( file_exists( $current_theme_template ) ) {

          $all_templates[ $current_theme_template ]['found'] = 1;

          if( empty( $current_template ) ) {

            $current_template = $current_theme_template;

          }

        }

        if( is_child_theme() ) {

          $all_templates[ $parent_theme_template ] = array( 'found' => 0 );

          if( file_exists( $parent_theme_template ) ) {

            $all_templates[ $parent_theme_template ]['found'] = 1;

            if( empty( $current_template ) ) {

              $current_template = $parent_theme_template;

            }

          }

        }

        $all_templates[ $wp_compat_template ] = array( 'found' => 0 );

        if( file_exists( $wp_compat_template ) ) {

          $all_templates[ $wp_compat_template ]['found'] = 1;

          if( empty( $current_template ) ) {

            $current_template = $wp_compat_template;

          }

        }

      }

    }

    $debug_lists['current_template'] = sprintf( '<strong>%s</strong> (%s)' , basename( $template ) , $current_template );

    $debug_lists['find_locate_templates'] = array();

    foreach( $all_templates as $template_file => $template_vals ) {

      $debug_lists['find_locate_templates'][ $template_file ] = $template_vals['found'];

    }

/*
    if( is_front_page() ) {

    } elseif( is_home() ) {

    } elseif( is_single() ) {

    } elseif( is_page() ) {

    } elseif( is_singular() ) {

    } elseif( is_category() ) {

    } elseif( is_tag() ) {

    } elseif( is_tax() ) {

    } elseif( is_author() ) {

    } elseif( is_date() ) {

    } elseif( is_archive() ) {

    } elseif( is_search() ) {

    } elseif( is_404() ) {

    } elseif( is_attachment() ) {

    } elseif( is_paged() ) {

    } elseif( is_post_type_archive() ) {

    } elseif( is_page_template() ) {

    } elseif( is_embed() ) {

    }
*/

    if( is_singular() ) {

      $debug_lists['post'] = $post;

      if( ! empty( $post ) && is_object( $post ) ) {

        $debug_lists['post_id'] = intval( $post->ID );
        $debug_lists['custom_fields'] = get_post_meta( $post->ID );

        $debug_lists['taxonomies'] = array();
        $debug_lists['terms'] = array();

        $post_taxonomies = get_post_taxonomies( $post->ID );

        if( ! empty( $post_taxonomies ) ) {

          foreach( $post_taxonomies as $taxonomy_name ) {

            $debug_lists['taxonomies'][ $taxonomy_name ] = false;
            $debug_lists['terms'][ $taxonomy_name ] = false;

            $taxonomy = get_taxonomy( $taxonomy_name );

            $terms = wp_get_post_terms( $post->ID , $taxonomy_name );

            if( empty( $taxonomy ) ) {

              continue;

            }

            $debug_lists['taxonomies'][ $taxonomy_name ] = $taxonomy;

            if( ! empty( $terms ) ) {

              $debug_lists['terms'][ $taxonomy_name ] = $terms;

            }

          }

        }

      }

      $debug_lists['get_permalink'] = esc_url( get_permalink( $post->ID ) );
      $debug_lists['get_page_link'] = esc_url( get_page_link( $post->ID ) );

    } elseif( is_archive() ) {

      if( is_category() or is_tag() or is_tax() ) {

        $term = get_queried_object();

        $debug_lists['term'] = $term;

        if( ! empty( $term ) && is_object( $term ) ) {

          $debug_lists['taxonomy'] = $term->taxonomy;
          $debug_lists['term_id'] = $term->term_id;
          $debug_lists['custom_meta'] = get_term_meta( $term->term_id );

        }

      } elseif( is_date() ) {

        $debug_lists['get_query_var("year")'] = get_query_var("year");
        $debug_lists['get_query_var("m")'] = get_query_var("m");
        $debug_lists['get_query_var("monthnum")'] = get_query_var("monthnum");
        $debug_lists['get_query_var("day")'] = get_query_var("day");

      }

    } elseif( is_search() ) {

      $debug_lists['get_search_query()'] = get_search_query();

    }

    return $debug_lists;

  }

  protected static function mywp_developer_debug() {

    if( is_admin() ) {

      return false;

    }

    parent::mywp_developer_debug();

  }

  protected static function mywp_debug_render() {

    if( is_admin() ) {

      return false;

    }

    parent::mywp_debug_render();

  }

}

MywpDeveloperModuleDevFrontend::init();

endif;

```
