mirror of
https://github.com/Pathduck/gallery3.git
synced 2026-07-29 19:20:52 -04:00
Add Menu::add_before()
This commit is contained in:
@@ -184,7 +184,7 @@ class Menu_Core extends Menu_Element {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new element to this menu
|
||||
* Add a new element to this menu, after the specific element
|
||||
*/
|
||||
public function add_after($target_id, $new_menu_element) {
|
||||
$copy = array();
|
||||
@@ -198,6 +198,21 @@ class Menu_Core extends Menu_Element {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new element to this menu, before the specific element
|
||||
*/
|
||||
public function add_before($target_id, $new_menu_element) {
|
||||
$copy = array();
|
||||
foreach ($this->elements as $id => $menu_element) {
|
||||
if ($id == $target_id) {
|
||||
$copy[$new_menu_element->id] = $new_menu_element;
|
||||
}
|
||||
$copy[$id] = $menu_element;
|
||||
}
|
||||
$this->elements = $copy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an element from the menu
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user