1 | <?php |
||
5 | class Manager |
||
6 | { |
||
7 | /** |
||
8 | * @var Singleton The reference to *Singleton* instance of this class |
||
9 | */ |
||
10 | private static $instance; |
||
11 | |||
12 | /** |
||
13 | * Undocumented variable |
||
14 | * |
||
15 | * @var array The list of registered shortcodes |
||
16 | */ |
||
17 | private $shortcodes = array(); |
||
18 | |||
19 | /** |
||
20 | * Returns the *Singleton* instance of this class. |
||
21 | * |
||
22 | * @return Singleton The *Singleton* instance. |
||
23 | */ |
||
24 | public static function get_instance() |
||
32 | |||
33 | /** |
||
34 | * Register a shortcode |
||
35 | * |
||
36 | * @param [array] $args |
||
37 | * @return void |
||
38 | */ |
||
39 | public function register_shortcode( $args ) |
||
59 | |||
60 | /** |
||
61 | * Enqueue the shortcode script and print the JSON object |
||
62 | * |
||
63 | * @param [array] $plugins_array |
||
64 | * @return void |
||
65 | */ |
||
66 | public function enqueue_script($plugins_array) |
||
77 | |||
78 | /** |
||
79 | * Enqueue the popup stylesheet. This needs to be separated from the editor |
||
80 | * stylesheet since it is not part of the editor. |
||
81 | * |
||
82 | * @return void |
||
83 | */ |
||
84 | public function enqueue_popup_style() |
||
88 | |||
89 | /** |
||
90 | * Enqueue the editor stylesheet. |
||
91 | * |
||
92 | * @return void |
||
93 | */ |
||
94 | public function enqueue_editor_style() |
||
98 | |||
99 | private function decode_atts($atts) |
||
110 | |||
111 | /** |
||
112 | * Create a JSON object that will be printed in the admin section |
||
113 | * to be used by the TinyMCE plugin code. |
||
114 | */ |
||
115 | private function prepare_json_object() |
||
126 | |||
127 | /** |
||
128 | * Default shortcode arguments |
||
129 | */ |
||
130 | private function default_args() |
||
148 | |||
149 | /** |
||
150 | * Check if a shortcode with the given ID has already been registered |
||
151 | */ |
||
152 | private function shortcode_exists( $id ) |
||
156 | |||
157 | /** |
||
158 | * Validate that the provided arguments have the required arguments as |
||
159 | * specified in self::required_args() |
||
160 | */ |
||
161 | private function validate_args( $args ) |
||
171 | |||
172 | /** |
||
173 | * Prepare a shortcode configuration array based on the given arguments |
||
174 | * |
||
175 | * @param [array] $args |
||
176 | * @return array |
||
177 | */ |
||
178 | private function prepare_config( $args ) |
||
190 | |||
191 | /** |
||
192 | * Genereate a basic shortcode template based on the given set |
||
193 | * of shortcode fields. |
||
194 | * |
||
195 | * @param [string] $tag |
||
196 | * @param [array] $fields |
||
197 | * @return string |
||
198 | */ |
||
199 | private function generate_template($tag, $fields) |
||
224 | |||
225 | /** |
||
226 | * A list of required arguments |
||
227 | */ |
||
228 | private function required_args() |
||
232 | |||
233 | /** |
||
234 | * Private constructor to prevent instantiation |
||
235 | */ |
||
236 | private function __construct() |
||
243 | } |
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: