-
Notifications
You must be signed in to change notification settings - Fork 0
Menu Sidebar
H::remove_menu( $titles );
PARAMETERS
$titles
(array) - Array of the menu titles (case sensitive).
EXAMPLE
H::remove_menu( array('Comments', 'Tools') );
H::add_menu( $title, $args );
PARAMETERS
$title
(string) - The text that appear in the Menu.
$args
(array) - Available list are:
-
slug
(string) - The URL that comes after yoursite.com/wp-admin/.... -
icon
(string) - Icon names are listed here. -
position
(string) - Relative position of this menu. The keyword is below / above followed by an existing menu title. For example: "below Pages". -
submenu
(array) - List of links under this menu. The format istitle => slug
. -
counter
(function) - Function that returns an integer. It is shown as circled number besides the menu title.
EXAMPLE
Create a shortcut to edit your main pages:
H::add_menu('Home', array(
'slug' => 'post.php?post=10&action=edit', // direct link to a specific Edit page.
'icon' => 'dashicons-admin-home',
'position' => 'below Posts',
'submenu' => array(
'About' => 'post.php?post=12&action=edit',
'Contact Us' => 'post.php?post=14&action=edit'
),
'counter' => function() {
return 5; // doesn't have any meaning, for showcase only
}
));
H::add_submenu( $parent_title, $menu_items );
PARAMETERS
$parent_title
(string) - The title of the parent (case sensitive).
$menu_items
(array) - Key-value pair for Title and Permalink.
EXAMPLE
Combine the shortcut with the original "Pages"
H::add_submenu('Pages', array(
'About' => 'post.php?post=12&action=edit',
'Contact Us' => 'post.php?post=14&action=edit'
))
H::add_menu_counter( $parent_title, $function );
PARAMETERS
$parent_title
(string) - The title to place this counter.
$function
(callable) - Calculate the number and should return integer.
EXAMPLE
Add number of posts that are still in "Draft".
H::add_menu_counter( 'Posts', 'count_draft_posts' );
function count_draft_posts() {
$posts = Timber::get_posts(array(
'post_type' => 'post',
'post_status' => 'draft'
));
return count( $posts );
}