1 | <?php |
||
8 | class Manager |
||
9 | { |
||
10 | /** |
||
11 | * @var Singleton The reference to *Singleton* instance of this class |
||
12 | */ |
||
13 | private static $instance; |
||
14 | |||
15 | /** |
||
16 | * @var Array Stores all the registered metaboxes |
||
17 | */ |
||
18 | private $metaboxes = array(); |
||
19 | |||
20 | /** |
||
21 | * Security nonce action |
||
22 | */ |
||
23 | const NONCE_ACTION = 'amarkal_metabox'; |
||
24 | |||
25 | /** |
||
26 | * Returns the *Singleton* instance of this class. |
||
27 | * |
||
28 | * @return Singleton The *Singleton* instance. |
||
29 | */ |
||
30 | public static function get_instance() |
||
39 | |||
40 | /** |
||
41 | * Add a metabox. |
||
42 | * |
||
43 | * @param string $id |
||
44 | * @param array $args |
||
45 | * @throws \RuntimeException if the given metabox id has already been registered |
||
46 | */ |
||
47 | public function add( $id, array $args ) |
||
55 | |||
56 | /** |
||
57 | * Render a metabox. |
||
58 | * |
||
59 | * @param WP_Post $post |
||
60 | * @param array $args |
||
61 | */ |
||
62 | public function render( $post, $args ) |
||
73 | |||
74 | /** |
||
75 | * Internally used to register metaboxes. |
||
76 | */ |
||
77 | public function add_meta_boxes() |
||
91 | |||
92 | /** |
||
93 | * Save metaboxes data for a given page. |
||
94 | * |
||
95 | * @param number $post_id |
||
96 | */ |
||
97 | public function save_meta_boxes( $post_id ) |
||
136 | |||
137 | /** |
||
138 | * Save the data of a single metabox. |
||
139 | * |
||
140 | * @param number $post_id |
||
141 | * @param string $id |
||
142 | * @param array $metabox |
||
143 | */ |
||
144 | public function save_meta_box( $post_id, $id, $metabox ) |
||
168 | |||
169 | /** |
||
170 | * Print custom metabox style. |
||
171 | */ |
||
172 | public function print_style() |
||
187 | |||
188 | /** |
||
189 | * Initiate the metaboxes by adding action hooks for printing and saving. |
||
190 | */ |
||
191 | private function init() |
||
197 | |||
198 | /** |
||
199 | * Default arguments for the add() method. |
||
200 | * |
||
201 | * @return array |
||
202 | */ |
||
203 | private function default_args() |
||
213 | } |
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: