Book Image

WordPress Web Application Development

By : Rakhitha Nimesh Ratnayake
Book Image

WordPress Web Application Development

By: Rakhitha Nimesh Ratnayake

Overview of this book

Table of Contents (19 chapters)
WordPress Web Application Development Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Customizing the main navigation menu


In WordPress, the main navigation menu is located on the left-hand side of the screen where we have access to all the sections of the application. In a similar way to the admin toolbar, we have the ability to extend the main navigation menu with customized versions.

Let's start by adding the admin menu invoking an action to the constructor:

add_action( 'admin_menu', array( $this,'wpwa_customize_main_navigation' ) );

Now, consider the initial implementation of the wpwa_customize_main_navigation function:

public function wpwa_customize_main_navigation(){
    global $menu,$submenu;
    echo "<pre>";print_r($menu);echo "</pre>";exit;
}

The preceding code uses the global variable menu for accessing the available main navigation menu items. Before we begin the customizations, it's important to get used to the structure of the menu array using a print_r statement. A part of the output generated from the print_r statement is shown in the following section...