[Flatsome] Ngăn cho các Block trong UXBuider tạo HTML khi chọn hidden

by Hoàng Lương
0 Các bình luận

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.

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

Chúc các bạn sử dụng đoạn code trên hiệu quả nhé! Có thắc mắc hoặc lỗi chỗ nào cũng vui lòng comment cho mình biết nữa

Nguồn : VietCoders

Đánh giá post

You may also like

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website. Quảng cáo là nguồn thu chính giúp chúng tôi duy trì hoạt động và mang đến nội dung miễn phí cho cộng đồng. Rất mong bạn tắt tiện ích AdBlocker khi truy cập website — sự ủng hộ của bạn giúp chúng tôi tiếp tục cải thiện và phục vụ tốt hơn mỗi ngày.