PluginProbe
Post Grid Gutenberg Blocks – PostX / 4.0.0
Post Grid Gutenberg Blocks – PostX v4.0.0
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 4.0.0, at classes/Templates.php

55 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 add_filter( 'theme_page_templates', array( $this, 'add_template_callback' ) );
25 }
26
27 /**
28 * Include Template File
29 *
30 * @since v.1.0.0
31 * @param STRING | Attachment
32 * @return STRING | Template File Path
33 */
34 public function set_template_callback( $template ) {
35 if ( is_singular() ) {
36 global $post;
37 if ( get_post_meta( $post->ID, '_wp_page_template', true ) === 'ultp_page_template' ) {
38 $template = ULTP_PATH . 'classes/template-without-title.php';
39 }
40 }
41 return $template;
42 }
43
44 /**
45 * Add A Page Template
46 *
47 * @since v.1.0.0
48 * @param ARRAY | Page Template List
49 * @return ARRAY | Page Template List as Array
50 */
51 public function add_template_callback( $templates ) {
52 $templates['ultp_page_template'] = __( 'PostX Template (Without Title)', 'ultimate-post' );
53 return $templates;
54 }
55 }