Customizing the main navigation menu
In WordPress, the main navigation menu is located on the left of the screen where we have access to all the sections of the application. Similar 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 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);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:
Array ( [2] => Array ( [0] =>...