<?php 

add_filter('woocommerce_register_post_type_product', 'remove_shop_default_description');
function remove_shop_default_description($args){
$args['description'] = '';
 	return $args;
}
 // new style for farnam //
 function mt_new_css() {
      $base = get_stylesheet_directory_uri();
	  	        wp_enqueue_style( 'mt_new_css', $base.'/mt.css' );
 }
 add_action('wp_enqueue_scripts', 'mt_new_css', 2 );
 
 
  function flat_new_css() {
      $base = get_stylesheet_directory_uri();
	  	        wp_enqueue_style( 'flat_new_css', $base.'/uicons-regular-rounded.css' );
 }
 add_action('wp_enqueue_scripts', 'flat_new_css', 4 );
 
 function owl_new_css() {
      $base = get_stylesheet_directory_uri();
	  	        wp_enqueue_style( 'owl_new_css', $base.'/owl/owl.carousel.min.css' );
 }
 add_action('wp_enqueue_scripts', 'owl_new_css', 98 );
 
 function style_new_css() {
      $base = get_stylesheet_directory_uri();
	  	        wp_enqueue_style( 'style_new_css', $base.'/style.css' );
 }
 add_action('wp_enqueue_scripts', 'style_new_css', 98 );
   function two_new_css() {
      $base = get_stylesheet_directory_uri();
	  	        wp_enqueue_style( 'two_new_css', $base.'/style-two.css' );
 }
 add_action('wp_enqueue_scripts', 'two_new_css', 99 );
 
 // new js for vendad //

			function add_theme_scripts2() {  
  wp_enqueue_script( 'script1', get_template_directory_uri() . '/owl/jquery.min.js', array ( 'jquery' ), true);
 
  
}
add_action( 'wp_enqueue_scripts', 'add_theme_scripts2' , 2 );


			function add_theme_owl() {  
  wp_enqueue_script( 'owl', get_template_directory_uri() . '/owl/owl.carousel.min.js', array ( 'jquery' ), true);
 
  
}
add_action( 'wp_enqueue_scripts', 'add_theme_owl' , 2 );



			function add_theme_owl9() {  
  wp_enqueue_script( 'owl9', get_template_directory_uri() . '/owl/jquery.countdown.js', array ( 'jquery' ), true);
 
  
}
add_action( 'wp_enqueue_scripts', 'add_theme_owl9' , 3 );



			function add_theme_owl99() {  
  wp_enqueue_script( 'owl99', get_template_directory_uri() . '/owl/jquery.countdown.min.js', array ( 'jquery' ), true);
 
  
}
add_action( 'wp_enqueue_scripts', 'add_theme_owl99' , 4 );




			function add_theme_owl999() {  
  wp_enqueue_script( 'owl999', get_template_directory_uri() . '/owl/jstheme.js', array ( 'jquery' ), true);
 
  
}
add_action( 'wp_footer', 'add_theme_owl999' , 18 );
			function add_theme_owl999999() {  
  wp_enqueue_script( 'owl999999', get_template_directory_uri() . '/owl/main.js', array ( 'jquery' ), true);
 
  
}
add_action( 'wp_footer', 'add_theme_owl999999' , 19 );


			function add_theme_globaljs() {  
  wp_enqueue_script( 'globaljs', get_template_directory_uri() . '/owl/global.js', array ( 'jquery' ), true);
 
  
}
add_action( 'wp_enqueue_scripts', 'add_theme_globaljs' , 4 );
  

			function add_theme_globaljsrange() {  
  wp_enqueue_script( 'globaljsrange', get_template_directory_uri() . '/owl/jquery-ui.js', array ( 'jquery' ), true);
 
  
}
add_action( 'wp_enqueue_scripts', 'add_theme_globaljsrange' , 5 );

function enqueue_slider_scripts() {

    wp_enqueue_script('jquery');
    wp_enqueue_script('jquery-ui-slider');

    // کتابخانه Touch Punch
    wp_enqueue_script(
        'jquery-ui-touch-punch',
        get_template_directory_uri() . '/owl/jquery.ui.touch-punch.min.js',
        array('jquery', 'jquery-ui-slider'),
        '0.2.3',
        true
    );
}
add_action('wp_enqueue_scripts', 'enqueue_slider_scripts');



function myscript() {
?>
<script>
var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
  acc[i].addEventListener("click", function() {
    /* Toggle between adding and removing the "active" class,
    to highlight the button that controls the panel */
    this.classList.toggle("active");

    /* Toggle between hiding and showing the active panel */
    var panel = this.nextElementSibling;
    if (panel.style.display === "block") {
      panel.style.display = "none";
    } else {
      panel.style.display = "block";
    }
  });
} 

// Get the modal
var modal = document.getElementById("myModal");

// Get the button that opens the modal
var btn = document.getElementById("myBtn");

// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks on the button, open the modal
btn.onclick = function() {
  modal.style.display = "block";
}

// When the user clicks on <span> (x), close the modal
span.onclick = function() {
  modal.style.display = "none";
}

// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
  if (event.target == modal) {
    modal.style.display = "none";
  }
} 

<?php echo get_option('jscode'); ?>

</script>

<style>

<?php echo get_option('csscode'); ?>


</style>
<?php
}
add_action( 'wp_footer', 'myscript' );

    function body_id() {
    if( is_page_template('') ) {
        $id = 'id="service-page"';
    }

    echo $id;
}
////// ADD FAVICON //////
function my_favicon() { ?>
<link href="<?php echo get_option('logolinkfa'); ?>" rel="shortcut icon">

<style>

.pageone1 .woocommerce-Address h2::before , #filterasli .close-btn-mehr-filter , .factor-page-iran-order , .mehrnoosh-h3-order-view i::after , .ui-slider .ui-slider-range , .mehrnoosh-price-filter-bottom , .product-list-order-view-count , .etel-title-order::before , .closebtnw , .fieldbox-top-456456666666666v .woocommerce-customer-details h2::before , .fieldbox-top-456456666666666v .woocommerce-order-details h2::before , .postnumber-no-farnam .copy-button , .order-single-farnam0-21 .woocommerce-column__title::before , .order-single-farnam0-21 .woocommerce-order-details__title::before , .header-one-tab-order .orderactive-header-farnam.order-header-farnam , .lidemt , .mike-single-box-imgee .mdi.mdi-comment-question-outline , .mik-woo-delhah-title::before , .owl-pone-delkhah.owl-carousel.owl-rtl.owl-loaded.owl-drag .owl-dots button.owl-dot.active , #single-product-tab-402-1 ul li.active a , #related-single-product-6542s h4::before , #single-product-tab-402-1 .woocommerce-Tabs-panel h2:first-child::after , #tab-seller_enquiry_form h3::after , .Property-sepid.single-product-402-1-sepid h4::before , .dokanvendore .percentage , .woocommerce-product-gallerynewimagebox12 .mizan-flash5555 , .zemanat-single-product55ffff , .woof_price_search_container.woof_container.woof_price_filter form::after , .min-icon-footer:hover .fi.fi-rr-home , .min-icon-footer .sabadnumbercolor , .modal-etel111 .khorooj-sistem , .modal-etel111 .elktwo::before  , .modaldakhel  , .closeiran-s , #videom .close , .share-video-moarefi:hover , .chap-12221 , .sgare-sepid-box span::before , #sharem .close1 , .chap-12221 , .woocommerce-MyAccount-navigation-link.is-active a::after , .user-bar-401-link:hover , .khotooj-az-site , .title-2.sef754343 a , .noosh-21::after , .div-bars-checkout-1400.ggtt-1400::after , .barsf , .mik-999-1400 .page-numbers.current , .noosh-19::before , .noosh-19::after , .div-bars-checkout-1400::before , .noosh-201::before , .noosh-201::after , .progress-bar-bamdad , .menu-header .dmega .sub-menu .sub-menu li a::before , .gffhrttrh-5445tgg h3::after , .mizany  , .mehr-65-tedad  , .loader-bar , .iran-farnam-9-box-iner , .iran-farnam-9-box-iner::before , .iran-farnam-9-box-iner::after , .sssbox.newsearch.yad-2020-1 .submit.icon-search , .tedad-1-cat-ravesh-1 , .risk-meta.hoversho-www1.ffgt544.koodak-34 , .owl-koffer .owl-dots button.active , .outofstock-new-2 , .elementor-485 .elementor-element.elementor-element-2036866 a.elementor-button, .elementor-485 .elementor-element.elementor-element-2036866 .elementor-button , .darsad-new-mank , .footerh3 h3::before , .checkoutnew-1 #order_review_heading::before , .checkoutnew-1 .woocommerce-billing-fields h3::before , .side-meta-1-box:hover  ,.darsad , #demo-two .left-rr-user , .commentlist::after  , .left-sabad span , .woocommerce nav.woocommerce-pagination ul li a:focus, .woocommerce nav.woocommerce-pagination ul li a:hover, .woocommerce nav.woocommerce-pagination ul li span.current
, .mizan , .mizan-6 , .price-kharid .single_add_to_cart_button.button.alt , .vijegi h4::before , .woocommerce div.product .woocommerce-tabs ul.tabs li.active , .woocommerce-Tabs-panel h2::before
, .risk-meta span:hover , .woocommerce #review_form #respond .form-submit input , .mob-1 .submit.icon-search , .woocommerce #respond input#submit, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button
, .woocommerce #reviews #comments ol.commentlist li img.avatar  , .head-page , .woocommerce .cart .button, .woocommerce .cart input.button , .footer-menu-box h3::before , .woocommerce-MyAccount-navigation-link.is-active a
, .in1 img , .mini-1-time , .elkone h3::before , .onvanij::before , .menu-header ul .mega .sub-menu li a::before , .matn-didgah h3::before , .category-111 , .styleslider .swiper-pagination-bullet-active 
, .post-n-meta.meta-tag-1 a , .main-blog-1345435 #submit , .main-blog-1345435 .comment-reply-link , .product-list234234 h3::after , .blog-widget h4::after , .main-blog-1 .page-numbers.current , .box-etel h3::before
, .side-meta-1-box.ghgfhtr .woosc-btn-added , .cpmare-wefew .woosc-btn-added , .pf-help-title h4::before , .risk-meta.hoversho-www1 .cpmare-wefew .woosc-btn-added , #thumbs .current .item-thumbin img 
, .wpcf7-form-control.wpcf7-submit , .dokan-account-migration-lists .dokan-w4.right-content a , .cart_totals h2::before ,.mini-cart-3 .remove.remove_from_cart_button , .irs-from, .irs-to, .irs-single , .woof_container h4::before , .wpfFilterTitle::before , .wpfFilterButton.wpfButton , .ui-slider.ui-widget-content .ui-slider-handle 
, .swiper-pagination-bullet.swiper-pagination-bullet-active , .daste-1:hover .box-number-cat , .daste-1:hover .box-number-cat::before , .new-title-2020 span , .jodasho::before , .product-demo-2-listing1::before 
 , .mini-price-demo-1 ins , .social-1 , .modal-content .close {
background: <?php echo get_option('color1'); ?>;	
}
.form-row.form-row-firstertertert .button:hover , .postlinkdddd , .userj88u #reg-btn , .orderactive-header-farnam.order-header-farnam .dayere-header-order-farnam , .woocommerce-orders-table.woocommerce-MyAccount-orders.shop_table.shop_table_responsive.my_account_orders.account-orders-table .woocommerce-button.button , .meta-v-sopid-box .woosc-btn:hover , .meta-v-sopid-box #tazminesalaat-sin:hover i , .tedad-sepid-single , .meta-v-sopid-boxre5ty45y45 #shareb:hover i , .mizan-flash5555eee , .Property-sepid.single-product-402-1-sepid ul li strong , .nimche-21 .woosc-btn-added.woosc-added , .risk-meta.hoversho-www1.ffgt544 .woosc-btn-added.woosc-added , .min-icon-footer:hover  , .bamdad-darsad , .dmega .sub-menu li:hover a ,  .farnam-offer-slider-1 .pricr-offer ins , .darsad-7  , .lahze-offer .product-list-1.ps3.jjj-112 .darsad , .chakame-123-d , #demo-two .ps3 ins , .side-1-product-box i  , .user-meta a:hover , .header-one-1 span i , .menu-header .current-menu-item a , .mega .sub-menu li .sub-menu li:hover a 
, .price-kharid .price ins , .vijegi strong , #reg-btn , .pricr-offer ,.pricr-offer ins , .share-2 a:hover , .left-timer-123123 h3 , .share-iran-32 a:hover , .price-kharid4543543 ins
, .price-kharid4543543 , .risk-meta.hoversho-www1 .cpmare-wefew-1 .woosq-btn:hover , .risk-meta.hoversho-www1 .cpmare-wefew .woosc-btn:hover , .dokan-single-store .dokan-store-tabs ul li a:hover ,
.woocommerce div.product .woocommerce-tabs ul.tabs li.active a , .tedadforoosh , .price-kharid-new ins , .woocommerce .star-rating span::before , .footer-menu-box ul li:hover a {
color: <?php echo get_option('color1'); ?>;	
}
.show-ticket-mbn , .axtion-farnam-list .woocommerce-button , .dmega .sub-menu .sub-menu li .sub-menu li:hover a , .woocommerce div.product .woocommerce-tabs ul.tabs li.active  , .product-style.htpp.ir-owl.offer-00-1.slide-new-4-slide .time1.mini-1-time {
	color: <?php echo get_option('color1'); ?> !important;	
}
.woocommerce-variation-radio input[type="radio"]:checked + label , .product-categories-filter.mehrnoosh-category-list-in-shop .current-category::before , .ui-slider span , .menu-item-has-children:hover ,  .product-style.htpp.ir-owl.offer-00-1 , #thumbs .current .item-thumbin , .menu-item-has-children:hover {
	border-color: <?php echo get_option('color1'); ?>;	
}
.woocommerce-variation-radio input[type="radio"]:checked + label , .show-ticket-mbn , .axtion-farnam-list .woocommerce-button , .woocommerce-orders-table.woocommerce-MyAccount-orders.shop_table.shop_table_responsive.my_account_orders.account-orders-table .woocommerce-button.button , .woocommerce div.product .woocommerce-tabs ul.tabs li.active , .product-style.htpp.ir-owl.offer-00-1.slide-new-4-slide .time1.mini-1-time , .owl-slide-new-5 .current .item-thumbin {
	border-color: <?php echo get_option('color1'); ?> !important;	
}
.menu-item-has-children:hover a::after {
		border-bottom-color: <?php echo get_option('color1'); ?>;
}
	
.replay-bala-34534mbn strong::before , .irantest-ticket-form-mbn .wast-btn.wast-btn-success , .show-ticket-mbn:hover , .wast-wrapper .wast-filter.wast-clearfix.list-filter-dsfsfferer32243 .wast-custom-select-item.selected  , .ticket-tak-2:hover .ticket-title-mbn::before  , .wast-wrapper .wast-custom-select-item.wast-custom-select-item--selected , .number-ticket-23423 span , .farnam-offer-slider-1  .owl-dot.active , .farnam-offer-slider-1 .mini-1-time , .rangi-1 , .mini-cart-3 .woocommerce-mini-cart__buttons .button:nth-child(2) , .irs-from, .irs-to, .irs-single , #demo-two .left-rr-user:hover {
	background: <?php echo get_option('color1'); ?> !important;	
}
.ui-slider .ui-slider-range , .mehrnoosh-custom-checkbox input:checked ~ .checkmark , input:checked + .slider , .elementor-485 .elementor-element.elementor-element-2036866 a.elementor-button, .elementor-485 .elementor-element.elementor-element-2036866 .elementor-button
 , .woocommerce .widget_price_filter .ui-slider .ui-slider-range , .woocommerce #respond input#submit.alt.disabled, .woocommerce #respond input#submit.alt.disabled:hover, .woocommerce #respond input#submit.alt:disabled, .woocommerce #respond input#submit.alt:disabled:hover, .woocommerce #respond input#submit.alt:disabled[disabled], .woocommerce #respond input#submit.alt:disabled[disabled]:hover, .woocommerce a.button.alt.disabled, .woocommerce a.button.alt.disabled:hover, .woocommerce a.button.alt:disabled, .woocommerce a.button.alt:disabled:hover, .woocommerce a.button.alt:disabled[disabled], .woocommerce a.button.alt:disabled[disabled]:hover, .woocommerce button.button.alt.disabled, .woocommerce button.button.alt.disabled:hover, .woocommerce button.button.alt:disabled, .woocommerce button.button.alt:disabled:hover, .woocommerce button.button.alt:disabled[disabled], .woocommerce button.button.alt:disabled[disabled]:hover, .woocommerce input.button.alt.disabled, .woocommerce input.button.alt.disabled:hover, .woocommerce input.button.alt:disabled, .woocommerce input.button.alt:disabled:hover, .woocommerce input.button.alt:disabled[disabled], .woocommerce input.button.alt:disabled[disabled]:hover  , .woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt {
		background-color: <?php echo get_option('color1'); ?>;	

}
.spinner , .irs-from::after, .irs-to::after, .irs-single::after {
	border-top-color: <?php echo get_option('color1'); ?> !important;
}
.left-rr-user , .mizan , .price-kharid .single_add_to_cart_button.button.alt , .woocommerce div.product .woocommerce-tabs ul.tabs li.active , .ps1-1 .mizan , .woocommerce #respond input#submit, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button
, .woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt , .woocommerce-MyAccount-navigation-link.is-active a , .in1 img 
, .category-111 , .wpfFilterButton.wpfButton {
box-shadow: 0 5px 15px <?php echo get_option('color2'); ?>;
}
.dokan-dashboard .dokan-dash-sidebar ul.dokan-dashboard-menu li.active:hover , 


.dokan-dashboard .dokan-dash-sidebar ul.dokan-dashboard-menu li.active, .dokan-dashboard .dokan-dash-sidebar ul.dokan-dashboard-menu li.active, .dokan-dashboard .dokan-dash-sidebar ul.dokan-dashboard-menu li.dokan-common-links a:hover

	{
	background-color: <?php echo get_option('color1'); ?> !important;	
	}
	
	.irs-from::after, .irs-to::after, .irs-single::after {
	border-top-color: <?php echo get_option('color1'); ?> !important;
}
.owl-dot.active::before , .mizan-flash5555 {
	border-right-color: <?php echo get_option('color1'); ?>;
	
}

.farnam-offer-slider-1 .owl-dot.active::before 	{
	border-left-color: <?php echo get_option('color1'); ?>;
	
}
.menu-item-has-children:hover a::after , .farnam-offer-slider-1 .pricr-offer ins::before  {
		border-bottom-color: <?php echo get_option('color1'); ?>;
}
.show-ticket-mbn svg path, .show-ticket-mbn svg circle {
	stroke: <?php echo get_option('color1'); ?>;
}

</style>
<?php }
add_action('wp_head', 'my_favicon');

add_action('woocommerce_checkout_create_order_line_item', function ($item, $cart_item_key, $values, $order) {
    $product = $item->get_product();

    if ($product) {
        $regular_price = $product->get_regular_price();
        $sale_price = $item->get_subtotal() / $item->get_quantity();

        $item->update_meta_data('_regular_price_at_purchase', $regular_price);
        $item->update_meta_data('_sale_price_at_purchase', $sale_price);
    }
}, 10, 4);
add_action('template_redirect', 'redirect_dokan_edit_account_to_wc');

function redirect_dokan_edit_account_to_wc() {
    if (is_user_logged_in() && strpos($_SERVER['REQUEST_URI'], 'dashboard/edit-account') !== false) {
        wp_redirect(wc_get_account_endpoint_url('edit-account'));
        exit;
    }
}