PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.0.13
Post Grid Gutenberg Blocks – PostX v5.0.13
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 5.0.13, at classes/Templates.php

62 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
9 namespace ULTP;
10
11 defined( 'ABSPATH' ) || exit;
12
13 /**
14 * Templates class.
15 *
16 * Handles template file inclusion and page template registration for Ultimate Post.
17 *
18 * @package ULTP\Templates
19 * @since v.1.0.0
20 */
21 class Templates {
22
23 /**
24 * Setup class.
25 *
26 * @since v.1.0.0
27 */
28 public function __construct() {
29 add_filter( 'template_include', array( $this, 'set_template_callback' ) );
30 add_filter( 'theme_page_templates', array( $this, 'add_template_callback' ) );
31 }
32
33 /**
34 * Include Template File
35 *
36 * @since v.1.0.0
37 * @param STRING $template Template file path.
38 * @return STRING Template file path.
39 */
40 public function set_template_callback( $template ) {
41 if ( is_singular() ) {
42 global $post;
43 if ( get_post_meta( $post->ID, '_wp_page_template', true ) === 'ultp_page_template' ) {
44 $template = ULTP_PATH . 'classes/template-without-title.php';
45 }
46 }
47 return $template;
48 }
49
50 /**
51 * Add a page template to the theme.
52 *
53 * @since v.1.0.0
54 * @param ARRAY $templates The page template list.
55 * @return ARRAY
56 */
57 public function add_template_callback( $templates ) {
58 $templates['ultp_page_template'] = __( 'PostX Template (Without Title)', 'ultimate-post' );
59 return $templates;
60 }
61 }
62