$this->children[] = $item;
}
+ /**
+ * Set the menu item's children
+ *
+ * @param array $children Array of ElggMenuItems
+ *
+ * @return void
+ */
+ public function setChildren($children) {
+ $this->children = $children;
+ }
+
/**
* Get the children menu items
*
}
/**
- * Initialise the admin backend.
+ * Initialize the admin backend.
*
* @return void
*/
// plugin settings are added in elgg_admin_add_plugin_settings_menu() via the admin page handler
// for performance reasons.
+ // we want plugin settings menu items to be sorted alphabetical
+ if (elgg_in_context('admin')) {
+ elgg_register_plugin_hook_handler('prepare', 'menu:page', 'elgg_admin_sort_page_menu');
+ }
+
if (elgg_is_admin_logged_in()) {
elgg_register_menu_item('topbar', array(
'name' => 'administration',
*
* @return void
* @access private
+ * @since 1.8.0
*/
function elgg_admin_add_plugin_settings_menu() {
}
}
+/**
+ * Sort the plugin settings menu items
+ *
+ * @param string $hook
+ * @param string $type
+ * @param array $return
+ * @param array $params
+ *
+ * @return void
+ * @since 1.8.0
+ */
+function elgg_admin_sort_page_menu($hook, $type, $return, $params) {
+ $configure_items = $return['configure'];
+ foreach ($configure_items as $menu_item) {
+ if ($menu_item->getName() == 'settings') {
+ $settings = $menu_item;
+ }
+ }
+
+ // keep the basic and advanced settings at the top
+ $children = $settings->getChildren();
+ $site_settings = array_splice($children, 0, 2);
+ usort($children, array('ElggMenuBuilder', 'compareByText'));
+ array_splice($children, 0, 0, $site_settings);
+ $settings->setChildren($children);
+}
+
/**
* Handles any set up required for administration pages
*