Support » Fixing WordPress » Detecting front-end admin panel and 3.8 changes

  • I know I can add css rules to check for the class .customize-support on the body element and I’ve also discovered that wp 3.8 now has 2 different admin bar sizes, 32px height when viewport width is greater than 782px otherwise it 46px height.

    But I noticed that since the .customize-support class is added via js from the wp core and not via php, trying to detect it with my own scripts fail.

    This is because my js runs on doc ready and the body element does not have the .customize-support class yet. Of course I can delay my script but that won’t work for me since I am detecting viewport height – admin bar for presentation and I prefer not to use a delay then fade-in method.

    Is there a better way to detect if admin on frontend that my script can use?

    For now, I am using functions.php to add a custom meta and then detect that with my js…but is there a better way?

    * if logged in as admin add to front end *
    function addAdminDetection() {
        if ( current_user_can( 'manage_options' ) ) {
            echo '<meta property="wp-admin" content="true" id="admin">';
        } else {
            //do nothing
    add_action('wp_head', 'addAdminDetection');
  • The topic ‘Detecting front-end admin panel and 3.8 changes’ is closed to new replies.