1 | <?php |
||
7 | abstract class Shortcode |
||
8 | { |
||
9 | /** |
||
10 | * The attributes passed to the shortcode |
||
11 | * @var array |
||
12 | */ |
||
13 | protected $attributes; |
||
14 | |||
15 | /** |
||
16 | * The enclosed content within the shortcode |
||
17 | * @var string |
||
18 | */ |
||
19 | protected $content; |
||
20 | |||
21 | /** |
||
22 | * The shortcode tag that was called |
||
23 | * @var string |
||
24 | */ |
||
25 | protected $tag; |
||
26 | |||
27 | /** |
||
28 | * Shortcode Constructor. |
||
29 | * |
||
30 | * @param array $atts Shortcode attributes |
||
31 | * @param string $content The inner (enclosed) content |
||
32 | * @param string $tag The called shortcode tag |
||
33 | */ |
||
34 | public function __construct($atts, $content, $tag) |
||
40 | |||
41 | /** |
||
42 | * Register a tag for this shortcode. |
||
43 | * |
||
44 | * @param mixed $tag The tag to register with this shortcode class |
||
45 | */ |
||
46 | public static function register($tag) |
||
50 | |||
51 | /** |
||
52 | * WordPress Shortcode Callback |
||
53 | * |
||
54 | * @param mixed $atts Shortcode attributes |
||
55 | * @param string $content The inner (enclosed) content |
||
56 | * @param string $tag The called shortcode tag |
||
57 | * |
||
58 | * @return static |
||
59 | */ |
||
60 | public static function controller($atts, $content, $tag) |
||
64 | |||
65 | /** |
||
66 | * Call the shortcode's handler and return the output. |
||
67 | * |
||
68 | * @return mixed Rendered shortcode output |
||
69 | */ |
||
70 | public function render() |
||
80 | |||
81 | /** |
||
82 | * Catch-all render method. |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | protected function handler() |
||
90 | |||
91 | /** |
||
92 | * Get all attributes as a collection. |
||
93 | * |
||
94 | * @return Collection |
||
95 | */ |
||
96 | public function attributes() |
||
100 | } |
||
101 |