Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773

(Woocommerce) Thu gọn nội dung chi tiết sản phẩm

jQuery(document).ready(function($) {		
var product = $('.single-product .wc-tab');
        if($('.single-product .tab-description.entry-content.wc-tab').length > 0){
            var wrap_description = $('.single-product .tab-description.entry-content.wc-tab');
            var height_description = wrap_description.height();
            var your_height_wrap_description = 500;
            if(height_description > your_height_wrap_description){
                wrap_description.css('height', your_height_wrap_description+'px');
                wrap_description.append('<div id="readmore_woo_description" class="readmore_woo"><a title="Xem đầy đủ mô tả" href="javascript:void(0);">Xem đầy đủ mô tả</a></div>');
                product.on('click','#readmore_woo_description', function(){
                    wrap_description.removeAttr('style');
                    $('.single-product #readmore_woo_description').remove();
                });
}
}
});


Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773

(Woocommerce) Custom Sản Phẩm Xem Gần Đây

1. Edit lại function Woocommerce

Funtion “wc_track_product_view” mặc định của woocommerce chỉ tracking sản phẩm liên quan khi có thêm widget recently_viewed_product ở sidebar.
Chỉnh sửa lại như sau nếu ko thêm widget thì nó vẫn tracking sản phẩm đã xem vào cookie trình duyệt:

function wc_track_product_view_always() {
  if ( ! is_singular( 'product' ) /* xnagyg: remove this condition to run: || ! is_active_widget( false, false, 'woocommerce_recently_viewed_products', true )*/ ) {
    return;
  }
  
  global $post;
  
  if ( empty( $_COOKIE['woocommerce_recently_viewed'] ) ) { // @codingStandardsIgnoreLine.
    $viewed_products = array();
  } else {
    $viewed_products = wp_parse_id_list( (array) explode( '|', wp_unslash( $_COOKIE['woocommerce_recently_viewed'] ) ) ); // @codingStandardsIgnoreLine.
  }
  
  // Unset if already in viewed products list.
  $keys = array_flip( $viewed_products );
  
  if ( isset( $keys[ $post->ID ] ) ) {
    unset( $viewed_products[ $keys[ $post->ID ] ] );
  }
  
  $viewed_products[] = $post->ID;
  
  if ( count( $viewed_products ) > 15 ) {
    array_shift( $viewed_products );
  }
  
  // Store for session only.
  wc_setcookie( 'woocommerce_recently_viewed', implode( '|', $viewed_products ) );
  }
  remove_action('template_redirect', 'wc_track_product_view', 20);
  add_action( 'template_redirect', 'wc_track_product_view_always', 20 );

2. Thêm shortcode mới

add_shortcode( 'recently_viewed_products', 'hnc_recently_viewed_shortcode' );
function hnc_recently_viewed_shortcode() { 
    $viewed_products = ! empty( $_COOKIE['woocommerce_recently_viewed'] ) ? (array) explode( '|', wp_unslash( $_COOKIE['woocommerce_recently_viewed'] ) ) : array();
    $viewed_products = array_reverse( array_filter( array_map( 'absint', $viewed_products ) ) ); 
    ob_start();
    if ( !empty( $viewed_products ) ){
   	$product_ids = implode( ",", $viewed_products );
    $products_query = new WP_Query( array (
        'post_type'         => 'product',
        'post_status'       => 'publish',
        'post__in' => $viewed_products,
        'posts_per_page' => 5,
    )); ?>
<ul class="hnc-recently-products">
    <?php if( $products_query->have_posts() ) : while( $products_query->have_posts() ) : $products_query->the_post();
    global $post, $product; ?>
    <li class="recently-product-item">
        <a href="<?php the_permalink(); ?>" class="recently-product-thumbnail">
            <?php do_action( 'recently_woocommerce_template_loop_product_thumbnail' ); ?>
        </a>
        <div class="recently-product-conntent">
            <div class="recently-product-title">
                <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
            </div>
            <div class="recently-product-price">
                <?php do_action('recently_woocommerce_template_loop_price'); ?>
            </div>
        </div>
    </li>
    <?php endwhile; wp_reset_postdata(); endif; ?>
</ul>
<?php } else {
        echo '<div class="no-content-product p-1">Chưa có sản phẩm đã xem nào!</div>';
    }
    return ob_get_clean();
}

3. Thêm action loop

Đoạn này thêm vào template shortcode phần ảnh đại diện và giá

add_action('recently_woocommerce_template_loop_product_thumbnail', 'woocommerce_template_loop_product_thumbnail' );
add_action('recently_woocommerce_template_loop_price', 'woocommerce_template_loop_price');


Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773

(Woocommerce) Dịch từ “page” ở url phân trang

function re_rewrite_rules() {
  global $wp_rewrite;
  $wp_rewrite->pagination_base = 'trang';
  $wp_rewrite->flush_rules();
}
add_action('init', 're_rewrite_rules');


Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773

(Woocommerce) Code Xuất Tất Cả Coupons

function coupons_code_export_custom_menu_page() {
    add_submenu_page(
        'woocommerce',
        'Coupons Code Export',
    	'Coupons Code Export',
        'manage_options',
        'coupons-code-export',
        'coupons_code_export_func'
    );
}
add_action( 'admin_menu', 'coupons_code_export_custom_menu_page' );

function coupons_code_export_func(){
  ?>
  <div class="wrap">
    <h1>Coupons Code Export - V1.0</h1>
    <form action="">
      <?php wp_nonce_field('coupons_code_nonce','coupons_nonce');?>
      <input name="export" type="submit" class="button button-primary button-large export_coupons" id="publish" value="Export Coupons Code">
    </form>
  </div>
  <script>
  (function($){
    $(".export_coupons").click(function(){
      var nonce = $('#coupons_nonce').val();
      window.location.href = '<?php echo admin_url('admin-ajax.php?action=export_coupons_code&nonce=')?>'+nonce;
      return false;
    });
  })(jQuery);
  </script>
  <?php
}

function cleanData(&$str,$key){
  $str = preg_replace("/\t/", "\\t", $str);
  $str = preg_replace("/\r?\n/", "\\n", $str);
  
  /*if(preg_match("/^0/", $str) || preg_match("/^\+?\d{8,}$/", $str) || preg_match("/^\d{4}.\d{1,2}.\d{1,2}/", $str)) {
      $str = "'$str";
    }*/
    
    if($key == 'Phone number') $str = "'$str";
  
  if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"';
}

function export_coupons_code_func(){
  if ( !wp_verify_nonce( $_REQUEST['nonce'], "coupons_code_nonce")) {
    	exit("No naughty business please");
  }
  $coupons = new WP_Query(array(
    'post_type'			=>	'shop_coupon',
    'posts_per_page'	=>	-1		
  ));
  if($coupons->have_posts()):
    while ($coupons->have_posts()):$coupons->the_post();
      $data[] = array(
        "Code" 			=> get_the_title(), 
        "Coupon amount" => esc_html( get_post_meta( get_the_ID(), 'coupon_amount', true ) ), 
        "Coupon type"	=> esc_html( wc_get_coupon_type( get_post_meta( get_the_ID(), 'discount_type', true ) ) ),
        "Name" 			=> esc_html(get_post_meta( get_the_ID(), 'name_customer', true )),
        "Email"			=> esc_html(get_post_meta( get_the_ID(), 'email_customer', true )),
        "Phone number"	=> esc_html(get_post_meta( get_the_ID(), 'phone_number_customer', true )),
      );
    endwhile;
  else:
    $data = array();
  endif;wp_reset_query();

  // file name for download
  $filename = "coupons_code_" . date('Ymd') . ".xls";

  header("Content-Disposition: attachment; filename=\"$filename\"");
  header("Content-Type: application/vnd.ms-excel");

  $flag = false;
  foreach($data as $row) {
  if(!$flag) {
    echo implode("\t", array_keys($row)) . "\n";
    $flag = true;
  }
  array_walk($row, 'cleanData');
  echo implode("\t", array_values($row)) . "\n";
  }
  exit;
}
add_action( 'wp_ajax_export_coupons_code', 'export_coupons_code_func' );

 



Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773

(Wordpress) Remove image size + Remove srcset

add_action('init', 'remove_plugin_image_sizes');
function remove_plugin_image_sizes() {
    remove_image_size('thumbnail'); // WordPress (used by the media librairy to display thumbs)
    remove_image_size('large'); // WordPress (used by the media librairy to display thumbs)
    remove_image_size('medium'); // WordPress (used by the media librairy to display thumbs)
    remove_image_size('medium_large'); // WordPress (used by the media librairy to display thumbs)
    remove_image_size('1536x1536'); // WordPress (used by the media librairy to display thumbs)
    remove_image_size('2048x2048'); // WordPress (used by the media librairy to display thumbs)
    remove_image_size('shop_thumbnail'); // Woocommerce
    remove_image_size('shop_catalog'); // Woocommerce
    remove_image_size('shop_single'); // Woocommerce
    remove_image_size('woocommerce_thumbnail'); // Woocommerce
    remove_image_size('woocommerce_single'); // Woocommerce
    remove_image_size('woocommerce_gallery_thumbnail'); // Woocommerce
  
}

 

// disable srcset on frontend
function disable_wp_responsive_images() {
  return 1;
}
add_filter('max_srcset_image_width', 'disable_wp_responsive_images');


Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773

(Woocommerce) Code Mini Cart

Header.php

<div class="hnc-cart-side">
    <div class="widget-heading">
      <a href="#" class="hnc-close-side-widget">Đóng</a>
    </div>
    <div class="widget woocommerce widget_shopping_cart">
      <div class="widget_shopping_cart_content scroll-content">
        <div class="hnc-scroll-content">
          <?php woocommerce_mini_cart(); ?>
        </div>
      </div>
    </div>
  </div>

Footer-js.php

jQuery(document).ready(function ($) {
    var widget = $('.cart-widget-opener'),
        btn = widget.find('.site-header__cart-toggle'),
        body = $('body');
    var cartWidgetSide = $('.hnc-cart-side');
    var closeSide = $('.hnc-close-side');
    widget.on('click', function (e) {
        if (!isCart() && !isCheckout()) e.preventDefault();
        if (isOpened()) {
            closeWidget();
        } else {
            setTimeout(function () {
                openWidget();
            }, 10);
        }
    });
    body.on("click touchstart", ".hnc-close-side", function () {
        if (isOpened()) {
            closeWidget();
        }
    });
    body.on("click", ".hnc-close-side-widget", function (e) {
        e.preventDefault();
        if (isOpened()) {
            closeWidget();
        }
    });
    body.on('click', 'a.add_to_cart_button', function () {
        setTimeout(function () {
            openWidget();
        }, 800);
    });
    $(document).keyup(function (e) {
        if (e.keyCode === 27 && isOpened()) closeWidget();
    });
    var closeWidget = function () {
        cartWidgetSide.removeClass('hnc-cart-opened');
        closeSide.removeClass('hnc-close-side-opened');
    };
    var openWidget = function () {
        if (isCart() || isCheckout()) return false;
        cartWidgetSide.addClass('hnc-cart-opened');
        closeSide.addClass('hnc-close-side-opened');
    };
    var isOpened = function () {
        return cartWidgetSide.hasClass('hnc-cart-opened');
    };
    var isCart = function () {
        return $('body').hasClass('hnc-cart');
    };
    var isCheckout = function () {
        return $('body').hasClass('hnc-checkout');
    };
});


Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773

(Woocommerce) Menu Mobile

Show menu danh mục ở trang header.php

<div class="hnc-mobile-nav menu-from-left">
    <div class="menu-mobile">
      <ul id="mobile-menu-nav" class="site-mobile-menu">
        <li class="menu-item"><a href="https://nhaccutienmanh.vn/gioi-thieu/">Giới thiệu</a></li>
        <li class="menu-item"><a href="https://nhaccutienmanh.vn/lien-he/">Liên hệ</a></li>
        <li class="menu-item"><a href="https://nhaccutienmanh.vn/cho-thue-phong-tap-band/">Cho Thuê Phòng
            Band</a></li>
        <li class="menu-item"><a href="https://nhaccutienmanh.vn/bai-viet/">Bài viết</a></li>
        <?php
    $taxonomy= 'product_cat';
                    foreach( get_terms( $taxonomy, array( 'hide_empty' => false, 'parent' => 0, 'exclude' => 15 ) ) as $parent_term ) {
                  $ooo =	 get_term_children( $parent_term->term_id, $taxonomy ); 
      ?>
        <li class="<?php if(is_array($ooo)){ echo 'menu-item-has-children'; } ?> menu-item">
          <a href="<?php echo esc_url( get_term_link( $parent_term ) ); ?>" class="woodmart-nav-link">
            <span><?php echo $parent_term->name; ?></span>
          </a>
          <?php
  if(is_array($ooo)){ ?>
          <div class="sub-menu-dropdown color-scheme-dark">
            <div class="container">
              <ul class="sub-menu color-scheme-dark">
                <?php  foreach( get_terms( $taxonomy, array( 'hide_empty' => false, 'parent' => $parent_term->term_id ) ) as $child_term ) { ?>
                <li class="menu-item">
                  <a href="<?php echo esc_url( get_term_link( $child_term ) ); ?>">
                    <span><?php echo $child_term->name; ?></span>
                  </a>
                </li>
                <?php } ?>
              </ul>
            </div>
          </div>
          <?php } ?>
        </li>
        <?php } ?>
      </ul>
    </div>
  </div>

Get submenu và show ra bằng shortcode

function shortcode_showcat_in_submenu($ts) {
ob_start();
 extract(shortcode_atts(array(
      'id' => 00,
 ),$ts ) );
$taxonomyName = "product_cat";
$parent_terms = get_terms(array('taxonomy' => $taxonomyName,'hide_empty' => 0, 'parent' => $id));   
$countchildren = count($parent_terms);
$col_cat = round($countchildren / 2);
    $col2_cat = $col_cat+1;
    $n_n = 1;
if($countchildren!=0):
foreach($parent_terms as $pterm){
        if($n_n == 1) echo '<div class="col-left">';
        if($n_n == $col2_cat) echo '<div class="col-right">';
  $zzterm_1 = get_term_by( 'id', $pterm->term_id, $taxonomyName );       
    echo '<a class="cat-link cat-lv1" href="' . get_term_link( $pterm, $taxonomyName ) . '">' . $zzterm_1->name . '</a>';
    
    $child_terms = get_terms(array('taxonomy' => $taxonomyName,'hide_empty' => 0, 'parent' => $zzterm_1->term_id));   
    foreach ( $child_terms as $cterm ) {
        $zzterm_2 = get_term_by( 'id', $cterm->term_id, $taxonomyName );   
    echo '<a class="cat-link cat-lv2" href="' . get_term_link( $cterm, $taxonomyName ) . '">' . $zzterm_2->name . '</a>';  
    }
        if($n_n == $col_cat) echo '</div>';
        if($n_n == $countchildren) echo '</div>';
        $n_n ++;
}
endif;
return ob_get_clean();
}
add_shortcode( 'category_content', 'shortcode_showcat_in_submenu' );

Add submenu vào menu admin trong phần mô tả

[category_content id=18]

CSS cho submenu

span.color-scheme-light {
    -webkit-transition: all .25s ease, height 0s ease;
    -o-transition: all .25s ease, height 0s ease;
    transition: all .25s ease, height 0s ease;
    font-weight: 700;
    font-size: 14px;
    padding: 10px 15px;
    background-color: #333;
    color: #fff;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    text-transform: uppercase;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}

span.menu-open-label {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    color: #fff;
    font-size: 16px;
    line-height: 1.5em;
    font-weight: 500;
}

span.color-scheme-light i {
    font-size: 22px;
}

.menu-opener .arrow-opener {
    -webkit-transition: transform .25s ease;
    -webkit-transition: -webkit-transform .25s ease;
    transition: -webkit-transform .25s ease;
    -o-transition: transform .25s ease;
    transition: transform .25s ease;
    transition: transform .25s ease, -webkit-transform .25s ease;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.menu-opener .arrow-opener:after {
    content: "\f107";
    -moz-osx-font-smoothing: grayscale;
    -webkit-font-smoothing: antialiased;
    display: inline-block;
    font-style: normal;
    font-variant: normal;
    font-weight: 400;
    font-family: "Font Awesome 5 Free";
    font-size: inherit;
    text-rendering: auto;
}

.vertical-navigation {
    position: relative;
}

.header-categories-nav .categories-menu-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 299;
    visibility: hidden;
    opacity: 0;
    margin-top: 9px;
}

.main-header .header-categories-nav.opened-menu .categories-menu-dropdown,
.site-header:not(.hnc-sticked) .header-categories-nav.opened-menu .categories-menu-dropdown {
    visibility: visible;
    opacity: 1;
}

.header-categories-nav .categories-menu-dropdown .menu {
    list-style: none;
    line-height: 1.5em;
    border: 1px solid rgba(129, 129, 129, .2);
    background-color: #fff;
    margin: 0;
    padding: 0;
}

.vertical-navigation ul li:not(:last-child) {
    display: block;
    margin-bottom: 0;
    border-bottom: 1px dashed #d2d2d2;
}

.header-categories-nav .categories-menu-dropdown ul li>a {
    font-size: 15px;
    font-weight: 500;
    padding: 5px 6px 6px;
    text-transform: capitalize;
    color: #333;
    line-height: 1.5em;
    -webkit-transition: all .2s ease;
    -o-transition: all .2s ease;
    transition: all .2s ease;
    display: block;
    text-decoration: none;
    position: relative;
}

.tmm-navigation .category-icon,
.hnc-mobile-nav .category-icon {
    margin-right: 6px;
    max-height: 24px;
    width: auto;
    display: inline-block;
    vertical-align: bottom;
}

.vertical-navigation .menu-item-object-product_cat:hover>a {
    background-color: #f1f1f9;
    color: #000;
    -webkit-transition: all .2s ease;
    -o-transition: all .2s ease;
    transition: all .2s ease;
    padding-left: 10px;
}

.categories-menu-dropdown>#menu-categories-container>ul#menu-categories>li>a:before {
    content: "";
    width: 3px;
    height: 0;
    background: var(--second-bg-color);
    position: absolute;
    top: 0;
    left: 0;
    -webkit-transition: all .2s;
    -o-transition: all .2s;
    transition: all .2s;
}

.categories-menu-dropdown>#menu-categories-container>ul#menu-categories>li>a:hover:before {
    height: 100%;
}

.vertical-navigation .item-event-hover>a:after {
    content: "\f105";
    -moz-osx-font-smoothing: grayscale;
    -webkit-font-smoothing: antialiased;
    display: inline-block;
    font-style: normal;
    font-variant: normal;
    font-weight: 400;
    font-family: "Font Awesome 5 Free";
    font-size: inherit;
    text-rendering: auto;
    position: absolute;
    top: 50%;
    margin-top: -7px;
    margin-left: 0;
    right: 10px;
    line-height: 14px;
    color: rgba(82, 82, 82, .45);
}

.vertical-navigation .sub-menu-dropdown {
    z-index: 380;
    text-align: left;
    background-position: bottom right;
    background-repeat: no-repeat;
    background-clip: border-box;
    background-color: #f1f1f9;
    position: absolute;
    left: 100%;
    top: 0;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    width: 800px;
    padding: 15px;
    margin: 0;
    -webkit-transition: opacity 0s ease, visibility 0s ease, -webkit-transform 0s ease;
    transition: opacity 0s ease, visibility 0s ease, -webkit-transform 0s ease;
    -o-transition: opacity 0s ease, visibility 0s ease, transform 0s ease;
    transition: opacity 0s ease, visibility 0s ease, transform 0s ease;
    transition: opacity 0s ease, visibility 0s ease, transform 0s ease, -webkit-transform 0s ease;
    -webkit-transform: translateX(-15px) translateZ(0);
    transform: translateX(-15px) translateZ(0);
}

.item-event-hover:hover>.sub-menu-dropdown {
    visibility: visible;
    opacity: 1;
    pointer-events: visible;
    pointer-events: unset;
    -webkit-transform: none;
    -ms-transform: none;
    transform: none;
}


.col-left,
.col-right {
    width: 49%;
    display: block;
    float: left;
}

.col-left {
    margin-right: 2%;
}


.col-left a.cat-link,
.col-right a.cat-link {
    margin: 0;
    padding: 0 0 3px 0;
    text-align: left;
    border: 0;
    font-size: 14px;
    line-height: 18px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
}

a.cat-link:before {
    content: '';
    display: inline-block;
    margin-right: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #3a3a3a;
}

.col-left a.cat-link.cat-lv1:before,
.col-right a.cat-link.cat-lv1:before {
    display: none;
}

.col-left a.cat-link.cat-lv1,
.col-right a.cat-link.cat-lv1 {
    margin-top: 10px;
    line-height: 20px;
    list-style: none;
    width: 100%;
    padding: 0;
    font-weight: 500;
    text-transform: capitalize;
    font-size: 15px;
    color: #8e000e;
}

.col-left a.cat-link:first-child,
.col-right a.cat-link:first-child {
    margin-top: 0 !important;
}

.col-left a.cat-link.cat-lv2,
.col-right a.cat-link.cat-lv2 {
    margin-left: 5px;
    font-size: 13px;
    font-weight: 400;
}

.col-left a.cat-link:hover,
.col-right a.cat-link:hover {
    color: var(--main-bg-color);
}

.hnc-main-navigation ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.hnc-main-navigation ul li {
    display: inline-block;
    position: static;
}

.hnc-main-navigation ul li a {
    padding: 5px 15px;
    font-size: 15px;
    color: #000;
    font-weight: 500;
    text-decoration: none;
    height: 44px;
    line-height: 36px;
    display: block;
    -webkit-transition: all .25s ease;
    -o-transition: all .25s ease;
    transition: all .25s ease;
}

.hnc-main-navigation ul li:hover a,
.hnc-main-navigation ul li a.current_page_item {
    color: #fff;
    background: var(--second-bg-color);
}

.hnc-main-header {
    position: relative;
  }


Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773

(Wordpress) JS Full Tiến Mạnh

<script>
    jQuery(document).ready(function($) {
    
    
    var $mapSrc;
    $('.map_link').click(function () {
        $mapSrc = $(this).data("src");
    });
    $('#myMaps').on('shown.bs.modal', function (e) {
        $(".embed-maps-item").attr('src', $mapSrc);
    });
    $('#myMaps').on('hidden.bs.modal', function (e) {
        $(".embed-maps-item").attr('src', "");
    });
    
    
     $(".header-categories-nav").hover(function() { 
                $(".box_overlay").css("visibility", "visible"); 
                $(".box_overlay").css("opacity", "1"); 
            }, function() { 
                $(".box_overlay").css("visibility", "hidden"); 
                $(".box_overlay").css("opacity", "0"); 
            }); 
  

        var body = $("body"),
            mobileNav = $(".hnc-mobile-nav"),
            dropDownCat = $(".hnc-mobile-nav .site-mobile-menu .menu-item-has-children"),
            elementIcon = '<span class="icon-sub-menu"></span>',
            butOpener = $(".icon-sub-menu"),
            btnNav = $(".fa-bars"),
     	btnNavClose = $(".fa-times");

        var closeSide = $('.tmm-close-side');

        dropDownCat.append(elementIcon);

        mobileNav.on("click", ".icon-sub-menu", function(e) {
            e.preventDefault();

            if ($(this).parent().hasClass("opener-page")) {
                $(this).parent().removeClass("opener-page").find("> ul").slideUp(200);
                $(this).parent().removeClass("opener-page").find(".sub-menu-dropdown .container > ul, .sub-menu-dropdown > ul").slideUp(200);
                $(this).parent().find('> .icon-sub-menu').removeClass("up-icon");
            } else {
                $(this).parent().addClass("opener-page").find("> ul").slideDown(200);
                $(this).parent().addClass("opener-page").find(".sub-menu-dropdown .container > ul, .sub-menu-dropdown > ul").slideDown(200);
                $(this).parent().find('> .icon-sub-menu').addClass("up-icon");
            }
        });


        body.on("click", ".mobile-nav-icon", function() {

            if (mobileNav.hasClass("active-mobile-menu")) {
                closeMenu();
            } else {
                openMenu();
            }

        });

        body.on("click touchstart", ".hnc-close-side", function() {
            closeMenu();
        });


        function openMenu() {
            mobileNav.addClass("active-mobile-menu");
            closeSide.addClass('hnc-close-side-opened');
      btnNav.removeClass('d-block');
      btnNav.addClass('d-none');
      btnNavClose.removeClass('d-none');
      btnNavClose.addClass('d-block');
        }

        function closeMenu() {
            mobileNav.removeClass("active-mobile-menu");
            closeSide.removeClass('hnc-close-side-opened');
      btnNav.removeClass('d-none');
      btnNav.addClass('d-block');
      btnNavClose.removeClass('d-block');
      btnNavClose.addClass('d-none');
        }

        var $header = $('.site-header');
    var verticalNavigation = $('#menu-categories-container').outerHeight();
           

        $('.categories-menu-dropdown .sub-menu-dropdown').css({
            minHeight: verticalNavigation
        });

        stickyHeader = function() {
            var scrollTop = $(window).scrollTop();
            if (scrollTop > 160) {
                $header.addClass('hnc-sticked');
            } else {
                $header.removeClass('hnc-sticked');
            }
        };
        $(window).on('scroll', function() {
            stickyHeader();
        });

        if ($('#hnc-to-top').length) {
            var scrollTrigger = 100, // px
                backToTop = function() {
                    var scrollTop = $(window).scrollTop();
                    if (scrollTop > scrollTrigger) {
                        $('#hnc-to-top').addClass('show');
                    } else {
                        $('#hnc-to-top').removeClass('show');
                    }
                };
            backToTop();
            $(window).on('scroll', function() {
                backToTop();
            });
            $('#hnc-to-top').on('click', function(e) {
                e.preventDefault();
                $('html,body').animate({
                    scrollTop: 0
                }, 700);
            });
        }
    
    
    
    
    
    var widget = $('.cart-widget-opener'),
            btn = widget.find('.site-header__cart-toggle'),
            body = $('body');

        var cartWidgetSide = $('.hnc-cart-side');
        var closeSide = $('.hnc-close-side');

        widget.on('click', function(e) {
            if ( ! isCart() && ! isCheckout() ) e.preventDefault();

            if( isOpened() ) {
                closeWidget();
            } else {
                setTimeout( function() {
                    openWidget();
                }, 10);
            }

        });

        body.on("click touchstart", ".hnc-close-side", function() {
            if( isOpened() ) {
                closeWidget();
            }
        });

        body.on("click", ".hnc-close-side-widget", function( e ) {
            e.preventDefault();
            if( isOpened() ) {
                closeWidget();
            }
        });


        body.on('click', 'a.add_to_cart_button', function(){
              setTimeout( function() {
                  openWidget();
              }, 800);
        });

        $( document ).keyup( function( e ) {
            if ( e.keyCode === 27 && isOpened() ) closeWidget();
        });

        var closeWidget = function() {
            cartWidgetSide.removeClass('hnc-cart-opened');
            closeSide.removeClass('hnc-close-side-opened');
        };

        var openWidget = function() {
            if ( isCart() || isCheckout() ) return false;
            cartWidgetSide.addClass('hnc-cart-opened');
            closeSide.addClass('hnc-close-side-opened');
        };

        var isOpened = function() {
            return cartWidgetSide.hasClass('hnc-cart-opened');
        };

        var isCart = function() {
            return $('body').hasClass('hnc-cart');
        };

        var isCheckout = function() {
            return $('body').hasClass('hnc-checkout');
        };
    
    $("#hnc-brand-list .more").click(function() {
        $("#hnc-brand-list .item").removeClass( "hide" );
        $(this).hide();
    });
    
    });

</script>



<?php if(is_product()) : ?>
<script>
    'use strict';
    /* global jQuery, PhotoSwipe, PhotoSwipeUI_Default, console */
    (function($){
      // Init empty gallery array
      var container = [];
      // Loop over gallery items and push it to the array
      $('.woocommerce-product-gallery__wrapper').find('.woocommerce-product-gallery__image').each(function(){
        var $link = $(this).find('a img'),
      $link_large = $(this).find('a').attr('href'),
            item = {
              src: $link_large,
              w: $link.data('large_image_width'),
              h: $link.data('large_image_height'),
              title: $link.attr('title')
            };
        container.push(item);
      });
      // Define click event on gallery item
      $('.anh-to-vl').click(function(event){
        // Prevent location change
        event.preventDefault();
        // Define object and gallery options
        var $pswp = $('.pswp')[0],
            options = {
              index: $('.woocommerce-product-gallery__wrapper').parent('.woocommerce-product-gallery__image').index(),
              bgOpacity: 0.9,
              showHideOpacity: true
            };
        // Initialize PhotoSwipe
        var gallery = new PhotoSwipe($pswp, PhotoSwipeUI_Default, container, options);
        gallery.init();
      });
    }(jQuery));
  </script>

<script>
  jQuery(document).ready(function ($) {
  var img_main = $('.anh-to-vl');
  var nav = $('.woocommerce-product-gallery__image');
  var img_first =  nav.first().find('a').attr('href');
if(img_main.find('a').attr('href')==''){
  	img_main.find('a').attr('href', img_first );
  	img_main.find('img').attr('src', img_first );
  nav.first().addClass('current');
  }
  $('.woocommerce-product-gallery__image').on('click', function(e) {
    e.preventDefault();
    var img_click_product = $(this).find('a').attr('href');
  	img_main.find('a').attr('href', img_click_product );
  	img_main.find('img').attr('src', img_click_product );
    
  if(nav.hasClass('current')){
    nav.removeClass('current');
  }
    $(this).addClass('current');
  });
  });
  </script>
<?php endif; ?>


Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773

(Wordpress & ACF) Trang Quản Lý Link

<div class="container table-manager-link">
    <?php 
if(current_user_can('administrator') == 1){	
$args = array(
        'post_type' => 'post',
         'posts_per_page' => 20,
        'paged' => $paged,
 		'post_status' => 'publish',
 );
      $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
 $query = new WP_Query( $args ); ?>
    <div class='manager-link d-block'>
        <div class="row">
            <div style="width: 15%">Tiêu đề</div>
            <div style="width: 57%">Sửa link</div>
            <div style="width: 20%">Cập nhật</div>
            <div style="width: 8%">Thông báo</div>
        </div>
        <?php if( $query->have_posts() ) : while( $query->have_posts() ) : $query->the_post(); global $post; $linkdown_count = get_post_meta( get_the_ID(), 'linkdown', true ) ?>
        <div class="row row-<?php the_ID(); ?> form-group">
            <div style="width: 15%"><a href="<?php the_permalink(); ?>" target="_blank"><?php the_title(); ?></a></div>
            <div style="width: 57%">
                <?php
if( have_rows('linkdown') ):;
    while ( have_rows('linkdown') ) : the_row(); 
$url = get_sub_field('url');
$headers = @get_headers($url); 
if($headers && strpos( $headers[0], '200')) { 
    $status = ""; 
} 
else { 
    $status = '<button class="btn btn-danger">404</button>'; 
} 
?>
                <div class="link-row d-inline-flex w-100">
                    <input type="text" class="form-control form-control-sm link_ten"
                        value="<?php the_sub_field('ten'); ?>" disabled data-id="<?php the_ID(); ?>" />
                    <input type="text" class="form-control form-control-sm link_url" value="<?php echo $url; ?>"
                        data-code="<?php echo $info['http_code']; ?>" disabled data-id="<?php the_ID(); ?>" />
                    <a class="btn text-white" href="<?php the_sub_field('url'); ?>" target="_blank"><i
                            class="fa fa-eye"></i></a>
                    <?php echo $status; ?>
                </div>
                <?php endwhile; 
else :
  echo 'Không có link';
endif; ?>
            </div>
            <div style="width: 20%">
                <?php 
  $report_download_link = get_post_meta( get_the_ID(), 'report_download_link', true );
  if($linkdown_count){ ?>
                <a class="btn btn-sm btn-enable-field text-white" href="#" data-id="<?php the_ID(); ?>">Bật sửa</a>
                <a class="btn btn-sm btn-update-link text-white" href="#" data-id="<?php the_ID(); ?>">Cập nhật</a>
                <?php } ?>
                <a class="btn btn-sm text-white" href="<?php echo get_edit_post_link(); ?>" data-id="<?php the_ID(); ?>"
                    target="_blank">Sửa bài viết</a>
                <?php if($report_download_link > 0){
            echo '<button class="btn btn-sm btn-danger">Có Người Báo Link Die!</button>';
          } ?>
            </div>
            <div style="width: 8%">
                <div class="mess-log"></div>
            </div>
        </div>
        <?php endwhile;  ?>
        <div class="pagination wp-pagenavi d-block text-center" style="margin-top: 30px">
            <?php 
        echo paginate_links( array(
            'base'         => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
            'total'        => $query->max_num_pages,
            'current'      => max( 1, get_query_var( 'paged' ) ),
            'format'       => '?paged=%#%',
            'show_all'     => false,
            'type'         => 'plain',
            'end_size'     => 2,
            'mid_size'     => 1,
            'prev_next'    => true,
            'prev_text'    => sprintf( '<button class="btn btn-sm text-white">%1$s</button>', __( 'Trước', 'text-domain' ) ),
            'next_text'    => sprintf( '<button class="btn btn-sm text-white">%1$s</button>', __( 'Sau', 'text-domain' ) ),
            'add_args'     => false,
            'add_fragment' => '',
        ) );
    ?>
        </div>
        <?php wp_reset_postdata(); endif; ?>
    </div>
    <?php } ?>
</div>


Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773

(Woocommerce) Lọc sản phẩm nổi bật trong trang admin

function wpa104537_filter_products_by_featured_status() {
global $typenow, $wp_query;
if ($typenow=='product') :
   // Featured/ Not Featured
   $output .= "<select name='featured_status' id='dropdown_featured_status'>";
   $output .= '<option value="">'.__( 'Tình trạng nổi bật', 'woocommerce' ).'</option>';
   $output .="<option value='featured' ";
   if ( isset( $_GET['featured_status'] ) ) $output .= selected('featured', $_GET['featured_status'], false);
   $output .=">".__( 'Nổi bật', 'woocommerce' )."</option>";
   $output .="<option value='normal' ";
   if ( isset( $_GET['featured_status'] ) ) $output .= selected('normal', $_GET['featured_status'], false);
   $output .=">".__( 'Không nổi bật', 'woocommerce' )."</option>";
   $output .="</select>";
   echo $output;
endif;
}
add_action('restrict_manage_posts', 'wpa104537_filter_products_by_featured_status');
function wpa104537_featured_products_admin_filter_query( $query ) {
global $typenow;
if ( $typenow == 'product' ) {
   // Subtypes
   if ( ! empty( $_GET['featured_status'] ) ) {
     if ( $_GET['featured_status'] == 'featured' ) {
       $query->query_vars['tax_query'][] = array(
         'taxonomy' => 'product_visibility',
         'field'    => 'slug',
         'terms'    => 'featured',
       );
     } elseif ( $_GET['featured_status'] == 'normal' ) {
       $query->query_vars['tax_query'][] = array(
         'taxonomy' => 'product_visibility',
         'field'    => 'slug',
         'terms'    => 'featured',
         'operator' => 'NOT IN',
       );
     }
   }
}
}
add_filter( 'parse_query', 'wpa104537_featured_products_admin_filter_query' );


Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773

(Woocommerce) Tùy biến sắp xếp sản phẩm trong danh mục sản phẩm

function patricks_woocommerce_catalog_orderby( $orderby ) {
  unset($orderby["popularity"]);
  unset($orderby["rating"]);
  return $orderby;
}
add_filter( "woocommerce_catalog_orderby", "patricks_woocommerce_catalog_orderby", 20 );


Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773

(Woocommerce) Hiển thị sản phẩm trong đơn hàng

add_filter('manage_edit-shop_order_columns', 'misha_order_items_column' );
function misha_order_items_column( $order_columns ) {
    $order_columns['order_products'] = "Sản phẩm trong đơn";
    return $order_columns;
}
add_action( 'manage_shop_order_posts_custom_column' , 'misha_order_items_column_cnt' );
function misha_order_items_column_cnt( $colname ) {
  global $the_order; // the global order object
 
 	if( $colname == 'order_products' ) {
 
    // get items from the order global object
    $order_items = $the_order->get_items();
 
    if ( !is_wp_error( $order_items ) ) {
      foreach( $order_items as $order_item ) {
 
 				echo $order_item['quantity'] .' × <a href="' . admin_url('post.php?post=' . $order_item['product_id'] . '&action=edit' ) . '">'. $order_item['name'] .'</a><br />';
        // you can also use $order_item->variation_id parameter
        // by the way, $order_item['name'] will display variation name too
 
      }
    }
 
  }
 
}


Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773

(Woocommerce) Clean woocommerce

function grd_woocommerce_script_cleaner() {
  // Remove the generator tag
  remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
  // Unless we're in the store, remove all the cruft!
  if ( ! is_woocommerce() && ! is_cart() && ! is_checkout() ) {
    wp_dequeue_style( 'woocommerce_frontend_styles' );
    wp_dequeue_style( 'woocommerce-general');
    wp_dequeue_style( 'woocommerce-layout' );
    wp_dequeue_style( 'woocommerce-smallscreen' );
    wp_dequeue_style( 'woocommerce_fancybox_styles' );
    wp_dequeue_style( 'woocommerce_chosen_styles' );
    wp_dequeue_style( 'woocommerce_prettyPhoto_css' );
    wp_dequeue_script( 'selectWoo' );
    wp_deregister_script( 'selectWoo' );
    wp_dequeue_script( 'wc-add-payment-method' );
    wp_dequeue_script( 'wc-lost-password' );
    wp_dequeue_script( 'wc_price_slider' );
    wp_dequeue_script( 'wc-single-product' );
    wp_dequeue_script( 'wc-add-to-cart' );
    wp_dequeue_script( 'wc-cart-fragments' );
    wp_dequeue_script( 'wc-credit-card-form' );
    wp_dequeue_script( 'wc-checkout' );
    wp_dequeue_script( 'wc-add-to-cart-variation' );
    wp_dequeue_script( 'wc-single-product' );
    wp_dequeue_script( 'wc-cart' );
    wp_dequeue_script( 'wc-chosen' );
    wp_dequeue_script( 'woocommerce' );
    wp_dequeue_script( 'prettyPhoto' );
    wp_dequeue_script( 'prettyPhoto-init' );
    wp_dequeue_script( 'jquery-blockui' );
    wp_dequeue_script( 'jquery-placeholder' );
    wp_dequeue_script( 'jquery-payment' );
    wp_dequeue_script( 'fancybox' );
    wp_dequeue_script( 'jqueryui' );
  }
}
add_action( 'wp_enqueue_scripts', 'grd_woocommerce_script_cleaner', 99 );


Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773

(Woocommerce) Tùy chỉnh beadcrumb của woo

add_filter( 'woocommerce_breadcrumb_defaults', 'hnc_woocommerce_breadcrumbs' );
function hnc_woocommerce_breadcrumbs() {
    return array(
      'delimiter'   => '<img class="delimiter" src="'.get_template_directory_uri().'/images/bul_navi.png"/>',
      'home'        => _x( '<i class="fas fa-home"></i>', 'breadcrumb', 'woocommerce' ),
            'wrap_before' => '<nav class="woocommerce-breadcrumb" itemprop="breadcrumb">',
            'wrap_after'  => '</nav>',
            'before'      => '',
            'after'       => '',
        );
}


Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773

(Plugin) Crack WP Content Crawler

– Giải nén Plugin và cài đặt Plugin vào Website tìm file trong trình sửa plugin trên Dashboard Admin WP theo đường dẫn sau:

wp-content-crawler\app\WPTSLMClient.php

– Tìm đến dòng: private function setValid($value)

Sửa cả cụm thành như sau:

private function setValid($value) {
  $value = '1';
  update_option($this->getValidOptionName(), base64_encode($value), true);    
}

Tìm tiếp dòng: private function getValid() 

Sửa cả cụm thành như sau:

private function getValid() {
  return '1';
}

– Vô hosting và phân quyền / Chmod cho file WPTSLMClient.php (wp-content-crawler\app\WPTSLMClient.php) trong plugin về 444 (Mục đích là Không thể sửa file)

– Truy cập Setting > License Settings for Content Crawler > Điền số bất kỳ > Ấn Save Change !

TẢI XUỐNG PLUGIN



Deprecated: wp_make_content_images_responsive đã bị loại bỏ từ phiên bản 5.5.0! Hãy sử dụng wp_filter_content_tags(). in /home/hnamblo1/public_html/wp-includes/functions.php on line 4773