我已经创建了这个自定义插件,并且在激活之后它会在安装的插件上显示“设置”。如何为我的自定义插件创建设置页面?
我不想在任何地方展示我的设置页面链接的管理面板菜单,但是当用户点击设置插件的(见上面的屏幕截图)应该去插件设置页面。我明白我必须对第二个函数“our_plugin_action_links”的变量做些什么$settings_link
我只是试图链接放在admin文件夹中的单个php文件。然后当点击时它会进入该php文件。但我想显示管理面板中的插件设置页面,就像其他页面一样,如添加帖子或**常规设置页面点击设置插件但未显示管理菜单中的链接或菜单为插件设置。
我该怎么做?
我的插件代码
<?php
/*
Plugin Name: admin menu remover
Description: Remove the admin menus just by a single plugin installation
Version: 1.0
Author: Author
Author URI: http://URI_Of_The_Plugin_Author
License: A "Slug" license name e.g. GPL2
*/
/* This function and action removes following menu item from the admin panel */
add_action('admin_menu', 'remove_links_menu');
function remove_links_menu() {
remove_menu_page('index.php'); // Dashboard
//remove_menu_page('edit-comments.php'); // Comments
remove_menu_page('themes.php'); // Appearance
//remove_menu_page('plugins.php'); // Plugins
//remove_menu_page('tools.php'); // Tools
//remove_menu_page('options-general.php'); // Settings
//remove_menu_page('users.php'); // Users
}
/* This function and filter append "setting" immediately after the "admin menu remover" plugin activation */
add_filter('plugin_action_links', 'our_plugin_action_links', 10, 2);
function our_plugin_action_links($links, $file) {
static $this_plugin;
if (!$this_plugin) {
$this_plugin = plugin_basename(__FILE__);
}
// check to make sure we are on the correct plugin
if ($file == $this_plugin) {
// the anchor tag and href to the URL we want. For a "Settings" link, this needs to be the url of your settings page
$settings_link = '<a href="' . get_bloginfo('wpurl') . '/wp-admin/admin.php?page=font-uploader.php">Settings</a>';
// add the link to the list
array_unshift($links, $settings_link);
}
return $links;
}
?>
完美..谢谢@chris – 2014-08-30 07:11:42