Add Submenu to Tools in Admin Panel without functions.php

I have a quick question, I am wanting to add in a new submenu to the 'Tools' section on my Admin Panel but without modifying any of the original WordPress files such as (functions.php, etc..) files. So I'm unable to use the functions.php file to input the function call directly.

File Path:
wp-content/mu-plugins/_functions/actions/instagram.php

Here is the code that I am using:

<?php
/**
 * Created by PhpStorm.
 * Date: 2019-08-14
 * Time: 10:44
 */

/*
* Add in a new submenu to the 'Tools.php' settings
*/
function admin_menu() {
    add_action('admin_menu', 'register_my_custom_submenu_page');

    function register_my_custom_submenu_page() {
        add_submenu_page(
            'tools.php',
            'Submenu Page',
            'My Custom Submenu Page',
            'manage_options',
            'my-custom-submenu-page',
            'my_custom_submenu_page_content' );
    }

    function my_custom_submenu_page_content() {
        ?>
            <div class="wrap">
            <h2>Page Title</h2>
            </div>
        <?php
    }
}

Could anyone let me know why it's not showing up under 'Tools' in the admin panel?

1 answer

  • answered 2019-08-14 18:38 Carl

    Yes, In your currently active theme or child theme, modify the functions.php file, and add this to the end of it. I just tried it on my own local machine and this works. You shouldn't use that admin_menu() function you're currently using.

        add_action('admin_menu', 'register_my_custom_submenu_page');
    
        function register_my_custom_submenu_page() {
            add_submenu_page(
                'tools.php',
                'Submenu Page',
                'My Custom Submenu Page',
                'manage_options',
                'my-custom-submenu-page',
                'my_custom_submenu_page_content' );
        }
    
        function my_custom_submenu_page_content() {
            ?>
                <div class="wrap">
                <h2>Page Title</h2>
                </div>
            <?php
        }