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 ) |
||
50 | |||
51 | /** |
||
52 | * Enqueue the shortcode script and print the JSON object |
||
53 | * |
||
54 | * @param [array] $plugins_array |
||
55 | * @return void |
||
56 | */ |
||
57 | public function enqueue_script($plugins_array) |
||
68 | |||
69 | /** |
||
70 | * Enqueue the popup stylesheet. This needs to be separated from the editor |
||
71 | * stylesheet since it is not part of the editor. |
||
72 | * |
||
73 | * @return void |
||
74 | */ |
||
75 | public function enqueue_popup_style() |
||
79 | |||
80 | /** |
||
81 | * Enqueue the editor stylesheet. |
||
82 | * |
||
83 | * @return void |
||
84 | */ |
||
85 | public function enqueue_editor_style() |
||
89 | |||
90 | /** |
||
91 | * Create a JSON object that will be printed in the admin section |
||
92 | * to be used by the TinyMCE plugin code. |
||
93 | */ |
||
94 | private function prepare_json_object() |
||
105 | |||
106 | /** |
||
107 | * Default shortcode arguments |
||
108 | */ |
||
109 | private function default_args() |
||
125 | |||
126 | /** |
||
127 | * Check if a shortcode with the given ID has already been registered |
||
128 | */ |
||
129 | private function shortcode_exists( $id ) |
||
133 | |||
134 | /** |
||
135 | * Validate that the provided arguments have the required arguments as |
||
136 | * specified in self::required_args() |
||
137 | */ |
||
138 | private function validate_args( $args ) |
||
148 | |||
149 | /** |
||
150 | * Prepare a shortcode configuration array based on the given arguments |
||
151 | * |
||
152 | * @param [array] $args |
||
153 | * @return array |
||
154 | */ |
||
155 | private function prepare_config( $args ) |
||
167 | |||
168 | /** |
||
169 | * Genereate a basic shortcode template based on the given set |
||
170 | * of shortcode fields. |
||
171 | * |
||
172 | * @param [string] $tag |
||
173 | * @param [array] $fields |
||
174 | * @return string |
||
175 | */ |
||
176 | private function generate_template($tag, $fields) |
||
201 | |||
202 | /** |
||
203 | * A list of required arguments |
||
204 | */ |
||
205 | private function required_args() |
||
209 | |||
210 | /** |
||
211 | * Private constructor to prevent instantiation |
||
212 | */ |
||
213 | private function __construct() |
||
220 | } |
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: