How to insert Wordpress icons in the administrative area menu?

Asked

Viewed 204 times

0

How to set icons of Wordpress itself, icon that is located on the line 10 of this function?

add_action('admin_menu', 'pagina_gerencia');

function pagina_gerencia() {
    add_menu_page (
    'Gerência de dados',
    'Gerência',
        'manage_options',
        'danton_traduttions/danton_traduttions.php',
        '',
        'div', // <-- linha 10
        6
    );
}

1 answer

1


Just use one of the classes of dashicons.css, as dashicons-chart-pie or dashicons-welcome-learn-more:

add_action('admin_menu', function() {
    # $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null
    add_menu_page (
        'Gerência de dados',
        'Gerência',
        'manage_options',
        'gerencia_de_dados',
        function(){ echo '<h1>menu</h1>'; },
        'dashicons-welcome-learn-more',
        6
    );
});

You can also enter a URL, a Base64-encoded SVG or leave empty to do with CSS.

  • If you gave a like for the questions would be very cool, stimulates the community. There are days that I leave giving Likes in your questions and answers as I do with several others in the community. Think about it.

  • 1

    it’s my common practice, I’ve traveled... but now I’m going to take some time to not seem to give in to the pressure :P

  • I do not know if this question deserves the opening of a question: from the moment I have set the files that the menu pulls and that the data worked has no direct relationship with Wordpress functions itself, I can put what I like in my archives .php? ... type pretend that there is integrated with Wordpress just because it is within the administrative area?

  • It’s not pretending what you do include/require will have the WP available. You have to organize the code right and everything is fine...

  • I knew something was wrong, it was too easy!!! Error of Cannot modify header information headers. rsrs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.