PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.4.2
Post Grid Gutenberg Blocks – PostX v2.4.2
5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 2.1.2 All 237 releases
ultimate-post / classes / Templates.php

Templates.php in Post Grid Gutenberg Blocks – PostX 2.4.2, at classes/Templates.php

59 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Template Action.
4 *
5 * @package ULTP\Templates
6 * @since v.1.0.0
7 */
8 namespace ULTP;
9
10 defined('ABSPATH') || exit;
11
12 /**
13 * Templates class.
14 */
15 class Templates{
16
17 /**
18 * Setup class.
19 *
20 * @since v.1.0.0
21 */
22 public function __construct(){
23 add_filter( 'template_include', array($this, 'set_template_callback') );
24 $post_types = get_post_types();
25 if( !empty($post_types) ){
26 foreach ($post_types as $post_type){
27 add_filter( "theme_{$post_type}_templates", array( $this, 'add_template_callback' ) );
28 }
29 }
30 }
31
32 /**
33 * Include Template File
34 *
35 * @since v.1.0.0
36 * @param STRING | Attachment
37 * @return STRING | Template File Path
38 */
39 public function set_template_callback($template){
40 if ( is_singular() ) {
41 if ( get_post_meta( get_the_ID(), '_wp_page_template', true ) === 'ultp_page_template' ) {
42 $template = ULTP_PATH . 'classes/template-without-title.php';
43 }
44 }
45 return $template;
46 }
47
48 /**
49 * Add A Page Template
50 *
51 * @since v.1.0.0
52 * @param ARRAY | Page Template List
53 * @return ARRAY | Page Template List as Array
54 */
55 public function add_template_callback($templates){
56 $templates['ultp_page_template'] = __('PostX Template', 'ultimate-post');
57 return $templates;
58 }
59 }