• <?php
    
    /*
    Plugin Name: Menu Test
    Plugin URI: https://codex.www.ads-software.com/Adding_Administration_Menus
    Description: Menu Test
    Author: Codex authors
    Author URI: https://example.com
    
    warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'boj_menuexample_settings_page' not found or invalid function name in C:\wamp\www\WPDev\wp-includes\plugin.php on line 470
    */
    
    add_action( 'admin_menu', 'boj_menuexample_create_menu' );
    
    function boj_menuexample_create_menu() {
    
    add_menu_page( 'My Plugin Settings Page', 'Menu Example Settings','manage_options', _FILE_, 'boj_menuexample_settings_page', plugins_url( '/images/wp-icon.png', _FILE__));
    
    }
    
    add_action( 'about_menu', 'boj_menuexample_about_page');
    function boj_menuexample_about_page() {
    add_submenu_page( _FILE_, 'About My Plugin', 'About', 'manage_options',_FILE_.'_about', boj_menuexample_about_page);
    
    }
    
    add_action( 'uninstall_menu', 'boj_menuexample_uninstall_page');
    function boj_menuexample_uninstall_page() {
    
    add_submenu_page( _FILE_,'Uninstall My Plugin', 'uninstall', 'manage_options',
    _FILE_.'_uninstall', boj_menuexample_uninstall_page);
    
    }
    
    ?>
Viewing 1 replies (of 1 total)
  • /*
    Plugin Name:  Menu Test
    Plugin URI:   https://codex.www.ads-software.com/Adding_Administration_Menus
    Description:  Menu Test
    Author:       Codex authors
    Author URI:   https://example.com
    */
    
    // You can do all the menu creation at once.
    function boj_menuexample_create_menu() {
    
      add_menu_page( 'My Plugin Settings Page', 'Menu Example Settings','manage_options', __FILE__, 'boj_menuexample_settings_page', plugins_url( '/images/wp-icon.png', __FILE__ ) );
    
      add_submenu_page( __FILE__, 'About My Plugin', 'About', 'manage_options', __FILE__ . '_about', 'boj_menuexample_about_page' );
    
      add_submenu_page( __FILE__,'Uninstall My Plugin', 'uninstall', 'manage_options', __FILE__ . '_uninstall', 'boj_menuexample_uninstall_page' );
    
    }
    add_action( 'admin_menu', 'boj_menuexample_create_menu' );
    
    //  Then you actually have to declare the functions that will generate the pages/page content.
    function boj_menuexample_settings_page() {
    
      echo "<h1>Settings Page</h1>";
    
    }
    function boj_menuexample_about_page() {
    
      echo "<h1>About Page</h1>";
    
    }
    function boj_menuexample_uninstall_page() {
    
      echo "<h1>Uninstall Page</h1>";
    
    }

    You also don’t need an extra uninstall page. Plugins should be installed and uninstalled by using the WordPress plugin administration page.

    If you’re plugin requires to delete options, database stuff in general or certain files when being uninstalled you should create a separate file for this, called uninstall.php (https://codex.www.ads-software.com/Function_Reference/register_uninstall_hook#uninstall.php)

Viewing 1 replies (of 1 total)
  • The topic ‘how do I write the function to open the page?’ is closed to new replies.