Hi, with which version did you encounter the issue on mobile?
To disable (or only enable) Fancybox on certain pages, your can find instructions on https://premium.status301.com/knowledge-base/easy-fancybox/disable-fancybox-on-certain-pages/
Hi,
thx for reply. I use the newest version 1.9.5…
I have test the snippet like this:
add_action(
‘wp_enqueue_scripts’,
function() {
class_exists(‘easyFancyBox’) && !is_page(‘home’) && easyFancyBox::$add_scripts = false;
},
0
);
But nothing is happend. Do you can take a look, what is wrong with the snippet or I have a syntaxerror? I need the js and css files only on 4 pages and I use ACF with customs settings to handle some other css and js files. My customers can choose, if js/css is loading or not on every page like:
if ( get_field( ‘contact’ ) ):
some-files.css
endif
In the backend on every pages are buttons to choose YES or NOT
Is is it possible to modify the code above like this:
add_action(
‘wp_enqueue_scripts’,
function() {
class_exists(‘easyFancyBox’) && CHECK-ACF-FIELD-YES && easyFancyBox::$add_scripts = false;
},
0
);
hui… sorry for my english… I hope you understand my plans 🙂
-
This reply was modified 2 years, 9 months ago by
janwill.
Hi, are you using a code snippets plugin or adding this to your theme’s functions.php? Make sure the quote marks are ' not ’
For ACF you should be able to use something like get_field('my_checkbox_field') if I’m not mistaken. For safety you could add an extra check so that the snippet will not cause a PHP error if ACF is deactivated:
add_action(
'wp_enqueue_scripts',
function() {
if ( class_exists('easyFancyBox') && function_exists('get_field') && ! get_field('lightbox_enabled') ) {
easyFancyBox::$add_scripts = false;
}
},
0
);
Note: in thsi example I am supposing the ACF field is a checkbox called lightbox_enabled and either returns a 1 (checked) or empty (unchecked).