Support » Plugins » ATTN Plugin developers: Question about submenu pages

  • Resolved Lovedoodle

    (@lovedoodle)


    I’m in the process of creating a plugin for 3 blogs running on WPMU.

    I’m wondering if it’s possible to use mysql_fetch_array to generate submenu pages based on data in the database.

    Each site has it’s own unique table (wp_1_ksettings, wp_2_kpsettings, wp_3_kpsettings) with unique data in it. The columns will contain the strings needed for the options, identifier, and etc used in this line:

    add_submenu_page(__FILE__, $row['option_name'], $row['option_name'], $row['capability'], $row['identifier'], $row['identifier']);

    It’s kinda complex and I’m sure there’s another way to do this but I just can’t think of it. If anyone out there has any ideas or other suggestions it would be greatly appreciated.

    //Add a menu to the top level
    add_action('admin_menu', 'Add_kp_plugin');
    
    //Add a main menu for the plugin
    function Add_kp_plugin() {
       if (function_exists('add_menu_page')){
    		add_menu_page('KP Settings', 'KP Settings', 2, __FILE__, 'startup');
    		global $wpdb;
    		$result = mysql_query("SELECT * FROM wp_" $wpdb->$siteid . "_kpsettings");
    		while($row = mysql_fetch_array($result))
    		{
    			add_submenu_page(__FILE__, $row['option_name'], $row['option_name'], $row['capability'], $row['identifier'], $row['identifier']);
    		}
    	}
    }
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘ATTN Plugin developers: Question about submenu pages’ is closed to new replies.