Ngăn các block trong UXBuider tạo HTML khi chọn hidden

Ngăn các block trong UXBuider tạo HTML khi chọn hidden 1
Tính năng: Ngăn các Block trong UX tạo html khi chọn hidden, mặc định Flatsome chỉ dùng css display none để ẩn những html đó.
Lợi ích: Làm được 2 template riêng cho mobile và desktop, kèm theo cũng rất nhiều lợi ích khi không phải doshorte code không dùng đến.
Lưu ý: Bật cache mobile riêng kẻo trên mobile lại chẳng có gì nhé.
 
// Add custom Theme Functions here
add_filter( ‘do_shortcode_tag’, ‘add_filter_shortcode_ux_visibility’, 10, 3 );
function add_filter_shortcode_ux_visibility( $output, $tag, $attr ) {
if( !isset($attr[‘visibility’]) )
return $output;

if($attr[‘visibility’] == ‘hidden’)
return;

if( ($attr[‘visibility’] == ‘hide-for-medium’) && wp_is_mobile() )
return;
elseif( ($attr[‘visibility’] == ‘show-for-small’) && !wp_is_mobile() )
return;
elseif( ($attr[‘visibility’] == ‘show-for-medium’) && !wp_is_mobile() )
return;
elseif( ($attr[‘visibility’] == ‘hide-for-small’) && wp_is_mobile() )
return;

return $output;
}

Để lại một bình luận

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

This site uses Akismet to reduce spam. Learn how your comment data is processed.