1 | <?php |
||
15 | abstract class Base_Admin_Menu { |
||
16 | /** |
||
17 | * Holds class instances. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected static $instances; |
||
22 | |||
23 | /** |
||
24 | * Whether the current request is a REST API request. |
||
25 | * |
||
26 | * @var bool |
||
27 | */ |
||
28 | protected $is_api_request = false; |
||
29 | |||
30 | /** |
||
31 | * Domain of the current site. |
||
32 | * |
||
33 | * @var string |
||
34 | */ |
||
35 | protected $domain; |
||
36 | |||
37 | /** |
||
38 | * Base_Admin_Menu constructor. |
||
39 | */ |
||
40 | protected function __construct() { |
||
48 | |||
49 | /** |
||
50 | * Determine if the current request is from API |
||
51 | */ |
||
52 | public function set_is_api_request() { |
||
58 | |||
59 | /** |
||
60 | * Returns class instance. |
||
61 | * |
||
62 | * @return Admin_Menu |
||
63 | */ |
||
64 | public static function get_instance() { |
||
73 | |||
74 | /** |
||
75 | * Sets up class properties for REST API requests. |
||
76 | * |
||
77 | * @param \WP_REST_Response $response Response from the endpoint. |
||
78 | */ |
||
79 | public function rest_api_init( $response ) { |
||
84 | |||
85 | /** |
||
86 | * Updates the menu data of the given menu slug. |
||
87 | * |
||
88 | * @param string $slug Slug of the menu to update. |
||
89 | * @param string $url New menu URL. |
||
|
|||
90 | * @param string $title New menu title. |
||
91 | * @param string $cap New menu capability. |
||
92 | * @param string $icon New menu icon. |
||
93 | * @param int $position New menu position. |
||
94 | * @return bool Whether the menu has been updated. |
||
95 | */ |
||
96 | public function update_menu( $slug, $url = null, $title = null, $cap = null, $icon = null, $position = null ) { |
||
150 | |||
151 | /** |
||
152 | * Updates the submenus of the given menu slug. |
||
153 | * |
||
154 | * @param string $slug Menu slug. |
||
155 | * @param array $submenus_to_update Array of new submenu slugs. |
||
156 | */ |
||
157 | public function update_submenus( $slug, $submenus_to_update ) { |
||
172 | |||
173 | /** |
||
174 | * Adds a menu separator. |
||
175 | * |
||
176 | * @param int $position The position in the menu order this item should appear. |
||
177 | * @param string $cap Optional. The capability required for this menu to be displayed to the user. |
||
178 | * Default: 'read'. |
||
179 | */ |
||
180 | public function add_admin_menu_separator( $position = null, $cap = 'read' ) { |
||
191 | |||
192 | /** |
||
193 | * Enqueues scripts and styles. |
||
194 | */ |
||
195 | public function enqueue_scripts() { |
||
223 | |||
224 | /** |
||
225 | * Adds the given menu item in the specified position. |
||
226 | * |
||
227 | * @param array $item The menu item to add. |
||
228 | * @param int $position The position in the menu order this item should appear. |
||
229 | */ |
||
230 | public function set_menu_item( $item, $position = null ) { |
||
244 | |||
245 | /** |
||
246 | * Determines whether the current locale is right-to-left (RTL). |
||
247 | */ |
||
248 | public function is_rtl() { |
||
251 | |||
252 | /** |
||
253 | * Whether to use wp-admin pages rather than Calypso. |
||
254 | * |
||
255 | * Options: |
||
256 | * false - Calypso (Default). |
||
257 | * true - wp-admin. |
||
258 | * |
||
259 | * @return bool |
||
260 | */ |
||
261 | abstract public function should_link_to_wp_admin(); |
||
262 | |||
263 | /** |
||
264 | * Create the desired menu output. |
||
265 | */ |
||
266 | abstract public function reregister_menu_items(); |
||
267 | } |
||
268 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.