-
-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathclass.cf7-helpers.php
45 lines (36 loc) · 1.41 KB
/
class.cf7-helpers.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
* Class helpers
* @version 1.0
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
class QS_CF7_helpers{
/**
* Get template part function that will get the required templates files
* @param [string] $slug [the file slug]
* @param string $name [the name of the tempate]
* @version 1.0
*/
public static function qs_get_template_part( $slug, $name = '' ) {
$template = '';
if ( $name ) {
$template = locate_template( array( "{$slug}-{$name}.php", QS_CF7_API_TEMPLATE_PATH . "{$slug}-{$name}.php" ) );
}
if ( ! $template && $name && file_exists( QS_CF7_API_TEMPLATE_PATH . "/templates/{$slug}-{$name}.php" ) ) {
$template = locate_template( array( "{$slug}-{$name}.php", QS_CF7_API_TEMPLATE_PATH . "/templates/{$slug}-{$name}.php" ) );
}
if ( ! $template && $name && file_exists( QS_WL_PLUGIN_PATH . "/templates/{$slug}-{$name}.php" ) ) {
$template = QS_WL_PLUGIN_PATH . "/templates/{$slug}-{$name}.php";
}
if ( ! $template ) {
$template = locate_template( array( "{$slug}.php", QS_WL_TEMPLATE_PATH . "{$slug}.php" ) );
}
$template = apply_filters( 'qs_get_template_part', $template, $slug, $name );
if ( $template ) {
load_template( $template, false );
}
}
}