plugins - Submenu Page under Settings in Admin Panel

I have a quick question, I am wanting to add in a new submenu to the 'Tools' section on my Admin Panel but wit

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/fh-extensions/_functions/actions/instagram.php

Here is the code that I am using:

<?php
/**
 * Created by PhpStorm.
 * User: smajlovs
 * 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?

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/fh-extensions/_functions/actions/instagram.php

Here is the code that I am using:

<?php
/**
 * Created by PhpStorm.
 * User: smajlovs
 * 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?

Share Improve this question edited Aug 14, 2019 at 17:30 DevSem 2092 silver badges11 bronze badges asked Aug 14, 2019 at 15:50 SemaSema 1 1
  • I just answered almost the same question an hour ago. See this link: wordpress.stackexchange/questions/345091/… – user3135691 Commented Aug 14, 2019 at 16:09
Add a comment  | 

1 Answer 1

Reset to default 0

I didn't test this but i'm pretty sure you just need to remove your code from the admin_menu() function declaration.

Like this:

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
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745241312a4618198.html

相关推荐

  • plugins - Submenu Page under Settings in Admin Panel

    I have a quick question, I am wanting to add in a new submenu to the 'Tools' section on my Admin Panel but wit

    3小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信