|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Templated Shortcode Implementation. |
|
4
|
|
|
* |
|
5
|
|
|
* This version of the shortcode uses Gamajo/TemplateLoader to let you override |
|
6
|
|
|
* the shortcode views from your theme. |
|
7
|
|
|
* |
|
8
|
|
|
* @see https://github.com/gamajo/TemplateLoader |
|
9
|
|
|
* |
|
10
|
|
|
* @package BrightNucleus\Shortcode |
|
11
|
|
|
* @author Alain Schlesser <[email protected]> |
|
12
|
|
|
* @license GPL-2.0+ |
|
13
|
|
|
* @link http://www.brightnucleus.com/ |
|
14
|
|
|
* @copyright 2015-2016 Alain Schlesser, Bright Nucleus |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace BrightNucleus\Shortcode; |
|
18
|
|
|
|
|
19
|
|
|
use Gamajo_Template_Loader; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Class ShortcodeTemplateLoader. |
|
23
|
|
|
* |
|
24
|
|
|
* @since 0.2.6 |
|
25
|
|
|
* |
|
26
|
|
|
* @package BrightNucleus\Shortcode |
|
27
|
|
|
* @author Alain Schlesser <[email protected]> |
|
28
|
|
|
*/ |
|
29
|
|
|
class ShortcodeTemplateLoader extends Gamajo_Template_Loader { |
|
30
|
|
|
|
|
31
|
|
|
/** |
|
32
|
|
|
* Directory name of the shortcode views. |
|
33
|
|
|
* |
|
34
|
|
|
* @var string |
|
35
|
|
|
* |
|
36
|
|
|
* @since 0.2.6 |
|
37
|
|
|
*/ |
|
38
|
|
|
protected $view_directory; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* Instantiate a ShortcodeTemplateLoader object. |
|
42
|
|
|
* |
|
43
|
|
|
* @since 0.2.6 |
|
44
|
|
|
* |
|
45
|
|
|
* @param string $filter_prefix Prefix for filter names. |
|
46
|
|
|
* @param string $template_dir Directory name for custom templates. |
|
47
|
|
|
* @param string $view_dir Directory name for the shortcode views. |
|
48
|
|
|
*/ |
|
49
|
|
|
public function __construct( $filter_prefix, $template_dir, $view_dir ) { |
|
50
|
|
|
$this->filter_prefix = $filter_prefix; |
|
51
|
|
|
$this->theme_template_directory = $template_dir; |
|
52
|
|
|
$this->view_directory = $view_dir; |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Return the path to the templates directory in this plugin. |
|
57
|
|
|
* |
|
58
|
|
|
* @since 0.2.6 |
|
59
|
|
|
* |
|
60
|
|
|
* @return string |
|
61
|
|
|
*/ |
|
62
|
|
|
protected function get_templates_dir() { |
|
63
|
|
|
return $this->view_directory; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|