Server : Apache/2 System : Linux vps.sdns.vn 3.10.0-1160.15.2.el7.x86_64 #1 SMP Wed Feb 3 15:06:38 UTC 2021 x86_64 User : phatdatpq ( 1022) PHP Version : 7.2.34 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/phatdatpq/domains/phatdatphuquy.com/public_html/wp-content/themes/dien-may-xanh/ |
Upload File : |
<?php // Add custom Theme Functions here require_once('myattr/init.php'); function temner_editor_for_woo($can_edit, $post_type) { if ($post_type == 'product') { $can_edit = true; } return $can_edit; } function isures_thumbnail_element( $name ) { return get_stylesheet_directory_uri() . '/images/thumbnail-isures/' . $name . '.svg'; } add_filter('use_block_editor_for_post_type', 'temner_editor_for_woo', 10, 2); function wc_product_category_add_tax_to_api() { $mytax = get_taxonomy('product_cat'); $mytax->show_in_rest = true; } add_action('init', 'wc_product_category_add_tax_to_api', 30); add_action('after_setup_theme', 'res_menu_isures'); function res_menu_isures() { register_nav_menus(array( 'isures_menu' => __('Vertical Menu', 'flatsome'), )); } add_filter('flatsome_header_element', 'create_menu_element'); function create_menu_element($nav_elements) { $nav_elements['vertical-menu-isures'] = __('<span style="background-color: #189eff">iSures Menu</span>', 'flatsome-admin'); return $nav_elements; } function isures_menu_get_option($key, $default = '') { $options = get_option('ot_vm'); $option = isset($options[$key]) ? $options[$key] : $default; return $option; } add_action('flatsome_header_elements', 'mega_menu_template'); function mega_menu_template($value) { $menu_title = isures_menu_get_option('menu_title', __('Danh mục sản phẩm', 'flatsome')); $menu_event = isures_menu_get_option('menu_event', 'hover'); $show_mega = isures_menu_get_option('show_mega', 0); if ($value == 'vertical-menu-isures') { ?> <div id="vertical-menu-isures" class="isures-wrap-<?php echo $menu_event; ?><?php echo ($show_mega ? ' is-mega' : ''); ?>"> <div id="mega-menu-title"> <i class="icon-menu"></i> <?php echo $menu_title; ?> </div> <?php wp_nav_menu(array( 'theme_location' => 'isures_menu', 'container' => true, 'menu_id' => 'isures_menu', 'menu_class' => 'is-container', 'depth' => 0, )); ?> </div> <?php } } // add_filter('flatsome_header_element', 'isures_recently_product'); function isures_recently_product($nav_elements) { $nav_elements['recently-isures'] = __('<span style="background-color: #189eff">Recently Product</span>', 'flatsome-admin'); return $nav_elements; } function set_user_visited_product_cookie() { 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) > 22) { array_shift($viewed_products); } wc_setcookie('woocommerce_recently_viewed', implode('|', $viewed_products)); } add_action('wp', 'set_user_visited_product_cookie'); add_action('flatsome_header_elements', 'get_recently_product_func'); function get_recently_product_func($value) { if ($value == 'recently-isures') { $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))); ?> <div id="isures-recently-wrap"> <span class="title-recently">Sản phẩm đã xem<i class="dashicons dashicons-arrow-down"></i></span> <div class="isures-container"> <?php if (!empty($viewed_products)) { foreach ($viewed_products as $values) { $product = wc_get_product($values); $image_id = $product->get_image_id(); $image_url = wp_get_attachment_image_url($image_id, 'full'); $product_title = $product->get_title(); ?> <a class="thumb-recently" href="<?php the_permalink($values); ?>" title="<?php echo $product_title; ?>"> <img width="65" src="<?php echo $image_url; ?>" alt="<?php echo $product_title; ?>"> <span><?php echo $product_title; ?></span> </a> <?php } } else { ?> <div class="nopro"><img src="/wp-content/uploads/2020/08/nopro.png" alt="Không có sản phẩm"> <span>Bạn chưa xem sản phẩm nào</span> </div> <?php } ?> </div> </div> <?php } } add_action('wp_enqueue_scripts', 'isures_js'); function isures_js() { wp_enqueue_script('custom-js-isures', get_stylesheet_directory_uri() . '/js/all-min-js.js', array('jquery'), '1.0', true); if(is_product()){ wp_enqueue_style('product-styles', get_stylesheet_directory_uri() . '/product.css', '1.0', true); } wp_enqueue_style('font-awesome-isures', get_stylesheet_directory_uri() . '/css/all.min.css', '1.0', true); wp_enqueue_style( 'dashicons' ); } function post_category() { add_ux_builder_shortcode('post_in_cate_custom', array( 'name' => __('Post iSures'), 'priority' => -2, 'category' => __( 'isures.com' ), 'thumbnail' => isures_thumbnail_element('post-in-cat'), 'options' => array( 'title_cat' => array( 'type' => 'textfield', 'heading' => __('Tiệu đề Element'), 'default' => '', ), 'post_options' => array( 'type' => 'group', 'heading' => __('Option Post Feature'), 'options' => array( 'ids' => array( 'type' => 'select', 'heading' => 'Tuỳ chọn bài viết', 'param_name' => 'ids', 'config' => array( 'multiple' => true, 'placeholder' => 'Select..', 'postSelect' => array( 'post_type' => array('post') ), ) ), 'cat' => array( 'type' => 'select', 'heading' => 'Chuyên mục', 'param_name' => 'cat', 'conditions' => 'ids === ""', 'default' => '', 'config' => array( 'multiple' => true, 'placeholder' => 'Select...', 'termSelect' => array( 'post_type' => array('category'), 'taxonomies' => array('category'), ), ) ), ), ), 'quarity' => array( 'type' => 'textfield', 'heading' => 'Số bài', 'default' => '2' ), 'style_front' => array( 'type' => 'radio-buttons', 'heading' => __('Dạng hiện thị'), 'default' => 'vertical', 'options' => array( 'horizontal' => array('title' => 'Ngang'), 'vertical' => array('title' => 'Dọc'), ), ), ), )); } add_action('ux_builder_setup', 'post_category'); function post_category_shortcode($atts, $content = null) { extract(shortcode_atts(array( '_id' => 'row-' . rand(), 'ids' => false, // Custom IDs 'cat' => '', 'category' => '', 'title_cat' => '', 'quarity' => '2', 'style_front' => 'vertical', ), $atts)); $args = array( 'post_status' => 'publish', 'post_type' => array('post'), 'cat' => $cat, 'posts_per_page' => $quarity, 'ignore_sticky_posts' => true, ); ob_start(); if (get_theme_mod('flatsome_fallback', 0) && $category) { $args['category_name'] = $category; } // IF custom post type taxonomy isset if (!empty($cat)) { $cat = explode(',', $cat); $args = array( 'post_status' => 'publish', 'post_type' => array('post'), 'posts_per_page' => $quarity, 'ignore_sticky_posts' => true, 'tax_query' => array( 'relation' => 'OR', array( 'taxonomy' => 'category', // the custom vocabulary 'terms' => $cat, // provide the term slugs 'operator' => 'IN', ), ), ); } // If custom ids if (!empty($ids)) { $ids = explode(',', $ids); $ids = array_map('trim', $ids); $args = array( 'post__in' => $ids, 'post_type' => array( 'post', 'featured_item', // Include for its tag archive listing. ), 'numberposts' => -1, 'orderby' => 'post__in', 'posts_per_page' => 99999, 'ignore_sticky_posts' => true, ); } $recentPosts = new WP_Query($args); echo '<div class="feature-post">'; if (!empty($title_cat)) { echo '<div class="title-feature"> <span>' . $title_cat . '</span> </div>'; } if ($recentPosts->have_posts()) : echo '<ul class="isures-list-post ' . $style_front . '">'; while ($recentPosts->have_posts()) : $recentPosts->the_post(); echo '<li>'; ?> <a href="<?php echo get_the_permalink(); ?>"> <?php echo get_the_title(); ?> <?php if ($style_front == 'horizontal') { ?><span class="dot livestream"><span class="ping"></span></span><?php } ?> </a> <?php echo '</li>'; endwhile; echo '</ul>'; endif; wp_reset_query(); echo '</div>'; $content = ob_get_contents(); ob_end_clean(); return $content; } add_shortcode('post_in_cate_custom', 'post_category_shortcode'); add_filter('woocommerce_product_data_tabs', function($tabs) { $tabs['additional_info'] = [ 'label' => __('Thông tin thêm', 'txtdomain'), 'target' => 'additional_product_data', //'class' => ['hide_if_external'], 'priority' => 5 ]; return $tabs; }); // // // Thêm field vào quản trị sản phẩm //add_action('woocommerce_product_options_general_product_data', 'woocommerce_product_add_fields'); add_action('woocommerce_product_data_panels','mtwoocommerce_product_add_fields'); function mtwoocommerce_product_add_fields() { global $woocommerce; echo '<div id="additional_product_data" class="panel woocommerce_options_panel wc_cpdf_tab">'; //Khuyến mãi woocommerce_wp_textarea_input( array( 'id' => '_textarea_sale', 'label' => __('Khuyến mãi', 'temner'), 'placeholder' => 'Ngăn cách mỗi dòng bằng dấu ;', ) ); //Thông số kỹ thuật woocommerce_wp_textarea_input( array( 'id' => '_textarea_param', 'label' => __('Ưu đãi thêm', 'temner'), 'placeholder' => 'Ngăn cách mỗi dòng bằng dấu ;', ) ); //Trả góp hay không woocommerce_wp_textarea_input( array( 'id' => '_tra_gop', 'label' => __('Label trả góp', 'temner'), 'placeholder' => 'Ví dụ: trả góp với 0%', ) ); //Trong hộp gồm woocommerce_wp_textarea_input( array( 'id' => '_in_box', 'label' => __('Trong hộp gồm có', 'temner'), 'placeholder' => '', ) ); woocommerce_wp_checkbox( array( 'id' => '_yes_no_tra_gop', 'label' => __('Hiện nút trả góp hay không', 'temner'), ) ); echo '</div>'; } function woocommerce_product_fields_save($post_id) { // Lưu - Khuyến mãi $woocommerce_procut_textarea_km = $_POST['_textarea_sale']; if (!empty($woocommerce_procut_textarea_km)) update_post_meta($post_id, '_textarea_sale', esc_html($woocommerce_procut_textarea_km)); // Lưu - thông số kỹ thuật $woocommerce_procut_textarea_param = $_POST['_textarea_param']; if (!empty($woocommerce_procut_textarea_param)) update_post_meta($post_id, '_textarea_param', esc_attr($woocommerce_procut_textarea_param)); //Lưu trả góp $woocommerce_procut_textarea_tra_gop = $_POST['_tra_gop']; if (!empty($woocommerce_procut_textarea_tra_gop)) update_post_meta($post_id, '_tra_gop', esc_html($woocommerce_procut_textarea_tra_gop)); //lưu in box $woocommerce_procut_textarea_in_box = $_POST['_in_box']; if (!empty($woocommerce_procut_textarea_in_box)) update_post_meta($post_id, '_in_box', esc_html($woocommerce_procut_textarea_in_box)); // Lưu checkbox co mua tra gop hay ko $woocommerce_wp_checkbox_tem = $_POST['_yes_no_tra_gop']; if (!empty($woocommerce_wp_checkbox_tem)) update_post_meta($post_id, '_yes_no_tra_gop', esc_html($woocommerce_wp_checkbox_tem)); } add_action('woocommerce_process_product_meta', 'woocommerce_product_fields_save'); // nut tra gop front end function btn_tra_gop() { $button_tra_gop = get_post_meta(get_the_ID(), '_yes_no_tra_gop', true); if (!empty($button_tra_gop)) { echo '<a href="#tra-gop" class="button btn-tra-gop"> <strong>Đăng ký trả góp</strong> <span>Lãi suất thấp 0%</span> </a>'; } } add_action('woocommerce_after_add_to_cart_button', 'btn_tra_gop'); function gift_frontend() { // Hiển thị Ưu đãi - Khuyến mãi $product_km_ud = get_post_meta(get_the_ID(), '_textarea_sale', true); if (!empty($product_km_ud)) { $arr_product_km_ud = explode(";", $product_km_ud); echo '<aside class="promotion_wrapper" style="display:block"> <b id="promotion_header">KHUYẾN MÃI</b><div class="khuyenmai-info">'; foreach ($arr_product_km_ud as $value) { echo '<span>' . $value . '</span><br/>'; } echo '</div></aside>'; } } add_action('flatsome_custom_single_product_1', 'gift_frontend'); function installment() { $tra_gop = get_post_meta(get_the_ID(), '_tra_gop', true); if (!empty($tra_gop)) { echo '<span class="installment">' . $tra_gop . '</span>'; } else { return; } } add_action('woocommerce_before_shop_loop_item', 'installment', 10, 0); // //Param product function temner_param() { $param_product = get_post_meta(get_the_ID(), '_textarea_param', true); if (!empty($param_product)) { $arr_param_product = explode(";", $param_product); echo '<aside class="promotion_wrapper-2" style="display:block"> <b>Ưu đãi thêm</b><div class="khuyenmai-info">'; foreach ($arr_param_product as $value) { echo '<span>' . $value . '</span><br>'; } echo '</div></aside>'; } } add_action('flatsome_custom_single_product_2', 'temner_param'); //front end in box function temner_in_box() { $hien_thi_chinh_sach = get_field('hien_thi_chinh_sach'); if($hien_thi_chinh_sach==1){ $doi_tra_qua_dien_thoai = get_field('doi_tra_qua_dien_thoai'); $san_pham_chinh_hang = get_field('san_pham_chinh_hang'); $thoi_gian_doi_tra = get_field('thoi_gian_doi_tra'); $mien_phi_cong_lap_dat = get_field('mien_phi_cong_lap_dat'); $thoi_gian_bao_hanh = get_field('thoi_gian_bao_hanh'); $mien_phu_hut_chan_khong = get_field('mien_phu_hut_chan_khong'); echo '<div class="policy_intuitive"><ul class="policy_new">'; if($san_pham_chinh_hang) { echo '<li><span><i class="icondetailV3-ch-new"></i></span><div class="policy_des"><b>'. $san_pham_chinh_hang .'</b></div></li>'; } if($mien_phi_cong_lap_dat) { echo '<li><span><i class="icondetailV3-ld-new"></i></span><div class="policy_des">'. $mien_phi_cong_lap_dat .'</div></li>'; } if($mien_phu_hut_chan_khong) { echo '<li><span><i class="icondetailV3-ck-new"></i></span><div class="policy_des">'. $mien_phu_hut_chan_khong .'</div></li>'; } if($thoi_gian_doi_tra) { echo '<li><span><i class="icondetailV3-1d1-new"></i></span><div class="policy_des">'. $thoi_gian_doi_tra .'</div></li>'; } if($doi_tra_qua_dien_thoai == 1) { echo '<li><span><i class="icondetailV3-dt-new"></i></span><div class="policy_des">Đổi trả và bảo hành cực dễ <b>chỉ cần số điện thoại</b></div></li>'; } if($thoi_gian_bao_hanh) { echo '<li><span><i class="icondetailV3-bh-new"></i></span><div class="policy_des">'. $thoi_gian_bao_hanh .'</div></li>'; } echo '</ul></div>'; } $in_box = get_post_meta(get_the_ID(), '_in_box', true); if (!empty($in_box)) { $arr_in_box = explode(";", $in_box); echo '<div class="in-box"><strong>Trong hộp gồm</strong>'; foreach ($arr_in_box as $value) { echo '<li>' . $value . '</li>'; } echo '</div>'; } } add_action('flatsome_custom_single_product_3', 'temner_in_box'); function tra_gop() { if (is_singular('product')) : ?> <div id="tra-gop" class="lightbox-by-id lightbox-content mfp-hide lightbox-white"> <div class="row"> <div class="col medium-6"> <?php woocommerce_template_single_title(); ?> <?php woocommerce_template_single_price(); ?> <?php the_post_thumbnail(); ?> </div> <div class="col medium-6"> <?php echo '<strong style="color:#ffb400;">Gửi yêu cầu trả góp</strong><hr>'; ?> <?php echo do_shortcode('[contact-form-7 id="168" title="Form liên hệ 1"]'); ?> </div> </div> </div> <?php endif; } add_action('wp_footer', 'tra_gop'); function sale_image_label() { global $product; if ($product->is_on_sale()) { ?> <div class="iconup"> <?php the_field('khuyenmai'); ?> </div> <?php } } add_action('woocommerce_before_shop_loop_item_title', 'sale_image_label', 10, 0); // function nav_cat_product() { $repeater_posts = 'products'; $repeater_post_type = 'product'; $repeater_post_cat = 'product_cat'; add_ux_builder_shortcode('isures_nav_cat_product', array( 'name' => __('Navigation Cat'), 'category' => __( 'isures.com' ), 'priority' => -1, 'thumbnail' => isures_thumbnail_element('navigation-category'), 'options' => array( 'title_nav' => array( 'type' => 'textfield', 'heading' => 'Tiêu đề', 'default' => '', ), 'cat_sub_title' => array( 'type' => 'select', 'heading' => 'Chọn Sub Title', 'param_name' => 'cat_sub_title', 'default' => '', 'config' => array( 'multiple' => true, 'placeholder' => 'Select...', 'termSelect' => array( 'post_type' => array('product'), 'taxonomies' => array('product_cat'), ), ), ), ), // end option tổng )); } add_action('ux_builder_setup', 'nav_cat_product'); function nav_cat_product_func($atts) { $sliderrandomid = rand(); if (!is_array($atts)) { $atts = array(); } extract(shortcode_atts(array( '_id' => 'product-grid-' . rand(), 'ids' => '', 'title_nav' => '', 'cat_sub_title' => '', ), $atts)); ob_start(); if (isset($atts['cat_sub_title'])) { $ids = explode(',', $atts['cat_sub_title']); $ids = array_map('trim', $ids); } else { $ids = array(); } $args_sub = array( 'taxonomy' => 'product_cat', 'include' => $ids, 'pad_counts' => true, 'child_of' => 0, ); $product_categories = get_terms($args_sub); // dump($product_categories); $show_cat = ''; if ($product_categories) { foreach ($product_categories as $category) { $term_link = get_term_link($category); $thumbnail_id = get_term_meta($category->term_id, 'thumbnail_id', true); if ($thumbnail_id) { $image = wp_get_attachment_url($thumbnail_id); } else { $image = wc_placeholder_img_src(); } $show_cat .= '<li class="isures-sub-title"> <a href="' . $term_link . '" class="load-product-tab" cat_id_tab="' . $category->term_id . '" count_post="' . $category->count . '"> <span>' . $category->name . '</span> </a> </li>'; } } echo '<ul class="isures-nav-cat isures-scroll"> <li class="title-nav-cat"><span>'.$title_nav.'</span></li> ' . $show_cat . ' </ul>'; $content = ob_get_contents(); ob_end_clean(); return $content; } add_shortcode('isures_nav_cat_product', 'nav_cat_product_func'); add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields',999999 ); function custom_override_checkout_fields( $fields ) { unset($fields['billing']['billing_last_name']); unset($fields['billing']['billing_postcode']); unset($fields['billing']['billing_city']); unset($fields['billing']['billing_country']); unset($fields['billing']['billing_state']); unset($fields['billing']['billing_company']); unset($fields['billing']['billing_address_2']); unset($fields['shipping']['shipping_country']); return $fields; } add_filter( 'woocommerce_checkout_fields' , 'rename_feild' ); // Our hooked in function - $fields is passed via the filter! function rename_feild( $fields ) { $fields['billing']['billing_first_name']['placeholder'] = 'Tên của bạn...'; $fields['billing']['billing_first_name']['label'] = 'Họ và Tên: '; $fields['billing']['billing_email']['placeholder'] = 'Nhập email...'; $fields['billing']['billing_email']['label'] = 'Email của bạn: '; $fields['billing']['billing_phone']['placeholder'] = 'Số điện thoại...'; $fields['billing']['billing_phone']['label'] = 'Phone: '; $fields['billing']['billing_address_1']['placeholder'] = 'Địa chỉ nhận hàng...'; $fields['billing']['billing_address_1']['label'] = 'Địa chỉ: '; return $fields; } add_action( 'flatsome_custom_single_product_4', 'wpmu_add_techdata' ); function wpmu_add_techdata() { ?> <?php if(get_field('tech_data')): ?> <div id="thongsokythuat" class="ex_thongso"> <h4 class="section-title section-title-normal"><b></b><span class="section-title-main">Thông số kỹ thuật</span><b></b></h4> <table> <tbody> <?php while(has_sub_field('tech_data')): ?> <tr> <th><?php the_sub_field('title_tech'); ?></th> <td><?php the_sub_field('desc_tech'); ?></td> </tr> <?php endwhile; ?> </tbody> </table> </div> <?php endif; ?> <?php } function disable_plugin_updates( $value ) { if ( isset($value) && is_object($value) ) { if ( isset( $value->response['advanced-custom-fields-pro/acf.php'] ) ) { unset( $value->response['advanced-custom-fields-pro/acf.php'] ); } } return $value; } add_filter( 'site_transient_update_plugins', 'disable_plugin_updates' ); add_filter( 'woocommerce_format_sale_price', 'invert_formatted_sale_price', 10, 3 ); function invert_formatted_sale_price( $price, $regular_price, $sale_price ) { return '<ins>' . ( is_numeric( $sale_price ) ? wc_price( $sale_price ) : $sale_price ) . '</ins> <del>' . ( is_numeric( $regular_price ) ? wc_price( $regular_price ) : $regular_price ) . '</del>'; } function show_rating( $rating_html, $rating, $count ) { $rating_html = '<div class="star-rating star-rating--inline">'; $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 );