Advertisement
TBotNik

EM Submenu test

Nov 16th, 2011
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /***************************************************************************/
  3. /* Plugin Name: WPS Poll */
  4. /* URI: ../wp-content/plugins/wps-poll */
  5. /* Description: This plugin is a test plugin for learning purpose. */
  6. /* Version: 0.1 Author: Nyle Davis */
  7. /* Author URI: http://URI_Of_The_Plugin_Author */
  8. /* License: GPL2 - most WordPress plugins are released under GPL2 */
  9. /***************************************************************************/
  10.  
  11. function wps_poll_options_page () {
  12. ?>
  13. <div class=”wrap”>
  14. <h2>WPS Poll Admin</h2>
  15. <p>Here comes the options page content.</p>
  16. </div>
  17. <?php
  18. } // end function
  19.  
  20. function wps_poll_new_page () {
  21. include ( ABSPATH.'wp-content/plugins/events-manager-ext/admin/emxt-admin-options.php');
  22. } // end function
  23.  
  24. function emxt_new_page () {
  25. include ( ABSPATH.'wp-content/plugins/events-manager-ext/admin/emxt-admin-optform.php');
  26. } // end function
  27.  
  28. function wps_poll_menu () {
  29. // #1 Works
  30. add_menu_page('WPS Poll', __('WPS Poll'),'manage_options',basename(__FILE__), 'wps_poll_options_page');
  31.  
  32. // #2 Works
  33. $parent_slug = 'wps-poll.php';
  34. $page_title = 'Options';
  35. $menu_title = 'Options';
  36. $capability = 'manage_options';
  37. $menu_slug = 'emxt-admin-options.php';
  38. $function = 'wps_poll_new_page';
  39. add_submenu_page($parent_slug, __($page_title), __($menu_title), $capability, $menu_slug, $function);
  40.  
  41. // #3 Works
  42. $source_file = ABSPATH.'wp-content/plugins/events-manager-ext/events-manager-ext.php';
  43. $page_title = 'EMXT Options';
  44. $menu_title = 'EMXT Options';
  45. $function = 'emxt_new_page';
  46. //echo "PS=> $parent_slug <br>";
  47. add_menu_page($page_title, __($menu_title), $capability, basename($source_file), $function);
  48.  
  49. // #4 Works Now ==> Problem was the __(var) syntax in the add_submenu_page line
  50. // and "activate_plugins" for capability
  51. // Test writing a submenu to existing Events manger admin menu
  52. $parent_slug = 'events-manager';
  53. $page_title = 'Ext Options';
  54. $menu_title = 'Ext Options';
  55. $capability = 'activate_plugins';
  56. $menu_slug = 'events-manager-ext';
  57. $function = 'emxt_new_page';
  58. add_submenu_page($parent_slug, __($page_title), __($menu_title), $capability, $menu_slug, $function);
  59. } // end function
  60.  
  61. add_action('admin_menu','wps_poll_menu');
  62.  
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement