/** * Adds a new menu page. * * This function is only executed once for each menu component. * The first child will be added using this function. * * @since 0.5.0 * @param WPDLib\Components\Base $menu_item the component to add to the menu * @return string|bool either the first submenu label (defined by the child component) or a boolean whether the component was successfully added */ protected function add_menu_page($menu_item) { $status = false; if (is_callable(array($menu_item, 'add_to_menu'))) { $status = $menu_item->add_to_menu(array('mode' => 'menu', 'menu_label' => $this->args['label'], 'menu_icon' => $this->args['icon'], 'menu_position' => $this->args['position'])); } if ($status) { $this->added = true; $this->menu_slug = $menu_item->slug; if (is_callable(array($menu_item, 'get_menu_slug'))) { $this->menu_slug = $menu_item->get_menu_slug(); } $this->first_submenu_label = $status; $this->maybe_adjust_first_submenu_label(); } return $status; }