Wordpress add link to admin menu bar

Categorías: 

Etiquetas: 

  • Step 1: call add_action 'admin_menu'
  • Step 2: create custom function for the new link

Step 1: call add_action 'admin_menu'

add_action( 'admin_menu', 'register_example_custom_menu_link_menu_page' );

Step 2: create custom function for the new link

function register_example_custom_menu_link_menu_page() {
    add_menu_page(
        __('New admin link'), // link title
        __('New admin link'), // link display on screen
        'manage_options', // capability / permission to see display the link
        'example_custom_menu_link', // menu slug / clean url
        'example_custom_menu_link_function', // function name to display content when an user clicks 
        '', // icon url, example: plugins_url( 'myplugin/images/icon.png' ),
        6 // menu order, must be unique, if the number exists it will overwrite another menu link
    ); 
}
 
function example_custom_menu_link_function() {
    echo "Here goes the magic!"
}

More info: http://codex.wordpress.org/Function_Reference/add_menu_page