我已經創建了這個自定義插件,並且在激活之後它會在安裝的插件上顯示「設置」。如何爲我的自定義插件創建設置頁面?
我不想在任何地方展示我的設置頁面鏈接的管理面板菜單,但是當用戶點擊設置插件的(見上面的屏幕截圖)應該去插件設置頁面。我明白我必須對第二個函數「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