Own Plugin problem with the add_submenu_page
-
Hi,
I got problem with adding subpages. My class looks like this<?php class ProductCatalogue { function AdminCategories(){...} function AdminPhotos() {...} function AdminSettings() {...} function AdminProducts() {...} function AdminMain() {...} } ?>Ouside of class i got:
$pc_plugin = new ProductCatalogue(); function ProductCatalogue_ap() { global $pc_plugin; if (!isset($pc_plugin)) { return; }//ENDIF if (function_exists('add_menu_page')) { add_menu_page('Product Catalogue', 'Product Catalogue', 9,__FILE__, array(&$pc_plugin, 'AdminMain')); add_submenu_page(__FILE__, 'Categories', 'Categories', 9, __FILE__, array(&$pc_plugin, 'AdminCategories')); add_submenu_page(__FILE__, 'Products', 'Products', 9, __FILE__, array(&$pc_plugin, 'AdminProducts')); add_submenu_page(__FILE__, 'Photos', 'Photos', 9, __FILE__, array(&$pc_plugin, 'AdminPhotos')); add_submenu_page(__FILE__, 'Settings', 'Settings', 9, __FILE__, array(&$pc_plugin, 'AdminSettings')); }//ENDIF } add_action('admin_menu', 'ProductCatalogue_ap');The problem is:
function add_submenu_page() with reference to my class and method array(&$pc_plugin, ‘AdminSettings’) adds sub page but still the content of the subpage is from add_menu_page().
What goes wrong with mine code.Thx,
mGz
-
Hi,
I realize it is a little bit late to react but i think i had the same problem and it took me some time to solve it.
WordPress seems to require that the various admin pages are located in separate files. In order to keep a single file I had to make WordPress think i’m using several files by adding a get parameter to the file.
like this,
add_submenu_page(__FILE__, 'Categories', 'Categories', 9, __FILE__ . '?option=one', array(&$pc_plugin, 'AdminCategories'));Hope this is still helpfull to someone.
Kind regards,
Richard
The topic ‘Own Plugin problem with the add_submenu_page’ is closed to new replies.