how to change default icon of custom plugin?

I made a custom plugin for POLL . When I activate it, default icon is coming there on sidebar. I want to change this default icon. Here is my code which I wrote in init.php file.

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';
}

I searched it but results are not coming for custom theme. 🙁 so I am asking here.
Thanks in advance!!!!!!

2 s
2

Take a close look at add_menu_page hook, it provides argument to supply with icon 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' 
);

Leave a Comment