PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 3.1.1
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v3.1.1
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
blockspare / inc / page-templates / module.php

module.php in BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites 3.1.1, at inc/page-templates/module.php

36 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 //Add our custom template to the admin's templates dropdown
3 add_filter( 'theme_page_templates', 'pluginname_template_as_option', 10, 3 );
4 function pluginname_template_as_option( $page_templates, $theme, $post ){
5
6 $page_templates['canvas.php'] = 'Blockspare Canvas';
7 $page_templates['full-width.php'] = 'Blockspare Full-Width';
8
9 return $page_templates;
10
11 }
12
13 //When our custom template has been chosen then display it for the page
14 add_filter( 'template_include', 'pluginname_load_template', 99 );
15 function pluginname_load_template( $template ) {
16
17 global $post;
18
19 if(isset($post)){
20
21 $canvas_template_slug = 'canvas.php';
22 $full_width_template_slug = 'full-width.php';
23 $page_template_slug = get_page_template_slug( $post->ID );
24
25 if( $page_template_slug == $canvas_template_slug ){
26 return BLOCKSPARE_PLUGIN_DIR . 'inc/page-templates/templates/' . $canvas_template_slug;
27 }
28
29 if( $page_template_slug == $full_width_template_slug ){
30 return BLOCKSPARE_PLUGIN_DIR . 'inc/page-templates/templates/' . $full_width_template_slug;
31 }
32
33 }
34 return $template;
35
36 }