PluginProbe
Property Hive / 1.4.53
Property Hive v1.4.53
2.3.0 2.2.6 2.2.5 2.2.4 2.2.3 2.2.2 1.4.46 1.4.47 1.4.48 1.4.49 1.4.5 1.4.50 1.4.51 1.4.52 1.4.53 1.4.54 1.4.55 1.4.56 1.4.57 1.4.58 1.4.59 1.4.6 1.4.60 1.4.61 1.4.62 All 260 releases
propertyhive / includes / class-ph-template-loader.php

class-ph-template-loader.php in Property Hive 1.4.53, at includes/class-ph-template-loader.php

71 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
5 /**
6 * Template Loader
7 *
8 * @class PH_Template_Loader
9 * @version 1.0.0
10 * @package PropertyHive/Classes
11 * @category Class
12 * @author PropertyHive
13 */
14 class PH_Template_Loader {
15
16 /**
17 * Constructor
18 */
19 public function __construct() {
20 add_filter( 'template_include', array( $this, 'template_loader' ) );
21 }
22
23 /**
24 * Load a template.
25 *
26 * Handles template usage so that we can use our own templates instead of the themes.
27 *
28 * Templates are in the 'templates' folder. propertyhive looks for theme
29 * overrides in /theme/propertyhive/ by default
30 *
31 * For beginners, it also looks for a propertyhive.php template first. If the user adds
32 * this to the theme (containing a propertyhive() inside) this will be used for all
33 * propertyhive templates.
34 *
35 * @param mixed $template
36 * @return string
37 */
38 public function template_loader( $template ) {
39
40 $find = array( 'propertyhive.php' );
41 $file = '';
42
43 if ( is_single() && get_post_type() == 'property' ) {
44
45 $file = 'single-property.php';
46 $find[] = $file;
47 $find[] = PH_TEMPLATE_PATH . $file;
48
49
50 } elseif ( is_post_type_archive( 'property' ) || is_page( ph_get_page_id( 'search_results' ) ) ) {
51
52 $file = 'archive-property.php';
53 $find[] = $file;
54 $find[] = PH_TEMPLATE_PATH . $file;
55
56 }
57
58 if ( $file ) {
59 $template = locate_template( array_unique($find) );
60 if ( ! $template )
61 $template = PH()->plugin_path() . '/templates/' . $file;
62 }
63
64 $template = apply_filters( 'propertyhive_loaded_template', $template );
65
66 return $template;
67 }
68
69 }
70
71 new PH_Template_Loader();