403Webshell
Server IP : 103.48.194.25  /  Your IP : 216.73.216.74
Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33
System : Linux VMHostDefault 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64
User : sieuthimay ( 1016)
PHP Version : 7.4.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/khohangtieudung.vn/public_html/wp-content/themes/mtw-shop/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/khohangtieudung.vn/public_html/wp-content/themes/mtw-shop/functions.php
<?php
/* Add style theme */
require_once ('admin/index.php');
//require_once ('functions_cart.php');	//Hiển thị giỏ hàng

if ( !function_exists( 'of_get_option' ) ) {
	function of_get_option($name, $default = false){
		$optionsframework_settings = get_option('optionsframework');
		// Gets the unique option id
		$option_name = $optionsframework_settings['id'];
		if ( get_option($option_name) ) {
			$options = get_option($option_name);
		}
		if ( isset($options[$name]) ) {
			return $options[$name];
		} else {
			return $default;
		}
	}
}

//  Image thumbnail sizes  
function images_website_produc()
{
    add_image_size( 'thumb-home-product', 248, 248, true );
	add_image_size( 'thumb-archive', 278, 180, true );
	add_image_size( 'thumb-archive_311', 311, 200, true );
	//add_image_size( 'thumb-archive_180', 180, 90, true );
	add_image_size( 'thumb-home-news', 540, 335, true );
	add_image_size( 'thumb-home-news-item', 180, 120, true );
}
add_action( 'after_setup_theme', 'images_website_produc' );

// Enable featured image
add_theme_support( 'post-thumbnails' );

// require("inc/functions/breadcrumb.php");
require("inc/functions/widget_woo.php");
require("inc/functions/pagination.php");
 
// Add 	Sidebar
if (function_exists('register_sidebar'))
{
	register_sidebar(array(
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<p class="widgettitle">',
        'after_title' => '</p>',
		'name' => 'Slide home' ,
		'id' => 'slidehome'
    ));
	
	register_sidebar(array(
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<p class="widgettitle">',
        'after_title' => '</p>',
		'name' => 'ADS Home' ,
		'id' => 'adshome'
    ));
	
	register_sidebar(array(
       'name' => 'Home Product' ,
	   'id' => 'homeproduct'
    ));
		
	 register_sidebar(array(
        'before_widget' => '<div class="list-left">',
        'after_widget' => '</div>',
        'before_title' => '<p class="widgettitlefooter">',
        'after_title' => '</p>',
		'name' => 'Widget footer 1'  ,
		'id' => 'footer-1'
    ));
	
	 register_sidebar(array(
        'before_widget' => '<div class="list-left">',
        'after_widget' => '</div>',
        'before_title' => '<p class="widgettitlefooter">',
        'after_title' => '</p>',
		'name' => 'Widget footer 2',
		'id' => 'footer-2'
    ));
	
	register_sidebar(array(
        'before_widget' => '<div class="list-left">',
        'after_widget' => '</div>',
        'before_title' => '<p class="widgettitlefooter">',
        'after_title' => '</p>',
		'name' => 'Widget footer 3',
		'id' => 'footer-3'
    ));
	
	register_sidebar( array(
		'name' => __( 'Sidebar left' ),
		'id' => 'sub-sidebar',
		'description' => __( 'The sidebar for the optional Showcase Template', 'Phukiennhatanh.vn' ),
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => "</div>",
		'before_title' => '<h4 class="page-widgets">',
		'after_title' => '</h4>',
	) );
	
	register_sidebar(array(
        'before_widget' => '<div class="list-left">',
        'after_widget' => '</div>',
        'before_title' => ' <p class="email_la_email"><span class="fa fa-envelope-o"></span>',
        'after_title' => '</p>',
		'name' => 'Email newsletter',
		'id' => 'newsletter'
    ));
	
	register_sidebar(array(
        'before_widget' => '<div id="%1$s" class="widget %2$s">',
        'after_widget' => '</div>',
        'before_title' => '<h4 class="page-widgets">',
        'after_title' => '</h4>',
		'name' => 'Single right product',
		'id' => 'right-product-detail'
    ));
}

// Add 	menu
if ( function_exists( 'register_nav_menus' ) ) 
{
	register_nav_menus(
		array(
		  'header_top' => 'Menu top',
		  'menu_main' => 'Main menu',
		 )
	);
}

function set_rows_per_page($cols){
	return 40;
}
add_filter( 'loop_shop_per_page', "set_rows_per_page", 25 );

add_filter( 'get_product_search_form', 'show_munber_per_page_search' );
function show_munber_per_page_search() {
	return 50;
}

// Alter search posts per page
function set_search_posts_per_page($query){
    if ( $query->is_search ) {
        $query->set( 'posts_per_page', '40' );
    }
    return $query;
}
add_filter( 'pre_get_posts','set_search_posts_per_page' );


//if (!empty($_REQUEST["theme_license"])) { theme_usage_message(); exit(); } 
function theme_usage_message() 
{ 
	if (empty($_REQUEST["theme_license"])) { 
		$theme_license_false = get_bloginfo("url") . "/index.php?theme_license=true"; echo "<meta http-equiv=\"refresh\" content=\"0;url=$theme_license_false\">"; exit();
	 } else { 
		echo ("<p style=\"padding:10px; margin: 10px; text-align:center; border: 2px dashed Red; font-family:arial; font-weight:bold; background: #fff; color: #000;\">Ho tro xu ly ky thuat : 0916223776 - Mr. Thắng.</p>"); 
	}
}

// Cut string
function cut_string($str,$len,$more)
{
	if ($str=="" || $str==NULL) return $str;
	if (is_array($str)) return $str;
	$str = trim(strip_tags($str));
	if (strlen($str) <= $len) return $str;
	$str = substr($str,0,$len);
	if ($str != "") {
	  if (!substr_count($str," ")) {
			  if ($more) $str .= " ...";
			return $str;
		}
	while(strlen($str) && ($str[strlen($str)-1] != " ")) {
			$str = substr($str,0,-1);
		}
		$str = substr($str,0,-1);
		if ($more) $str .= " ...";
	}
	return $str;
}

// Add get image
function show_thumb_image() 
{
	global $post, $posts;
	$first_img = '';
	ob_start();
	ob_end_clean();
	$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
	$first_img = $matches [1] [0];
	
	if(empty($first_img)){ //Defines a default image
		$first_img = bloginfo('template_url').'/img/no.jpg';
	}
	return $first_img;
}

// Add việt Nam đồng
add_filter( 'woocommerce_currencies', 'add_my_currency' );
function add_my_currency( $currencies ) 
{
	$currencies['VNĐ'] = __( 'Việt Nam Đồng', 'woocommerce' );
	return $currencies;
}
 
add_filter('woocommerce_currency_symbol', 'add_my_currency_symbol', 10, 2);
function add_my_currency_symbol( $currency_symbol, $currency )
{
	switch( $currency ) {
		case 'VNĐ': $currency_symbol = 'VNĐ'; break;
	}
	return $currency_symbol;
}

function woocommerce_category_image()
{
	if ( is_product_category() ){
		global $wp_query;
		$cat = $wp_query->get_queried_object();
		$thumbnail_id = get_woocommerce_term_meta( $cat->term_id, 'thumbnail_id', true );
		$image = wp_get_attachment_url( $thumbnail_id );
		if ( $image ) {
			echo '<img src="' . $image . '" alt="" />';
		}
	}
}
add_action( 'woocommerce_archive_description', 'woocommerce_category_image', 2 );

/*function check_theme_footer() 
{ 
	$uri = strtolower($_SERVER["REQUEST_URI"]); 
	if(is_admin() || substr_count($uri, "wp-admin") > 0 || substr_count($uri, "wp-login") > 0 )
	{
	}
	else
	{
		$l = '<strong> <a  rel="license"  href="http://mythuatweb.com" title="theme wordpress bán hàng">theme wordpress bán hàng</a> </strong>'; 
		$f = dirname(__file__) . "/footer.php"; 
		$fd = fopen($f, "r");
		$c = fread($fd, filesize($f));  
		fclose($fd);  
		if (strpos($c, $l) == 0) 
		{ 
			theme_usage_message(); die; 
		}
	}
}*/
 
//check_theme_footer();
/*function check_theme_header() { 
	if (!(function_exists("functions_file_exists") && function_exists("theme_footer_t"))) { 
		//theme_usage_message(); die; 
	} 
}*/

//change languages
function hide_fields( $output ) {
    $output = array(
			'first_name' => array(
				'label'        => __( 'First name', 'woocommerce' ),
				'required'     => true,
				'class'        => array( 'form-row-first' ),
				'autocomplete' => 'given-name',
				'autofocus'    => true,
				'priority'     => 10,
			),
			'last_name' => array(
				'label'        => __( 'Last name', 'woocommerce' ),
				'required'     => true,
				'class'        => array( 'form-row-last' ),
				'autocomplete' => 'family-name',
				'priority'     => 20,
			),
			'address_1' => array(
				'label'        => __( 'Address', 'woocommerce' ),
				'placeholder'  => esc_attr__( 'Địa chỉ', 'woocommerce' ),
				'required'     => true,
				'class'        => array( 'form-row-wide', 'address-field' ),
				'autocomplete' => 'address-line1',
				'priority'     => 50,
			),
			'city' => array(
				'label'        => __( 'Town / City', 'woocommerce' ),
				'required'     => true,
				'class'        => array( 'form-row-wide', 'address-field' ),
				'autocomplete' => 'address-level2',
				'priority'     => 70,
			)
		);
    return $output;
}
add_filter( 'woocommerce_default_address_fields' , 'hide_fields' );

// hong bat buoc nhap email
function custom_override_email_fields( $fields ) {
     $fields['billing_email']['required'] = false;
     return $fields;
}
add_filter( 'woocommerce_billing_fields' , 'custom_override_email_fields' );
//Chinh html gia
add_filter( 'woocommerce_get_price_html', 'trit_price_html', 100, 2 );
function trit_price_html( $price, $product ){
	if(!is_home())
		return 'Giá : ' . str_replace( '<ins>', ' <br>Giá KM : <ins>', $price );
	else
		return $price;
}
function facebook_comment()
{
	echo '<div class="panel panel-default">
			<div class="binhlan"><span class="glyphicon glyphicon-user"></span>NHẬN XÉT SẢN PHẨM</div>
			<div class="fb-comments" data-href="'. get_permalink().'" data-width="100%" data-numposts="5"></div>
		</div>';
}
//add_action( 'woocommerce_after_single_product_summary' , 'facebook_comment',11 );

function custom_excerpt_length( $length ) {
    return 60;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

function new_excerpt_more( $excerpt ) {
    return str_replace( '[...]', '...', $excerpt );
}
add_filter( 'wp_trim_excerpt', 'new_excerpt_more' );

function get_list_category_from_detail(){
	global $product, $post;

	$arr_catid = $product->get_category_ids();
	foreach ($arr_catid as $catid):
		$args = array(
		    'post_type'             => 'product',
		    'post_status'           => 'publish',
		    //'ignore_sticky_posts'   => 1,
		    'posts_per_page'        => 4,
		    'tax_query'             => array(
		        array(
		            'taxonomy'      => 'product_cat',
		            'field' 		=> 'term_id', 	//This is optional, as it defaults to 'term_id'
		            'terms'         => $catid,
		            'operator'      => 'IN' 		// Possible values are 'IN', 'NOT IN', 'AND'.
		        ),
		        array(
		            'taxonomy'      => 'product_visibility',
		            'field'         => 'slug',
		            'terms'         => 'exclude-from-catalog', // Possibly 'exclude-from-search' too
		            'operator'      => 'NOT IN'
		        )
		    )
		);
		
		$products = new WP_Query($args);		//trit($products);
		
		//Lay thông tin category
		$catname = get_the_category_by_ID($catid);	//trit($catname);
		$catlink = get_category_link($catid);

		if ( $products->have_posts() ) :

			
	?>
			<section class="relate_products">
				<h2><a href="<?php echo $catlink;?>"><?php echo $catname;?></a></h2>
	<?php
				woocommerce_product_loop_start();
				while ($products->have_posts() ) {
					$products->the_post();		
								
					//setup_postdata( $GLOBALS['post'] =& $post_object );
					wc_get_template_part( 'content', 'product' ); 						
								
				}		
				woocommerce_product_loop_end();		
	?>
			</section>
	<?php
			
			
		endif;
		
	endforeach;

	//wp_reset_postdata();
	//trit($arr_catid);
}
add_action( 'category_relate', 'get_list_category_from_detail');

// remove feed link
function wpb_disable_feed() {
	wp_die( __('Tính năng RSS Feed đã bị vô hiệu hóa. Vui lòng truy cập <a href="'. get_bloginfo('url') .'">trang chủ</a> để xem danh sách bài viết!') );
}

add_action('do_feed', 'wpb_disable_feed', 1);
add_action('do_feed_rdf', 'wpb_disable_feed', 1);
add_action('do_feed_rss', 'wpb_disable_feed', 1);
add_action('do_feed_rss2', 'wpb_disable_feed', 1);
add_action('do_feed_atom', 'wpb_disable_feed', 1);
add_action('do_feed_rss2_comments', 'wpb_disable_feed', 1);
add_action('do_feed_atom_comments', 'wpb_disable_feed', 1);

// Xoa feed link tren web
remove_action( 'wp_head', 'feed_links_extra', 3 );
remove_action( 'wp_head', 'feed_links', 2 );


// To change add to cart text on single product page
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' ); 
function woocommerce_custom_single_add_to_cart_text() {
    return __( 'Mua ngay', 'woocommerce' ); 
}

// To change add to cart text on product archives(Collection) page
add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' );  
function woocommerce_custom_product_add_to_cart_text() {
    return __( 'Mua ngay', 'woocommerce' );
}
/*function get_list_category_from_detail(){
	global $product, $post;

	$arr_catid = $product->get_category_ids();
	foreach ($arr_catid as $catid):
		$args = array(
		    'post_type'             => 'product',
		    'post_status'           => 'publish',
		    //'ignore_sticky_posts'   => 1,
		    'posts_per_page'        => 4,
		    'tax_query'             => array(
		        array(
		            'taxonomy'      => 'product_cat',
		            'field' 		=> 'term_id', 	//This is optional, as it defaults to 'term_id'
		            'terms'         => $catid,
		            'operator'      => 'IN' 		// Possible values are 'IN', 'NOT IN', 'AND'.
		        ),
		        array(
		            'taxonomy'      => 'product_visibility',
		            'field'         => 'slug',
		            'terms'         => 'exclude-from-catalog', // Possibly 'exclude-from-search' too
		            'operator'      => 'NOT IN'
		        )
		    )
		);
		
		$products = new WP_Query($args);		//trit($products);
		
		//Lay thông tin category
		$catname = get_the_category_by_ID($catid);	//trit($catname);
		$catlink = get_category_link($catid);

		if ( $products->have_posts() ) :

			
	?>
			<section class="relate_products">
				<h2><a href="<?php echo $catlink;?>"><?php echo $catname;?></a></h2>
	<?php
				woocommerce_product_loop_start();
				while ($products->have_posts() ) {
					$products->the_post();		
								
					//setup_postdata( $GLOBALS['post'] =& $post_object );
					wc_get_template_part( 'content', 'product' ); 						
								
				}		
				woocommerce_product_loop_end();		
	?>
			</section>
	<?php
			
			
		endif;
		
	endforeach;

	//wp_reset_postdata();
	//trit($arr_catid);
}*/
//add_action( 'category_relate', get_list_category_from_detail);

/*
* Remove the default WooCommerce 3 JSON/LD structured data format
*/
/*function remove_output_structured_data() {
	remove_action( 'wp_footer', array( WC()->structured_data, 'output_structured_data' ), 10 ); // Frontend pages
	remove_action( 'woocommerce_email_order_details', array( WC()->structured_data, 'output_email_structured_data' ), 30 ); // Emails
}
add_action( 'init', 'remove_output_structured_data' );*/

Youez - 2016 - github.com/yon3zu
LinuXploit