Answer the question
In order to leave comments, you need to log in
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
You can pass a function to js using wp_localize_script.
Example:
code in function.php
add_action('wp_enqueue_scripts','load_styles_scripts');
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
$IABS=array('IABS_Out'=>is_admin_bar_showing());
wp_localize_script('click','IABS_In',$IABS);//передаем в файл скрипта функцию
}endif;
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 questionAsk a Question
731 491 924 answers to any question