• <?php
    /*
    Plugin Name: WordPress Menu Examples Plugin
    Plugin URI: https://example.com/wordpress-plugins/my-plugin
    Description: A plugin to create menus and submenus in WordPress
    Version: 1.0
    Author: Brad Williams
    Author URI: https://wrox.com
    License: GPLv2
    */
    
    add_action( 'admin_menu', 'boj_menuexample_create_menu' );
    
    function boj_menuexample_create_menu() {
    
    	//create custom top-level 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__ ) );
    
    	//create submenu items
    	add_submenu_page( __FILE__, 'About My Plugin', 'About', 'manage_options', __FILE__.'_about', boj_menuexample_about_page );
    	add_submenu_page( __FILE__, 'Help with My Plugin', 'Help', 'manage_options', __FILE__.'_help', boj_menuexample_help_page );
    	add_submenu_page( __FILE__, 'Uinstall My Plugin', 'Uninstall', 'manage_options', __FILE__.'_uninstall', boj_menuexample_uninstall_page ); 
    
    }
    
    ?>
    [/PHP]
    
    [PHP]
    /*
    
      Description:  menuexample_settings_page
      Author: adrian
      Version: 1.0
      Author URI: https://www.xymalf.com
     */
    
    <?php
    
    */
    
    add_action( 'admin_menu', 'boj_menuexample_create_menu' );
    
    function boj_menuexample_create_menu() {
    
    	//create a submenu under Settings
    	add_options_page( 'My Plugin Settings Page', 'Menu Example Settings', 'manage_options', __FILE__, 'boj_menuexample_settings_page' );
    
    }
    ?>

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]

    the plug in is activating but when I click on the link for the Settings page it crashes. Help please.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Try checking your site’s error logs for messages. Your hosts should be able to help you accessing your site’s error logs.

    Thread Starter xymalf

    (@xymalf)

    Not running the plugin live – developing local on a WAMP server

    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

    it comes up with that error even though I have a boj_menuexample_settings_page in the plugin directory.

    developing local on a WAMP server

    Then check your server’s error logs.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sub menu item crashing the plugin.’ is closed to new replies.