Genri_Rus2019-09-15 20:03:06
Genri_Rus, 2019-09-15 20:03:06

Is there an analogue of the php function is_admin_bar_showing() for checking in js?

Let me explain the problem, the fact is that when loading data ajax, the modal window has certain styles registered
And here top: 0 is registered, but let's say top: 32px
There is one way out of this problem, create 2 different files and connect them in the case of the admin bar or without?
I'm more interested in the question, but can I somehow check in the frontend?
Let's say the admin bar is currently shown or not?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
twobomb, 2018-04-14

Type of such

Oleg, 2018-04-14

Gradient + shadow
But you have a texture there, so a picture.

Vladimir Brumer, 2019-09-15

You can pass a function to js using wp_localize_script.
code in function.php

if(!function_exists('load_styles_scripts')):function load_styles_scripts(){
    wp_enqueue_script('click',get_template_directory_uri().'/js/click.js',array('jquery'));//подключенный файл скрипта в котором Вы хотите использовать функцию is_admin_bar_showing

    wp_localize_script('click','IABS_In',$IABS);//передаем в файл скрипта функцию


then you need to get the data in this script file
after we do what we want
Видео пример

Anatoly Kulikov, 2019-09-15

No extra files and duplicates are needed, everything is very easy to do.
If I remember correctly, the admin bar has a unique id. Check if it exists on the page, and if it exists, you can either add an inline style or a modifier class.
That's all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question