我是wordpress的新手,我正在尝试添加一些简单的东西,只是一个admin_option_page()。在我激活了我的插件后,它似乎没有工作......我不确定我在这里做错了什么。如果有人可以帮助我,我会非常感激。谢谢!
class Settings{
public function __construct()
{
add_action("admin_menu",[$this,"myPluginMenu"]);
}
public function myPluginMenu(){
add_options_page("My plugin menu","Plugin menu","manage-options","my-plugin-menu",[$this,"pluginHtml"]);
}
public function pluginHtml(){
if(!current_user_can("manage_options")){
wp_die(__("Sorry you cant access this page"));
}
echo "<div class='wrap'>";
echo "<p>Here is where the form would go if it had options</p>";
echo "</div>";
}
}
new Settings();
答案 0 :(得分:0)
我发现了我的错误
字符串&#34; manage-options&#34;应该是&#34; manage_options&#34;