[wp-trac] [WordPress Trac] #14310: Make template hierarchy filterable

WordPress Trac noreply at wordpress.org
Wed Oct 21 19:25:34 UTC 2015


#14310: Make template hierarchy filterable
------------------------------+--------------------------
 Reporter:  scribu            |       Owner:  johnbillion
     Type:  enhancement       |      Status:  reviewing
 Priority:  normal            |   Milestone:  4.4
Component:  Themes            |     Version:
 Severity:  normal            |  Resolution:
 Keywords:  has-patch commit  |     Focuses:  template
------------------------------+--------------------------

Comment (by johnbillion):

 Example of a naïve JavaScript templating app class which wants to be able
 to access the page template hierarchy:

 {{{
 function __construct() {
         add_filter( 'page_template_hierarchy', array( $this,
 'log_page_template_hierarchy' ) );
         add_action( 'wp_footer',               array( $this,
 'output_page_template_hierarchy' ) );
 }

 public function log_page_template_hierarchy( array $templates ) {
         $this->page_templates = $templates;
         return $templates;
 }

 public function output_page_template_hierarchy() {
         ?>
         <script>
         var page_templates = <?php echo wp_json_encode(
 $this->page_templates ); ?>;
         </script>
         <?php
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/14310#comment:58>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list