为什么激活的插件没有出现在WordPress管理区的左侧菜单栏中?

时间:2018-12-29 作者:Tahridabbas

有人能帮我吗?我正在尝试为gallery创建一个插件,但在启动时出现了一个问题,当我激活插件时,它正在激活,但问题是它没有出现在左侧菜单中,

this is my code of plugin startup:|

<?php
/*
Plugin Name:JaissGallery
Plugin URI:WWW.GOOGLE.COM
description: >-Jaiss gallery plugin
Version: 0.1
Author: Mr. Tahrid abbas
Author URI: http://mrtotallyawesome.com
*/

function doctors_gallery(){
    add_menu_page(
    "doctorsGallery",
    "Doctors Gallery",
    "Manage_options",
    "DoctorsGallery",
    "Doc_gallery_view"
    );
}
add_action(\'admin_menu\',\'doctors_gallery\');

function Doc_gallery_view(){
    echo "ghfhgfgh";
}
有人能告诉我我在那里错过了什么吗?

2 个回复
最合适的回答,由SO网友:Debabrata Karfa 整理而成

对于菜单和子菜单,

enter image description here

function doctors_gallery(){
    add_menu_page(
        __( \'Doctors Gallery\', \'textdomain\' ),
        \'Doctors Gallery\',
        \'manage_options\', //  The capability required for this menu to be displayed to the user.
        \'DoctorsGallery\',
        \'doc_gallery_view\'
    );

    add_submenu_page(
        \'DoctorsGallery\',
        __( \'Doctors Submenu Page\', \'textdomain\' ),
        __( \'Doctors Submenu\', \'textdomain\' ),
        \'manage_options\',
        \'DoctorsSubGallery\',
        \'doctor_submenu_callback\'
    );

}

add_action( \'admin_menu\',\'doctors_gallery\' );

function doc_gallery_view(){
    echo "ghfhgfgh";
}

function doctor_submenu_callback(){
    echo "Sub Menu section";
}

SO网友:Debabrata Karfa

Can you try this,

function doctors_gallery(){
    add_menu_page(
        __( \'Doctors Gallery\', \'textdomain\' ),
        \'Doctors Gallery\',
        \'manage_options\', //  The capability required for this menu to be displayed to the user.
        \'DoctorsGallery\',
        \'doc_gallery_view\'
    );
}
add_action( \'admin_menu\',\'doctors_gallery\' );

function doc_gallery_view(){
    echo "ghfhgfgh";
}

相关推荐

Testing Plugins for Multisite

我最近发布了一个WordPress插件,它在单个站点上非常有效。我被告知该插件在多站点安装上不能正常工作,我理解其中的一些原因。我已经更新了代码,现在需要一种方法来测试更新后的代码,然后才能转到实时客户的多站点安装。我有一个用于测试的WordPress安装程序的单站点安装,但需要在多站点安装上进行测试。根据我所能找到的唯一方法是在网络上至少有两个站点来安装整个多站点安装,以测试我的插件。设置WordPress的整个多站点安装是插件开发人员的唯一/首选方式,还是有更快的测试环境可用。