Last active
January 9, 2025 11:47
-
-
Save webantam43/cb290aa390d92dac64e3ec8cb7afac06 to your computer and use it in GitHub Desktop.
Tải điều kiện file flatsome-swatches-frontend.css theme Flatsome
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Tải điều kiện file flatsome-swatches-frontend.css | |
| add_action('wp_enqueue_scripts', function() { | |
| wp_dequeue_style('flatsome-swatches-frontend'); | |
| wp_deregister_style('flatsome-swatches-frontend'); | |
| }, 20); | |
| // Thêm CSS khi cần thiết | |
| add_action('wp_enqueue_scripts', function() { | |
| // Kiểm tra các điều kiện để load CSS | |
| if ( | |
| is_product() || // Trang chi tiết sản phẩm | |
| is_shop() || // Trang shop | |
| is_product_category() || // Trang danh mục sản phẩm | |
| is_product_tag() || // Trang tag sản phẩm | |
| has_product_shortcode_wat() || // Các trang có shortcode sản phẩm | |
| has_uxbuilder_products_wat() // Các trang có element UX Builder products | |
| ) { | |
| wp_enqueue_style( | |
| 'flatsome-swatches-frontend', | |
| get_template_directory_uri() . '/assets/css/extensions/flatsome-swatches-frontend.css', | |
| array(), | |
| wp_get_theme('flatsome')->get('Version') | |
| ); | |
| } | |
| }, 30); | |
| // Hàm kiểm tra shortcode sản phẩm | |
| function has_product_shortcode_wat() { | |
| global $post; | |
| if (!is_singular() || !isset($post->post_content)) { | |
| return false; | |
| } | |
| $product_shortcodes = array( | |
| 'products', | |
| 'product_page', | |
| 'product_category', | |
| 'recent_products', | |
| 'featured_products', | |
| 'sale_products', | |
| 'best_selling_products', | |
| 'top_rated_products', | |
| 'product_attribute', | |
| 'ux_products', // Thêm shortcode của UX Builder | |
| 'ux_product_categories', // Thêm shortcode của UX Builder | |
| ); | |
| foreach ($product_shortcodes as $shortcode) { | |
| if (has_shortcode($post->post_content, $shortcode)) { | |
| return true; | |
| } | |
| } | |
| return false; | |
| } | |
| // Hàm kiểm tra UX Builder products elements | |
| function has_uxbuilder_products_wat() { | |
| global $post; | |
| if (!is_singular() || !isset($post->post_content)) { | |
| return false; | |
| } | |
| // Kiểm tra có element UX Builder products không | |
| if ( | |
| strpos($post->post_content, '[ux_products') !== false || | |
| strpos($post->post_content, '[ux_product_categories') !== false || | |
| strpos($post->post_content, '[shop_products') !== false || | |
| strpos($post->post_content, '[products_grid') !== false || | |
| strpos($post->post_content, '[product_categories_grid') !== false | |
| ) { | |
| return true; | |
| } | |
| // Kiểm tra có section chứa products không | |
| if (strpos($post->post_content, '"element":"products"') !== false) { | |
| return true; | |
| } | |
| return false; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment