View difference between Paste ID: 3Bg8a98z and 6TfEX7cF
SHOW: | | - or go back to the newest paste.
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-
   }
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-
      <h2>WPS Poll New Page</h2>
23+
24-
      <p>Here is the new page contents.</p>
24+
   function emxt_new_page () {
25
      include ( ABSPATH.'wp-content/plugins/events-manager-ext/admin/emxt-admin-optform.php');
26
   }  // end function
27-
   }
27+
28
   function wps_poll_menu () {
29
      // #1 Works	
30-
      // Works	
30+
31
32
      // #2 Works
33
      $parent_slug = 'wps-poll.php';
34-
      $page_title  = 'WPS Poll';
34+
      $page_title  = 'Options';
35-
      $menu_title  = 'WPS Poll';
35+
      $menu_title  = 'Options';
36
      $capability  = 'manage_options';
37-
      $menu_slug   = basename(__FILE__);
37+
      $menu_slug   = 'emxt-admin-options.php';
38
      $function    = 'wps_poll_new_page';
39-
      // Doesn't Work
39+
      add_submenu_page($parent_slug, __($page_title), __($menu_title), $capability, $menu_slug, $function);
40-
      //add_submenu_page($parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function);
40+
41-
      // Test writing a submenu to Events manger
41+
      // #3 Works
42-
      // Doesn't Work	
42+
      $source_file = ABSPATH.'wp-content/plugins/events-manager-ext/events-manager-ext.php';
43-
      $parent_slug = ABSPATH.'/wp-content/plugins/events-manager/events-manager.php';
43+
      $page_title  = 'EMXT Options';
44-
      add_submenu_page($parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function);
44+
      $menu_title  = 'EMXT Options';
45-
   }
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-
?>
49+
      // #4 Works Now ==> Problem was the __(var) syntax in the add_submenu_page line 
50-
50+
	  //              and "activate_plugins" for capability
51-
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
?>