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

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

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;
}

Avatar of jamesblackvn

Tui là jamesblackvn!

Trả lời

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 *

Website này sử dụng Akismet để hạn chế spam. Tìm hiểu bình luận của bạn được duyệt như thế nào.