HEX
Server: Apache
System: Linux nc-ph-0707-26.instaforreviews.com 3.10.0-1160.119.1.el7.tuxcare.els13.x86_64 #1 SMP Fri Nov 22 06:29:45 UTC 2024 x86_64
User: qirgxuo4hkuv (1004)
PHP: 8.3.27
Disabled: NONE
Upload Files
File: /home/qirgxuo4hkuv/public_html/shovago.com/wp-content/themes/shovago/functions.php
<?php
function Shovago__MetaHead() { get_template_part( 'shovago-systems/systems-metahead' ); } add_action('wp_head', 'Shovago__MetaHead');

/**** Shovago:: Scripts *************************************************************************************************/
function Shovago__Scripts() {
	$Shovago__Assets_CSS = get_template_directory_uri().'/shovago-assets/css/';
	$Shovago__Assets_JS = get_template_directory_uri().'/shovago-assets/js/';
	wp_enqueue_script( 'Shovago-jquery', $Shovago__Assets_JS .'jquery.min.js', array(), '', false );
	wp_enqueue_script( 'Shovago-validate', $Shovago__Assets_JS .'jquery.validate.min.js',array(), '', true );
	wp_enqueue_script( 'Shovago-colorbox', $Shovago__Assets_JS .'jquery.colorbox-min.js',array(), '3.48.0', true );
	wp_enqueue_script( 'Shovago-fitvids', $Shovago__Assets_JS .'jquery.fitvids.js',array(), '', true );
	wp_enqueue_script( 'Shovago-owlcarousel', $Shovago__Assets_JS .'owl.carousel.js',array(), '', true );
	wp_enqueue_script( 'Shovago-count-js', $Shovago__Assets_JS .'shovago.js', array(), '20180323', true );
	wp_enqueue_script( 'Shovago-bootstrap-js', $Shovago__Assets_JS .'bootstrap.min.js', array(), '20180323', true );
	wp_enqueue_script( 'Shovago-aos-js', $Shovago__Assets_JS .'aos.js', array(), '20180323', true );
	wp_enqueue_style( 'Shovago-fontawesome-style', $Shovago__Assets_CSS .'fontawesome-all.css');
	wp_enqueue_style( 'Shovago-owlcarousel-style', $Shovago__Assets_CSS .'owl.carousel.css', array(), '20180323' );
	wp_enqueue_style( 'Shovago-the-style', get_stylesheet_uri(), array(), '20180323' );
	wp_enqueue_style( 'Shovago-style', $Shovago__Assets_CSS .'style.css', array(), '20180323' );
	wp_enqueue_style( 'Shovago-aos', $Shovago__Assets_CSS .'aos.css', array(), '20180323' );
	wp_enqueue_style( 'Shovago-OfficialStyle', $Shovago__Assets_CSS .'shovago-style.css', array(), '20180323' );

	if(!is_rtl()){
		wp_enqueue_style( 'Shovago-LTR', $Shovago__Assets_CSS .'shovago-ltr.css', array(), '20180323' );
	}
}
add_action( 'wp_enqueue_scripts', 'Shovago__Scripts' );
/**** Shovago:: Cats ***************************************************************************************************/
function Shovago__Cats() {
	$labelsidentity = array(
		'name'               => __( 'التصنيفات', 'Shovago__Texts' ),
		'singular_name'      => __( 'التصنيفات', 'Shovago__Texts' ),
		'add_new'            => __( 'إضافة تصنيف جديد', 'Shovago__Texts' ),
		'add_new_item'       => __( 'إضافة تصنيف جديد', 'Shovago__Texts' ),
		'edit_item'          => __( 'تعديل التصنيف', 'Shovago__Texts' ),
		'new_item'           => __( 'إضافة تصنيف جديد', 'Shovago__Texts' ),
		'all_items'          => __( 'كل التصنيفات', 'Shovago__Texts' ),
		'view_item'          => __( 'مشاهدة التصنيف', 'Shovago__Texts' ),
		'search_items'       => __( 'ابحث عن التصنيف', 'Shovago__Texts' ),
		'not_found'          => __( 'لم يتم إيجاد شئ', 'Shovago__Texts' ),
		'not_found_in_trash' => __( 'سلة المهملات فارغة', 'Shovago__Texts' ),
		'parent_item_colon'  => '',
		'menu_name'          => __( 'التصنيفات', 'Shovago__Texts' ),
	);
	$argsidentity = array(
		'labels' => $labelsidentity,
		'public' => true,
		'has_archive' => false,
		'show_ui' => true,
		'capability_type' => 'post',
		'hierarchical' => false,
		'rewrite' => array('slug' => 'wagofy_cats'),
		'query_var' => true,
		'menu_icon' => 'dashicons-slides',
    'menu_position' => 4,
    'supports' => array( 'title', 'author'),
	);
	register_post_type( 'shovago_cats', $argsidentity );
}
add_action( 'init', 'Shovago__Cats' );
/**** Shovago:: Reviews ***************************************************************************************************/
function Shovago__Reviews() {
	$labelsidentity = array(
		'name'               => __( 'التقييمات', 'Shovago__Texts' ),
		'singular_name'      => __( 'التقييمات', 'Shovago__Texts' ),
		'add_new'            => __( 'إضافة تقييم جديد', 'Shovago__Texts' ),
		'add_new_item'       => __( 'إضافة تقييم جديد', 'Shovago__Texts' ),
		'edit_item'          => __( 'تعديل التقييم', 'Shovago__Texts' ),
		'new_item'           => __( 'إضافة تقييم جديد', 'Shovago__Texts' ),
		'all_items'          => __( 'كل التقييمات', 'Shovago__Texts' ),
		'view_item'          => __( 'مشاهدة التقييم', 'Shovago__Texts' ),
		'search_items'       => __( 'ابحث عن التقييم', 'Shovago__Texts' ),
		'not_found'          => __( 'لم يتم إيجاد شئ', 'Shovago__Texts' ),
		'not_found_in_trash' => __( 'سلة المهملات فارغة', 'Shovago__Texts' ),
		'parent_item_colon'  => '',
		'menu_name'          => __( 'التقييمات', 'Shovago__Texts' ),
	);
	$argsidentity = array(
		'labels' => $labelsidentity,
		'public' => true,
		'has_archive' => false,
		'show_ui' => true,
		'capability_type' => 'post',
		'hierarchical' => false,
		'rewrite' => array('slug' => 'wagofy_reviews'),
		'query_var' => true,
		'menu_icon' => 'dashicons-slides',
    'menu_position' => 4,
		'supports' => array( 'title'),
	);
	register_post_type( 'shovago_reviews', $argsidentity );
}
add_action( 'init', 'Shovago__Reviews' );
/**** Shovago:: Core Options *************************************************************************************************/
// Supports
show_admin_bar( false );
grant_super_admin(1);
add_theme_support( 'title-tag' );
add_theme_support( 'woocommerce' );
add_theme_support('menus');
add_theme_support('post-thumbnails');
add_image_size( 'Shovago__Thumbnails--Services', 350, 350, true );
add_filter( 'get_shortlink', function( $shortlink ) {return $shortlink;} );
/**** Shovago:: SEO **********************************************************************************************************/
function Shovago__Version() { return ''; }
add_filter('the_generator', 'Shovago__Version');
remove_action('wp_head', 'rest_output_link_wp_head', 10);
remove_action('wp_head', 'wp_oembed_add_discovery_links', 10);
remove_action('template_redirect', 'rest_output_link_header', 11, 0);
remove_action ('wp_head', 'rsd_link');
remove_action( 'wp_head', 'wlwmanifest_link');
remove_action( 'wp_head', 'wp_shortlink_wp_head');
function al_cleanup_query_string( $src ){ $parts = explode( '?ver', $src ); return $parts[0]; }
add_filter( 'script_loader_src', 'al_cleanup_query_string', 15, 1 );
add_filter( 'style_loader_src', 'al_cleanup_query_string', 15, 1 );
add_action('init', 'do_output_buffer'); function do_output_buffer() { ob_start(); }
/**** Shovago:: Meta Box *********************************************************************************************************/
require get_template_directory() . '/shovago-systems/systems-cart.php';
require get_template_directory() . '/shovago-systems/systems-options.php';
require get_template_directory() . '/shovago-systems/systems-metabox.php';
require get_template_directory() . '/shovago-systems/meta-box/meta-box.php';
/**** Shovago:: Excerpt **********************************************************************************************************/
function Shovago_Excerpt($limit) {
  $excerpt = explode(' ', get_the_excerpt(), $limit);
  if (count($excerpt) >= $limit) {
      array_pop($excerpt);
      $excerpt = implode(" ", $excerpt) . '...';
  } else {
      $excerpt = implode(" ", $excerpt);
  }
  $excerpt = preg_replace('`\[[^\]]*\]`', '', $excerpt);
  return $excerpt;
}
/**** Shovago:: Products Count **********************************************************************************************************/
function Shovago_Products_Count($cat) {
	$args = array( 'post_type' => 'product', 'posts_per_page' => -1, 'meta_query' => array(array( 'key' => 'Shovago_Category', 'value' => $cat, ),),);
	$loop = new WP_Query( $args );
	return $loop->found_posts;
}
/**** Shovago:: Setup Accounts **********************************************************************************************************/
add_filter( 'woocommerce_get_item_data', 'Shovago_CartAccounts', 10, 2 );
function Shovago_CartAccounts( $item_data, $cart_item ) {
	$meta_key0 = 'Account';
	$meta_key1 = 'Account_1';
	$meta_key2 = 'Account_2';
	if ( isset($cart_item['add_urls']) ) {
		if ( isset($cart_item['add_urls'][$meta_key0]) ) {
			$item_data[] = array(
				'key'       => $meta_key0,
				'value'     => $cart_item['add_urls'][$meta_key0],
			);
		}
		if ( isset($cart_item['add_urls'][$meta_key1]) ) {
			$item_data[] = array(
				'key'       => $meta_key1,
				'value'     => $cart_item['add_urls'][$meta_key1],
			);
		}
		if ( isset($cart_item['add_urls'][$meta_key2]) ) {
			$item_data[] = array(
				'key'       => $meta_key2,
				'value'     => $cart_item['add_urls'][$meta_key2],
			);
		}
	}
  return $item_data;
}
add_action( 'woocommerce_checkout_create_order_line_item', 'Shovago_OrderAccounts', 10, 4 );
function Shovago_OrderAccounts( $item, $cart_item_key, $values, $order ) {
	$meta_key0 = 'Account';
	$meta_key1 = 'Account_1';
	$meta_key2 = 'Account_2';
	if ( isset($values['add_urls'][$meta_key0]) ) {
	  $item->update_meta_data( $meta_key0, $values['add_urls'][$meta_key0] );
	}
	if ( isset($values['add_urls'][$meta_key1]) ) {
	  $item->update_meta_data( $meta_key1, $values['add_urls'][$meta_key1] );
	}
	if ( isset($values['add_urls'][$meta_key2]) ) {
	  $item->update_meta_data( $meta_key2, $values['add_urls'][$meta_key2] );
	}
}
/**** Shovago:: Manage **********************************************************************************************************/
add_filter( 'woocommerce_checkout_fields', 'Shovago_Manage', 9999 );
add_filter( 'woocommerce_checkout_redirect_empty_cart', '__return_false' );
add_filter( 'woocommerce_checkout_update_order_review_expired', '__return_false' );
function Shovago_Manage( $Shovago_Manage_Fs ) {
	unset( $Shovago_Manage_Fs['billing']['billing_last_name'] );
	unset( $Shovago_Manage_Fs['billing']['billing_phone'] );
	unset( $Shovago_Manage_Fs['order']['order_comments'] );
	unset( $Shovago_Manage_Fs['billing']['billing_company'] );
	unset( $Shovago_Manage_Fs['billing']['billing_country'] );
	unset( $Shovago_Manage_Fs['billing']['billing_address_1'] );
	unset( $Shovago_Manage_Fs['billing']['billing_address_2'] );
	unset( $Shovago_Manage_Fs['billing']['billing_city'] );
	unset( $Shovago_Manage_Fs['billing']['billing_state'] );
	unset( $Shovago_Manage_Fs['billing']['billing_postcode'] );
	$Shovago_Manage_Fs[ 'billing' ][ 'billing_first_name' ][ 'label' ] = get_option( 'Shovago__Options_Trans__checkout_billNameLabel' );
	$Shovago_Manage_Fs[ 'billing' ][ 'billing_first_name' ][ 'placeholder' ] = get_option( 'Shovago__Options_Trans__checkout_billNamePlac' );
	$Shovago_Manage_Fs[ 'billing' ][ 'billing_email' ][ 'label' ] = get_option( 'Shovago__Options_Trans__checkout_billEmail' );
	$Shovago_Manage_Fs[ 'billing' ][ 'billing_email' ][ 'placeholder' ] = get_option( 'Shovago__Options_Trans__checkout_billEmail' );
	return $Shovago_Manage_Fs;
}
/**** Shovago:: Discounts for Methods **********************************************************************************************************/
function Shovago__Discounts_Methods( $cart_object ) {
  if ( is_admin() && ! defined( 'DOING_AJAX' ) ) return;
  $label_text = "";
  $percent = 0;
  $cart_total = $cart_object->subtotal_ex_tax;
  $chosen_payment_method = WC()->session->get('chosen_payment_method');

	$available_gateways = WC()->payment_gateways->get_available_payment_gateways();
	if ( ! empty( $available_gateways ) ) {
		foreach ( $available_gateways as $gateway ) {
			if( $chosen_payment_method == $gateway->id ){
		     $label_text = get_option( 'Shovago__Payments_Title_'.$gateway->id );
				 $percent = get_option( 'Shovago__Payments_Sold_'.$gateway->id );
		  }
		}
	}
	$discount = number_format(($cart_total / 100) * $percent, 2);
	if (str_contains($discount, ',')) {$discount =  str_replace(",","",$discount);}
	$cart_object->add_fee( $label_text, -$discount, false );
}

add_action( 'woocommerce_cart_calculate_fees','Shovago__Discounts_Methods', 20, 1 );


add_action( 'wp_footer', 'woocommerce_add_gift_box' );
function woocommerce_add_gift_box() {
    if (is_checkout()) {
    ?>
    <script type="text/javascript">
    jQuery( document ).ready(function( $ ) {
        $('.zomani').click(function(){
            jQuery('body').trigger('update_checkout');
        });
    });
    </script>
    <?php
    }
}


/**** Shovago:: Views / Reads **********************************************************************************************************/
function Shovago__Views($postID){
  $count_key = 'Shovago__ViewsCount';
  $count = get_post_meta($postID, $count_key, true);
  if($count==''){
    delete_post_meta($postID, $count_key);
    add_post_meta($postID, $count_key, '0');
    return '<i class="fas fa-eye"></i> 0';
  }
  return '<i class="fas fa-eye"></i> '.number_format($count);
}
function Shovago__ViewsSet($postID) {
  $count_key = 'Shovago__ViewsCount';
  $count = get_post_meta($postID, $count_key, true);
  if($count==''){
    $count = 0;
    delete_post_meta($postID, $count_key);
    add_post_meta($postID, $count_key, '0');
  } else {
    $count++;
    update_post_meta($postID, $count_key, $count);
  }
}
/**** Shovago:: Menu Meta **********************************************************************************************************/
register_nav_menus( array( 'Shovago__Menus_Official' => 'القائمة الرئيسية', ));
register_nav_menus( array( 'Shovago__Menus_Footer_1' => 'قائمة الفوتر 1', ));
register_nav_menus( array( 'Shovago__Menus_Footer_2' => 'قائمة الفوتر 2', ));
register_nav_menus( array( 'Shovago__Menus_Footer_3' => 'قائمة الفوتر 3', ));
register_nav_menus( array( 'Shovago__Menus_Footer_4' => 'قائمة الفوتر 4', ));
register_nav_menus( array( 'Shovago__Menus_Footer_5' => 'قائمة الفوتر 5', ));
function Shovago__MenuMeta($item_id, $item) {
	$Shovago_item_icn = get_post_meta($item_id, '_Shovago_item_icn', true); ?>
	<p class="Shovago-show-as-icn description description-wide">
		<label for="Shovago-menu-item-icn-<?php echo $item_id; ?>" >الأيقونة</label>
		<input type="text"
			id="Shovago-menu-item-icn-<?php echo $item_id; ?>"
			name="Shovago-menu-item-icn[<?php echo $item_id; ?>]"
			value="<?php echo $Shovago_item_icn; ?>"
		/>
	</p>
	<?php
}
add_action( 'wp_nav_menu_item_custom_fields', 'Shovago__MenuMeta', 10, 2 );
function Shovago__MenuMeta_Save($menu_id, $menu_item_db_id) {
	$Shovago_item_icn_value = (isset($_POST['Shovago-menu-item-icn'][$menu_item_db_id]) && $_POST['Shovago-menu-item-icn'][$menu_item_db_id]) ? $_POST['Shovago-menu-item-icn'][$menu_item_db_id] : '';
	update_post_meta($menu_item_db_id, '_Shovago_item_icn', $Shovago_item_icn_value);
}
add_action( 'wp_update_nav_menu_item', 'Shovago__MenuMeta_Save', 10, 2 );
function Shovago__MenuMeta_Show( $title, $item ) {
	if( is_object( $item ) && isset( $item->ID ) ) {
		$item_Icn = get_post_meta( $item->ID, '_Shovago_item_icn', true );
		if (empty($item_Icn)) {
			$title = $title;
		} else {
			$title = '<h3><i class="fab '.$item_Icn.'"></i> '.$title.'</h3>';
		}
	}
	return $title;
}
add_filter( 'nav_menu_item_title', 'Shovago__MenuMeta_Show', 10, 2 );
/**** Shovago:: Products Count **********************************************************************************************************/
function Shovago__Categories() {
	$Shovago__Cats_Args = array( 'post_type' => 'shovago_cats', 'posts_per_page' => -1,);
	$Shovago__Cats_WhileList = new WP_Query( $Shovago__Cats_Args );
	echo "<ul>";
		if( $Shovago__Cats_WhileList->have_posts() ): while( $Shovago__Cats_WhileList->have_posts() ): $Shovago__Cats_WhileList->the_post();
		global $post;
		$Shovago__Cats_link = get_the_permalink();
	  $Shovago__Cats_Icns = get_post_meta( $post->ID, 'Shovago__Cats_Icon', true );
		$Shovago__Cats_Icn = wp_get_attachment_url( $Shovago__Cats_Icns );
		$Shovago__Cats_Class = '';
		if ($post->post_title == 'فيس بوك' || $post->post_title == 'Facebook' || $post->post_title == 'facebook' || $post->post_title == 'فيسبوك') {
			$Shovago__Cats_Class = 'fb';
		}
		if ($post->post_title == 'سنابشات' || $post->post_title == 'Snapchat' || $post->post_title == 'snapchat' || $post->post_title == 'سناب شات') {
			$Shovago__Cats_Class = 'snp';
		}
		if ($post->post_title == 'تيكتوك' || $post->post_title == 'TikTok' || $post->post_title == 'tiktok' || $post->post_title == 'تيك توك') {
			$Shovago__Cats_Class = 'tik';
		}
		echo "<li data-aos='fade-up'><a href=".$Shovago__Cats_link.">";
			echo "<img src=".$Shovago__Cats_Icn." class=".$Shovago__Cats_Class.">";
			echo "<span>".get_the_title()."</span>";
		echo "</a></li>";
		endwhile; wp_reset_query(); endif;
	echo "</ul>";
}
/**** Shovago:: Products **********************************************************************************************************/
function Shovago_Products($cat, $type) {
	$args = array( 'post_type' => 'product',  'posts_per_page' => -1, 
		'orderby' => 'meta_value_num',
		'meta_key' => 'Shovago__HowMuch',
		'order' => 'ASC',
		'meta_query' => array(
			array( 'key' => 'Shovago__Category', 'value' => $cat, ),
			array( 'key' => 'Shovago__Service', 'value' => $type, ),
		),
	);
	$loop = new WP_Query( $args );
	while ( $loop->have_posts() ) : $loop->the_post();
		get_template_part( 'shovago-contents/grids', 'products');
	endwhile;
	wp_reset_query();
}