<?php
 global $smof_data;

add_filter( 'woocommerce_get_catalog_ordering_args', 'mihanwp_sort_by_stock', 9999 );
 
function mihanwp_sort_by_stock( $args ) {
   $args['orderby'] = 'meta_value';
   $args['order'] = 'ASC';
   $args['meta_key'] = '_stock_status';
   return $args;
}

 $minify_create='';
 $minify='1';
 
 
if( !defined('REZA_PATH') ){
	define( 'REZA_PATH', get_template_directory() );
}
if( !defined('REZA_DIR') ){
	define( 'REZA_DIR', get_template_directory_uri() );
}

if( !defined('REZA_FILE') ){
	define( 'REZA_FILE', dirname( __FILE__ ) );
}	
 
/*****************************************************************************************************************************************************
******************************************************************************************************************************************************
 
																	Include Inc
 
*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
include_once REZA_PATH . '/inc/option.php';
include_once REZA_PATH . '/inc/default.php';
include_once REZA_PATH . '/inc/translation.php';
 include_once REZA_PATH . '/header/header-functions.php';
include_once REZA_PATH . '/inc/menu/walker_menu.php';   
include_once REZA_PATH . '/inc/menu/walker_menu_mobile.php'; 
include_once REZA_PATH . '/inc/wp_list_comments.php';
 include_once REZA_PATH . '/inc/post-functions.php';   
include_once REZA_PATH . '/inc/blog/blog-functions.php'; 
include_once REZA_PATH . '/inc/column-sidebar.php';
include_once REZA_PATH . '/inc/breadcrumbs.php';
include_once REZA_PATH . '/inc/footer-functions.php'; 
include_once REZA_PATH . '/inc/color.php';
include_once REZA_PATH . '/inc/ads-functions.php';
include_once REZA_PATH . '/inc/pagenavi.php'; 
 
 if(function_exists ( "sao_slide_post_type" ) ){  
include_once REZA_PATH . '/inc/slider/slider-functions.php';
 }
 
if ( function_exists ( "is_woocommerce" )){
	include_once REZA_PATH . '/inc/product/product-functions.php';
} 
if(is_admin()){
include_once REZA_PATH . '/admin/tgm-plugin-activation/tgm-plugin.php';
}
include_once REZA_PATH . '/custom-css/custom-css.php';
include_once REZA_PATH . '/custom-css/enqueue.php';
if(!empty($minify_create)){
include_once REZA_PATH . '/custom-css/minify.php';
}
include_once REZA_PATH . '/config-builder/config.php'; 
include_once REZA_PATH . '/elementor/elementor.php'; 
include_once REZA_PATH . '/widgets/widget.php';
      
include_once REZA_PATH . '/admin/admin.php';
 
  
/*****************************************************************************************************************************************************
******************************************************************************************************************************************************

																		Output Buffer Start
																		
*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
add_action('wp_loaded', 'reza_output_buffer_start');
function reza_output_buffer_start() { 
    ob_start("reza_output_callback"); 
}
 
/*****************************************************************************************************************************************************
******************************************************************************************************************************************************

																		Output Callback
																		
*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function reza_output_callback($buffer) {
    return preg_replace( "%[ ]type=[\'\"]text\/(javascript|css)[\'\"]%", '', $buffer );
}
 function reza_admin_login_header() {
    remove_action('wp_head', '_admin_bar_bump_cb');
}
add_action('get_header', 'reza_admin_login_header');

/*****************************************************************************************************************************************************
******************************************************************************************************************************************************

																Site Icon

*/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
function reza_site_icon($tags) {
    $tags[] = sprintf('', esc_url(get_site_icon_url(null, 64)));

    return $tags;
}
add_filter('site_icon_meta_tags', 'reza_site_icon');

/*****************************************************************************************************************************************************
******************************************************************************************************************************************************

																		Setup
																		
*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
add_action( 'after_setup_theme', 'reza_setup' );
function reza_setup() {
 
 	add_theme_support( 'automatic-feed-links' );
	add_theme_support( 'woocommerce' );  
	   add_theme_support( 'post-thumbnails' ); 
 	add_filter( 'enable_post_format_ui', '_ereturn_false' );

	load_theme_textdomain( 'reza', REZA_PATH . '/languages' );

 
add_image_size( 'reza_thumbnail', 160  ); // 300 pixels wide (and unlimited height)
	add_image_size( 'reza_medium', 210  ); // 300 pixels wide (and unlimited height)
	add_image_size( 'reza_large', 280 ); // 300 pixels wide (and unlimited height)
	add_image_size( 'reza_big', 375  ); // 300 pixels wide (and unlimited height)
	 
 
 
} 
/*****************************************************************************************************************************************************
******************************************************************************************************************************************************

																		Language Selector Flags
																		
*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function reza_language_selector_flags(){
	if( function_exists( 'icl_get_languages' )){
		$languages = icl_get_languages('skip_missing=0&orderby=code');
		if(!empty($languages)){
			echo '<div id="reza_lang_switcher">';
			foreach($languages as $l){
				if(!$l['active']) echo '<a href="'.esc_attr($l['url']).'">';
					echo '<img src="'.esc_attr($l['country_flag_url']).'" height="12" alt="'.esc_attr($l['language_code']).'" width="18" />';
				if(!$l['active']) echo '</a>';
			}
			echo '</div>';
		}
	}
}  
 /*****************************************************************************************************************************************************
******************************************************************************************************************************************************

																Number Replace
																		
*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function reza_number_replace($English_Number){
	$WPLANG = get_option('WPLANG');
	$con = 'fa';
	$number1 = 'I';
	$number2 = 'R';
	if(is_rtl()){
 	$number = str_replace(
		array('&#۳۶;','0','1','2','3','4','5','6','7','8','9'),
		array('$','۰','۱','۲','۳','۴','۵','۶','۷','۸','۹'),
	isset($English_Number)?$English_Number:''
	);
	}else{
		$number = $English_Number;
	}

		return $number;
	 
	 
 }
function reza_number_replace_page_number($English_Number){
	$WPLANG = get_option('WPLANG');
	$con = 'fa';
	$number1 = 'I';
	$number2 = 'R';
 	$number = str_replace(
		array('0','1','2','3','4','5','6','7','8','9'),
		array('۰','۱','۲','۳','۴','۵','۶','۷','۸','۹'),
	isset($English_Number)?$English_Number:''
	);

		return $number;
	 
 }
/*****************************************************************************************************************************************************
******************************************************************************************************************************************************

																	Mobile
																		
*//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function reza_ismobile() {
return  wp_is_mobile();

} 
    
function reza_image_insert_override($sizes){
     unset( $sizes['medium']);
    unset( $sizes['medium_large']);
    unset( $sizes['large']);
    unset( $sizes['1536x1536']);
    unset( $sizes['2048x2048']);
    unset( $sizes['yith-woocompare-image']);
    unset( $sizes['reza_thumbnail']);
    unset( $sizes['reza_medium']);
    unset( $sizes['reza_large']);
    unset( $sizes['reza_big']);
    unset( $sizes['woocommerce_thumbnail']);
    unset( $sizes['woocommerce_single']);
    unset( $sizes['woocommerce_gallery_thumbnail']);
 
	 
	
    return $sizes;
}



//add_filter('intermediate_image_sizes_advanced', 'reza_image_insert_override' );