removing forced template structure
authorAnthony Talarico <talarico@gaslightmedia.com>
Fri, 19 May 2017 13:04:14 +0000 (09:04 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Fri, 19 May 2017 13:04:14 +0000 (09:04 -0400)
wp 4.7 doesn't support the pseudo template structure, need to use actual template files for the
update

capstone-team.php [new file with mode: 0644]
full-width.php [new file with mode: 0644]
functions.php
members-only.php [new file with mode: 0644]
partners-blocks.php [new file with mode: 0644]
sections/interior-page.php

diff --git a/capstone-team.php b/capstone-team.php
new file mode 100644 (file)
index 0000000..e6145e9
--- /dev/null
@@ -0,0 +1,5 @@
+<?php 
+/*
+    Template Name:Capstone Team
+*/
+get_template_part('index');
\ No newline at end of file
diff --git a/full-width.php b/full-width.php
new file mode 100644 (file)
index 0000000..d7c2b3a
--- /dev/null
@@ -0,0 +1,5 @@
+<?php 
+/*
+    Template Name: Full Width
+*/
+get_template_part('index');
\ No newline at end of file
index 54dd9be..cc80c47 100644 (file)
@@ -153,66 +153,66 @@ add_action('thematic_searchloop', 'mytheme_search_loop');
 
 // This series of functions is used for forcing a template if one or any is picked.
 // START FORCE TEMPLATE FUNCTIONS
-add_filter( 'template_include', 'glm_force_template', 99 );
-function glm_force_template( $template ) {
-    if ($template != locate_template("woocommerce.php")) {
-        $template = locate_template( "index.php" );
-    }
-    return $template;
-}
-function get_custom_page_templates() {
-    $templates = array();
-    // maybe by options? --> $templates = get_option( 'custom_page_templates' );
-    // maybe by conf file? --> $templates = include 'custom_page_templates.php';
-    return apply_filters( 'custom_page_templates', $templates );
-}
-add_action( 'edit_form_after_editor', 'custom_page_templates_init' );
-add_action( 'load-post.php', 'custom_page_templates_init_post' );
-add_action( 'load-post-new.php', 'custom_page_templates_init_post' );
-
-function custom_page_templates_init() {
-    remove_action( current_filter(), __FUNCTION__ );
-    if ( is_admin() && get_current_screen()->post_type === 'page' ) {
-        $templates = get_custom_page_templates(); // the function above
-        if ( ! empty( $templates ) )  {
-            set_custom_page_templates( $templates );
-        }
-    }
-}
-function custom_page_templates_init_post() {
-    remove_action( current_filter(), __FUNCTION__ );
-    $method = filter_input( INPUT_SERVER, 'REQUEST_METHOD', FILTER_SANITIZE_STRING );
-    if ( empty( $method ) || strtoupper( $method ) !== 'POST' ) return;
-    if ( get_current_screen()->post_type === 'page' ) {
-        custom_page_templates_init();
-    }
-}
-function set_custom_page_templates( $templates = array() ) {
-    if ( ! is_array( $templates ) || empty( $templates ) ) return;
-    $core = array_flip( (array) get_page_templates() ); // templates defined by file
-    $data = array_filter( array_merge( $core, $templates ) );
-    ksort( $data );
-    $stylesheet = get_stylesheet();
-    $hash = md5( get_theme_root( $stylesheet ) . '/' . $stylesheet );
-    $persistently = apply_filters( 'wp_cache_themes_persistently', false, 'WP_Theme' );
-    $exp = is_int( $persistently ) ? $persistently : 1800;
-    wp_cache_set( 'page_templates-' . $hash, $data, 'themes', $exp );
-}
-add_filter( 'custom_page_templates', function( $now_templates ) {
-    // Any slug->name pairs down here will be selectable in the admin side of
-    // a page. You do not need to create a new template file. You can refer to
-    // this template by its slug in our index.php using get_page_template_slug
-    // Below are some commented examples of custom quasi-templates.
-    $templates = array(
-       'partners-blocks' => 'Partners Page Blocks',
-       'members-only'    => 'Members Only',
-       'capstone-team'    => 'Capstone Team',
-       'full-width'       => 'Full Width'
-    //    'any-template-slug' => 'Sample Template' ,
-    );
-
-    return array_merge( $now_templates, $templates );
-} );
+//add_filter( 'template_include', 'glm_force_template', 99 );
+//function glm_force_template( $template ) {
+//    if ($template != locate_template("woocommerce.php")) {
+//        $template = locate_template( "index.php" );
+//    }
+//    return $template;
+//}
+//function get_custom_page_templates() {
+//    $templates = array();
+//    // maybe by options? --> $templates = get_option( 'custom_page_templates' );
+//    // maybe by conf file? --> $templates = include 'custom_page_templates.php';
+//    return apply_filters( 'custom_page_templates', $templates );
+//}
+//add_action( 'edit_form_after_editor', 'custom_page_templates_init' );
+//add_action( 'load-post.php', 'custom_page_templates_init_post' );
+//add_action( 'load-post-new.php', 'custom_page_templates_init_post' );
+//
+//function custom_page_templates_init() {
+//    remove_action( current_filter(), __FUNCTION__ );
+//    if ( is_admin() && get_current_screen()->post_type === 'page' ) {
+//        $templates = get_custom_page_templates(); // the function above
+//        if ( ! empty( $templates ) )  {
+//            set_custom_page_templates( $templates );
+//        }
+//    }
+//}
+//function custom_page_templates_init_post() {
+//    remove_action( current_filter(), __FUNCTION__ );
+//    $method = filter_input( INPUT_SERVER, 'REQUEST_METHOD', FILTER_SANITIZE_STRING );
+//    if ( empty( $method ) || strtoupper( $method ) !== 'POST' ) return;
+//    if ( get_current_screen()->post_type === 'page' ) {
+//        custom_page_templates_init();
+//    }
+//}
+//function set_custom_page_templates( $templates = array() ) {
+//    if ( ! is_array( $templates ) || empty( $templates ) ) return;
+//    $core = array_flip( (array) get_page_templates() ); // templates defined by file
+//    $data = array_filter( array_merge( $core, $templates ) );
+//    ksort( $data );
+//    $stylesheet = get_stylesheet();
+//    $hash = md5( get_theme_root( $stylesheet ) . '/' . $stylesheet );
+//    $persistently = apply_filters( 'wp_cache_themes_persistently', false, 'WP_Theme' );
+//    $exp = is_int( $persistently ) ? $persistently : 1800;
+//    wp_cache_set( 'page_templates-' . $hash, $data, 'themes', $exp );
+//}
+//add_filter( 'custom_page_templates', function( $now_templates ) {
+//    // Any slug->name pairs down here will be selectable in the admin side of
+//    // a page. You do not need to create a new template file. You can refer to
+//    // this template by its slug in our index.php using get_page_template_slug
+//    // Below are some commented examples of custom quasi-templates.
+//    $templates = array(
+//       'partners-blocks' => 'Partners Page Blocks',
+//       'members-only'    => 'Members Only',
+//       'capstone-team'    => 'Capstone Team',
+//       'full-width'       => 'Full Width'
+//    //    'any-template-slug' => 'Sample Template' ,
+//    );
+//
+//    return array_merge( $now_templates, $templates );
+//} );
 // END FORCE TEMPLATE FUNCTIONS
 
 
diff --git a/members-only.php b/members-only.php
new file mode 100644 (file)
index 0000000..59ae62c
--- /dev/null
@@ -0,0 +1,5 @@
+<?php 
+/*
+    Template Name: Members Only 
+*/
+get_template_part('index');
\ No newline at end of file
diff --git a/partners-blocks.php b/partners-blocks.php
new file mode 100644 (file)
index 0000000..f6145dc
--- /dev/null
@@ -0,0 +1,5 @@
+<?php 
+/*
+    Template Name: Partners Blocks
+*/
+get_template_part('index');
\ No newline at end of file
index 7d72c42..7ab1f9b 100644 (file)
@@ -1,5 +1,5 @@
 <main class="page-inside">
-    <?php if (get_page_template_slug( $post->ID ) == "partners-blocks") { ?>
+    <?php if (get_page_template_slug( $post->ID ) == "partners-blocks.php") { ?>
         <div id="content-wrapper" class="partners-page-wrapper">
     <?php } else { ?>
         <div id="content-wrapper">
@@ -16,7 +16,7 @@
         <?php $post_content = get_post($post->ID); ?>
         <div class="row">
             <!-- check for partners page template -->
-            <?php if (get_page_template_slug( $post->ID ) == "partners-blocks") { ?>
+            <?php if (get_page_template_slug( $post->ID ) == "partners-blocks.php") { ?>
                    
                     <?php $index_template = false; ?>
                     <?php echo apply_filters('the_content', $post_content->post_content) ; ?>
@@ -26,7 +26,7 @@
                     <?php get_template_part('parts/glm-blocks'); ?>
                    
             <!-- check for members only template -->
-            <?php } else if (get_page_template_slug( $post->ID ) == "members-only") { ?>
+            <?php } else if (get_page_template_slug( $post->ID ) == "members-only.php") { ?>
     
                     <?php $index_template = false; ?>
                           <div class="medium-3 columns members-only-menu show-for-large">
                             <?php echo apply_filters('the_content', $post_content->post_content) ; ?>
                          </div>
             <!-- check for full width template -->
-            <?php } else if (get_page_template_slug( $post->ID ) == "full-width") { ?>
+            <?php } else if (get_page_template_slug( $post->ID ) == "full-width.php") { ?>
                     <div class="small-12 columns">
                         <?php echo apply_filters('the_content', $post_content->post_content) ; ?>
                     </div>
-            <?php } else if (get_page_template_slug( $post->ID ) == "capstone-team") { ?>
+            <?php } else if (get_page_template_slug( $post->ID ) == "capstone-team.php") { ?>
                     <div class="small-12 columns">
                         <?php get_template_part('parts/capstone-team'); ?>
                         <?php echo apply_filters('the_content', $post_content->post_content) ; ?>