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/thucphamxanh.orgs.vn/public_html/wp-content/themes/wp_shop/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/thucphamxanh.orgs.vn/public_html/wp-content/themes/wp_shop//functions.php
<?php
/* Add style theme */
require_once ('admin/index.php');

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_180', 180, 90, true );
	add_image_size( 'thumb-archive_311', 311, 200, 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/widget_woo.php");
// require("inc/functions/breadcrumb.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'  
    ));
	
	
	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'  
    ));
	
	register_sidebar(array(
       'name' => 'Home Product'  
    ));
		
	 register_sidebar(array(
        'before_widget' => '<div class="list-left">',
        'after_widget' => '</div>',
        'before_title' => '<p class="widgettitlefooter">',
        'after_title' => '</p>',
		'name' => 'Widget 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'  
    ));
	
	register_sidebar(array(
        'before_widget' => '<div class="list-left">',
        'after_widget' => '</div>',
        'before_title' => '<p class="widgettitlefooter">',
        'after_title' => '</p>',
		'name' => 'Widget 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'  
    ));
	
	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'  
    ));
}

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


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 : 094 5656 346 - Mr Linh.</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;
}


add_action( 'woocommerce_archive_description', 'woocommerce_category_image', 2 );

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="" />';
		}
	}
}

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_city']['required'] = false;
	$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="fb-comments" data-href="'. get_permalink().'" data-width="100%" data-numposts="5"></div>';
}
//add_action( 'woocommerce_after_single_product_summary' , 'facebook_comment',11 );

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;

}
add_action( 'category_relate', get_list_category_from_detail);

function get_list_news_relate_from_detail()
{
	global $product, $post;
	
	$catid = get_the_category();
	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;
}
add_action( 'news_relate', get_list_news_relate_from_detail);

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

Youez - 2016 - github.com/yon3zu
LinuXploit