我制作了一个自定义插件POLL . 当我激活它时,默认图标会出现在侧边栏上。我想更改此默认图标。这是我写的代码init.php 文件
add_action(\'admin_menu\', \'mt_add_pages\');
// action function for above hook
function mt_add_pages() {
// Add a new top-level menu (ill-advised):
add_menu_page(__(\'Poll\',\'menu-test\'), __(\'Poll\',\'menu-test\'), \'manage_options\', \'manage-polls\', \'poll_page\' );
// Add a submenu to the custom top-level menu:
add_submenu_page(\'manage-polls\', __(\'Add New Poll\',\'menu-test\'), __(\'Add New Poll\',\'menu-test\'), \'manage_options\', \'add-poll\', \'add_new_poll_page\');
}
// mt_toplevel_page() displays the page content for the custom Test Toplevel menu
function poll_page() {
if (!current_user_can(\'manage_options\'))
{
wp_die( __(\'You do not have sufficient permissions to access this page.\') );
}
echo "<br/>";
echo "<div>";
echo \'<div style="float:left;"><img width="20" height = "20" src="\'.site_url().\'/wp-content/plugins/poll/images/poll_red.png" /></div>\';
echo "</div>";
echo "<h2>" . __( \'Manage Polls\', \'menu-test\' ) . "</h2>";
include_once \'manage-polls.php\';
}
// mt_sublevel_page() displays the page content for the first submenu
// of the custom Test Toplevel menu
function add_new_poll_page() {
if (!current_user_can(\'manage_options\'))
{
wp_die( __(\'You do not have sufficient permissions to access this page.\') );
}
echo "<br/>";
echo "<div>";
echo \'<div style="float:left;"><img width="20" height = "20" src="\'.site_url().\'/wp-content/plugins/poll/images/poll_red.png" /></div>\';
echo "</div>";
include_once \'poll_form.php\';
}
我搜索了它,但没有自定义主题的结果:(所以我在这里问。提前谢谢!!!!!)!!!!!!
最合适的回答,由SO网友:Rajeev Vyas 整理而成
仔细查看add\\u menu\\u页面挂钩,它提供了用于提供图标url的参数
<?php
add_menu_page(
$page_title,
$menu_title,
$capability,
$menu_slug,
$function,
$icon_url,
$position
);
http://codex.wordpress.org/Function_Reference/add_menu_page
add_menu_page(
__(\'Poll\',\'menu-test\'),
__(\'Poll\',\'menu-test\'),
\'manage_options\',
\'manage-polls\',
\'poll_page\',
\'plugins_folder Or Theme folder url/icon.png\'
);