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 | * @var array The list of registered settings pages |
||
14 | */ |
||
15 | private $settings_pages = array(); |
||
16 | |||
17 | /** |
||
18 | * Returns the *Singleton* instance of this class. |
||
19 | * |
||
20 | * @return Singleton The *Singleton* instance. |
||
21 | */ |
||
22 | public static function get_instance() |
||
30 | |||
31 | /** |
||
32 | * Add a page to the admin menu. |
||
33 | * |
||
34 | * @param array $args |
||
35 | * @throws \RuntimeException |
||
36 | */ |
||
37 | public function add_settings_page( $args ) |
||
48 | |||
49 | /** |
||
50 | * Get a settings page from the list of registered settings pages. |
||
51 | * |
||
52 | * @param string $slug |
||
53 | * @param string $parent_slug |
||
54 | * @return SettingsPage |
||
55 | * @throws \RuntimeException If no settings page was found for the given slug/parent_slug |
||
56 | */ |
||
57 | public function get_settings_page( $slug ) |
||
65 | |||
66 | /** |
||
67 | * Register styles & scripts to be enqueued by settings pages |
||
68 | */ |
||
69 | public function register_scripts() |
||
74 | |||
75 | /** |
||
76 | * Private constructor to prevent instantiation |
||
77 | */ |
||
78 | private function __construct() |
||
82 | |||
83 | /** |
||
84 | * Register scripts and initiate the request handler. |
||
85 | */ |
||
86 | private function init() |
||
93 | } |
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: