
// Add custom Theme Functions here
add_filter('use_block_editor_for_post', '__return_false');




//Them star rating trang chủ
function show_rating( $rating_html, $rating, $count ) {
    $rating_html  = '<div class="star-rating">';
    $rating_html .= wc_get_star_rating_html( $rating, $count );
    $rating_html .= '</div>';

    return $rating_html;
};  
add_filter( 'woocommerce_product_get_rating_html', 'show_rating', 100, 3 );


//Thay gia bang lien he 

function custom_price(){
    return '0936669983';
}

add_filter('woocommerce_empty_price_html', 'custom_price');


//------------------------------------- Code chèn ngày tháng tự động -------------------------//
//* Kich hoat Shortcode cho tieu đe bai viet.
add_filter( 'the_title', 'do_shortcode' );
//* Kich hoat Shortcode cho plugin SEO Yoast
add_filter( 'wpseo_title', 'do_shortcode' );
add_filter( 'wpseo_metadesc', 'do_shortcode' );
//* Kich hoat Shortcode cho plugin Rank Math
add_filter( 'rank_math/frontend/title', function( $title ) {
	$title = do_shortcode($title);
	return $title;
});
add_filter( 'rank_math/frontend/description', function( $description ) {
	$description = do_shortcode($description);
	return $description;
});
// * Shortcode hien thi thoi gian hien tai.
// * shortcode: [nam]
add_shortcode ('nam', 'get_hienthinam');
function get_hienthinam () 
{
	$hienthinam= date ("Y"); // * Thay đổi định dạng tại đây
	return "$hienthinam";
}
// * shortcode: [thang]
add_shortcode ('thang', 'get_hienthithang');
function get_hienthithang () 
{
	$hienthithang= date ("m"); // * Thay đổi định dạng tại đây
	return "$hienthithang";
}
 // * shortcode: [ngay]
add_shortcode ('ngay', 'get_hienthingay');
function get_hienthingay () 
{
	$hienthingay= date ("d"); // * Thay đổi định dạng tại đây
	return "$hienthingay";
}
 // * shortcode: [thang_nam]
add_shortcode ('thang_nam', 'get_hienthithangnam');
function get_hienthithangnam () 
{
	$hienthithangnam= date ("m/Y"); // * Thay đổi định dạng tại đây
	return "<b style='color:red;'>$hienthithangnam</b>";
}
 // * shortcode: [hienthithangnam]
add_shortcode ('ngay_thang_nam', 'get_hienthingaythangnam');
function get_hienthingaythangnam () 
{
	$hienthingaythangnam= date ("d/m/Y"); // * Thay đổi định dạng tại đây
	return "<b style='color:red;'>$hienthingaythangnam</b>";
}


/* Đặt nút close vào bên trong lightbox*/
add_filter( 'flatsome_lightbox_close_btn_inside', '__return_true' );
/*Remove p tag automatically in CF7*/
add_filter('wpcf7_autop_or_not', '__return_false');


/*=======Preload feature image of wocommerce product====================*/

function get_featured_image_preload_url() {
    $product_id = get_the_ID(); // Lấy ID sản phẩm
    $image_id = get_post_thumbnail_id( $product_id ); // Lấy ID ảnh đại diện
    $image_url = wp_get_attachment_image_src( $image_id, 'full' ); // Lấy URL ảnh kích thước gốc

    return $image_url ? $image_url[0] : ''; // Trả về URL ảnh hoặc rỗng nếu không có
}
add_action( 'wp_head', 'preload_featured_image' );
function preload_featured_image() {
    if ( is_product() ) { // Kiểm tra xem có phải trang sản phẩm WooCommerce hay không
        $featured_image_url = get_featured_image_preload_url(); 
        
        if( $featured_image_url ) {
            echo '<link rel="preload" href="' . esc_url( $featured_image_url ) . '" as="image">';
        }
    }
}


/*======Remove jquery do ko dung den trong trang Product ======*/
add_action( 'wp_enqueue_scripts', 'dequeue_jquery_min_js', 99 );
function dequeue_jquery_min_js() {
    if ( is_product() ) { // Kiểm tra xem có phải trang sản phẩm WooCommerce hay không
       // wp_dequeue_script( 'flatsome-jquery' ); // Loại bỏ file `jquery.min.js`
       wp_deregister_script('jquery');
       wp_deregister_style('flatsome'); // Loại bỏ file `flatsome.css`
    }
}<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//kinhotothienke.vn/main-sitemap.xsl"?>
<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
	<sitemap>
		<loc>https://kinhotothienke.vn/post-sitemap.xml</loc>
		<lastmod>2026-03-20T04:09:36+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://kinhotothienke.vn/page-sitemap.xml</loc>
		<lastmod>2024-04-10T02:03:37+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://kinhotothienke.vn/product-sitemap1.xml</loc>
		<lastmod>2024-08-15T08:59:42+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://kinhotothienke.vn/product-sitemap2.xml</loc>
		<lastmod>2024-08-15T08:52:03+00:00</lastmod>
	</sitemap>
	<sitemap>
		<loc>https://kinhotothienke.vn/product_cat-sitemap.xml</loc>
		<lastmod>2024-08-15T08:59:42+00:00</lastmod>
	</sitemap>
</sitemapindex>
<!-- XML Sitemap generated by Rank Math SEO Plugin (c) Rank Math - rankmath.com -->