All,
Here is my code that works on this:
Code:
<?php
/***************************************************************************/
/* Plugin Name: WPS Poll */
/* URI: ../wp-content/plugins/wps-poll */
/* Description: This plugin is a test plugin for learning purpose. */
/* Version: 0.1 Author: Nyle Davis */
/* Author URI: http://URI_Of_The_Plugin_Author */
/* License: GPL2 - most WordPress plugins are released under GPL2 */
/***************************************************************************/
function wps_poll_options_page () {
?>
<div class=”wrap”>
<h2>WPS Poll Admin</h2>
<p>Here comes the options page content.</p>
</div>
<?php
} // end function
function wps_poll_new_page () {
include ( ABSPATH.'wp-content/plugins/events-manager-ext/admin/emxt-admin-options.php');
} // end function
function emxt_new_page () {
include ( ABSPATH.'wp-content/plugins/events-manager-ext/admin/emxt-admin-optform.php');
} // end function
function wps_poll_menu () {
// #1 Works
add_menu_page('WPS Poll', __('WPS Poll'),'manage_options',basename(__FILE__), 'wps_poll_options_page');
// #2 Works
$parent_slug = 'wps-poll.php';
$page_title = 'Options';
$menu_title = 'Options';
$capability = 'manage_options';
$menu_slug = 'emxt-admin-options.php';
$function = 'wps_poll_new_page';
add_submenu_page($parent_slug, __($page_title), __($menu_title), $capability, $menu_slug, $function);
// #3 Works
$source_file = ABSPATH.'wp-content/plugins/events-manager-ext/events-manager-ext.php';
$page_title = 'EMXT Options';
$menu_title = 'EMXT Options';
$function = 'emxt_new_page';
//echo "PS=> $parent_slug <br>";
add_menu_page($page_title, __($menu_title), $capability, basename($source_file), $function);
// #4 Works Now ==> Problem was the __(var) syntax in the add_submenu_page line
// and "activate_plugins" for capability
// Test writing a submenu to existing Events manger admin menu
$parent_slug = 'events-manager';
$page_title = 'Ext Options';
$menu_title = 'Ext Options';
$capability = 'activate_plugins';
$menu_slug = 'events-manager-ext';
$function = 'emxt_new_page';
add_submenu_page($parent_slug, __($page_title), __($menu_title), $capability, $menu_slug, $function);
} // end function
add_action('admin_menu','wps_poll_menu');
?> Items 1-3 are experimental, but work, and showed me how to use the vars for command substitution. None of the codex HOWTOs showed this, but the syntax is very significant and the __(var) values must be there or the commands do not work. add_menu_page is much more forgiven than the submenu command.
Anyway got the menu items added, but get errors from something else, so starting with clean code and adding one item at a time to find the activation problem with my other code. Will open a different thread, as I think that will not be related to these commands anymore.
Thanks!
OMR