*
* The text of the menu item is obtained from elgg_echo(admin:$parent_id:$menu_id)
*
+ * This function handles registering the parent if it has not been registered.
+ *
* @param string $menu_id The Unique ID of section
* @param string $parent_id If a child section, the parent section id.
* @param int $weight The menu item weight
*/
function elgg_add_admin_menu_item($menu_id, $parent_id = NULL, $weight = 100) {
+ // make sure parent is registered
+ if ($parent_id && !elgg_is_menu_item_registered('page', $parent_id)) {
+ elgg_add_admin_menu_item($parent_id);
+ }
+
// in the admin section parents never have links
if ($parent_id) {
$href = "pg/admin/$parent_id/$menu_id";
elgg_add_admin_menu_item('simple', 'plugins', 10);
elgg_add_admin_menu_item('advanced', 'plugins', 20);
- // utilities
- elgg_add_admin_menu_item('utilities', null, 70);
-
// dashboard
elgg_register_menu_item('page', array(
'name' => 'dashboard',
return false;
}
+/**
+ * Check if a menu item has been registered
+ *
+ * @param string $menu_name The name of the menu
+ * @param string $item_name The unique identifier for this menu item
+ *
+ * @return bool
+ * @since 1.8.0
+ */
+function elgg_is_menu_item_registered($menu_name, $item_name) {
+ global $CONFIG;
+
+ if (!isset($CONFIG->menus[$menu_name])) {
+ return false;
+ }
+
+ foreach ($CONFIG->menus[$menu_name] as $index => $menu_object) {
+ if ($menu_object->getName() == $item_name) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
/**
* Adds a breadcrumb to the breadcrumbs stack.
*