How to wrap admin menus and menu headers in additional divs without modifying the WordPress core?

I need to do this to enable advanced styling options via css, the one a class the headers are wrapped in isn’t adequate to do the type of styling needed. Thanks!

Related posts

Leave a Reply

3 comments

  1. Since the admin back-end menus do have li tags you can use that if you want. but as far as adding divs you will need to hack the core files directly. That is if you are talking about the back-end.

  2. Short of removing everything and recreating it all, I think the only solution is jQuery.

    add_action( 'admin_head', 'wrap_menu_div_wpse_19814' );
    function wrap_menu_div_wpse_19814()
    {   
        ?>
        <script type="text/javascript">
            jQuery(document).ready(function($) 
            {    
                $('.menu-top').each(function()
                {
                    old_value = $(this).html();
                    $(this).html( '<div>' + old_value + '</div>' );
                });
            });
        </script>
        <?php
    }
    
  3. dont know of anything like this but what you can often do sometimes is to target this specificity of a particular div, for instance if you have a div which is included in a < p > which is included in a < table > < tr > and < td > but the div has no class or id then you can still target it by using

    table tr td p div{
    }

    and it will often affect that and only that div …. it’s not foolproof but it works a lot of the time …. you often need to use !important though and sometimes you need to go back very far along the page even back as far as the html and body sometimes
    sometimes pseudo like firstchild help too

    hope this helps

    good luck