wordpress - Adding new menu page to dashboard -


i'm looking use add_menu_page add new section wordpress dashboard. issue put code? i've looked around @ several tutorials , frustratingly not 1 mentions add code!

if tell me:

  1. where put add_menu_page code and
  2. where register function passed parameter add_menu_page function

that appreciated.

normally wouldn't answer question doesn't have code you've tried in, seems more abstract question i'll give more abstract answer.

'hacking' wordpress achieved using hooks triggered when actions executed wordpress. when hook reached system checks see if there functions registered called @ point in execution. menu page can registered in functions.php file of theme or in plugin file - doesn't matter long register appropriate action hook.

example

first need page menu item link (create page anywhere, ideally in theme directory if you're doing theme or plugin directory if you're doing plugin). called mine settings_page.php , put in theme directory.

then we've got function register menu page (in functions.php if you're doing theme or in main plugin file if you're doing plugin):

function create_menu() {     $settings_page = add_menu_page(          __("my settings", emu2_i18n_domain),         __("my settings", emu2_i18n_domain),         0,         theme_directory.'/settings_page.php'          // replacing theme_directory actual directory     ); } 

then register menu page wordpress hook - in case 'admin_menu' hook (in same file 1 registered function above in):

add_action( 'admin_menu', 'create_menu' ); 

now you're done. i've listed couple of resource below in case want delve bit deeper, hope helped lay bit more groundwork what's going on under surface.

extra resources

function reference create_menu in wordpress codex

function reference create_sub_menu in wordpress codex

list of wordpress hooks

wordpress tutorial writing plugin


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -