Support » Plugin: Admin bar languages » problem with is_admin_bar_showing() in the frondend

  • Resolved wittich

    (@wittich)


    Hi there, thanks for your plugin, its exactly what I was looking for. It helps a lot when your pages have the same title with different languages.

    I encountered a problem with the call of the function is_admin_bar_showing() in the plugin. In the frontend it result the following error message:

    PHP Fatal error: Call to undefined function is_user_logged_in() in /wp-includes/admin-bar.php on line 829, referer: /wp-admin/index.php

    I remove the query and there is no more problem. Though in the frontend the flag is overlapped with the original wordpress icon.

    Hope that helps to improve the plugin.

    Best regards
    Valentin

    https://wordpress.org/plugins/admin-bar-languages/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Mikael Korpela

    (@simison)

    That’s interesting, thanks for the info!

    Which WP version you’re using and does this occur with fresh install?

    I’m using 4.0 with a multisite environment.

    In the meanwhile I read a little more about the function and it seems like for some reason is_user_logged_in() get called to early.

    So what I did is that I wraped you plugin into another function… It seams like that it works.

    if (!function_exists('load_admin_bar_languages')){
    
        function load_admin_bar_languages() {
    
            /*
             * Run this plugin only when we have admin bar up there...
             */
            if( is_admin_bar_showing() ) {
    
                [...]
    
            }
    
        }
    
     }
    
    add_action( 'init', 'load_admin_bar_languages' );

    Though I have still the error that in the frondend the flag is overlapped with the wordpress icon.

    Plugin Author Mikael Korpela

    (@simison)

    Yup, I was looking into this today and found the issue. Just fixed this and pushed v1.1: https://wordpress.org/plugins/admin-bar-languages/

    Thanks for the heads up!

    Thanks for you fast correction.

    The issue overlapping icon in the admin bar in the frontend seems still not solved. For same reason the flagatar.css doesn’t get loaded in the frontend. Well it doesn’t really bother…

    Regards

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘problem with is_admin_bar_showing() in the frondend’ is closed to new replies.