function class doesnt work

i added a menu to admin bar menu but it’s style doesnt work;it looks like has default style

<style>

.my_menu_item_class{
color:red;
background: yellow;
}
</style>
<?php
add_action(‘admin_bar_menu’, ‘add_toolbar_items’, 100);
function add_toolbar_items($admin_bar){
$admin_bar->add_menu( array(
‘id’ => ‘my-item’,
‘title’ => ‘My Item’,
‘href’ => ‘#’,
‘meta’ => array(
‘title’ => __(‘My Item’),
),
));
$admin_bar->add_menu( array(
‘id’ => ‘my-sub-item’,
‘parent’ => ‘my-item’,
‘title’ => ‘My Sub Menu Item’,
‘href’ => ‘#’,
‘meta’ => array(
‘title’ => __(‘My Sub Menu Item’),
‘target’ => ‘_blank’,
‘class’ => ‘my_menu_item_class’
),
));
$admin_bar->add_menu( array(
‘id’ => ‘my-second-sub-item’,
‘parent’ => ‘my-item’,
‘title’ => ‘My Second Sub Menu Item’,
‘href’ => ‘#’,
‘meta’ => array(
‘title’ => __(‘My Second Sub Menu Item’),
‘target’ => ‘_blank’,
‘class’ => ‘my_menu_item_class’
),
));
}

?>

Read more here:: function class doesnt work

Leave a Reply

Your email address will not be published. Required fields are marked *