HEX
Server: nginx/1.18.0
System: Linux vcwordpress 5.15.0-174-generic #184-Ubuntu SMP Fri Mar 13 18:41:50 UTC 2026 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vcstore.viitorcloud.co/wp-content/themes/vcmarketplace/functions.php
<?php

/**
 * vcmarketplace functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package vcmarketplace
 */

if (!defined('_S_VERSION')) {
	// Replace the version number of the theme on each release.
	define('_S_VERSION', '1.0.0');
}

/**
 * Sets up theme defaults and registers support for various WordPress features.
 *
 * Note that this function is hooked into the after_setup_theme hook, which
 * runs before the init hook. The init hook is too late for some features, such
 * as indicating support for post thumbnails.
 */
function vcmarketplace_setup()
{
	/*
		* Make theme available for translation.
		* Translations can be filed in the /languages/ directory.
		* If you're building a theme based on vcmarketplace, use a find and replace
		* to change 'vcmarketplace' to the name of your theme in all the template files.
		*/
	load_theme_textdomain('vcmarketplace', get_template_directory() . '/languages');

	// Add default posts and comments RSS feed links to head.
	// add_theme_support( 'automatic-feed-links' );

	/*
		* Let WordPress manage the document title.
		* By adding theme support, we declare that this theme does not use a
		* hard-coded <title> tag in the document head, and expect WordPress to
		* provide it for us.
		*/
	// add_theme_support( 'title-tag' );

	/*
		* Enable support for Post Thumbnails on posts and pages.
		*
		* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
		*/
	// add_theme_support( 'post-thumbnails' );

	// This theme uses wp_nav_menu() in one location.
	// register_nav_menus(
	// 	array(
	// 		'menu-1' => esc_html__( 'Primary', 'vcmarketplace' ),
	// 	)
	// );
	register_nav_menus(
		array(
			'primary' => __('Primary Menu'),
		)
	);


	/*
		* Switch default core markup for search form, comment form, and comments
		* to output valid HTML5.
		*/
	add_theme_support(
		'html5',
		array(
			'search-form',
			'comment-form',
			'comment-list',
			'gallery',
			'caption',
			'style',
			'script',
		)
	);

	// Set up the WordPress core custom background feature.
	add_theme_support(
		'custom-background',
		apply_filters(
			'vcmarketplace_custom_background_args',
			array(
				'default-color' => 'ffffff',
				'default-image' => '',
			)
		)
	);

	// Add theme support for selective refresh for widgets.
	add_theme_support('customize-selective-refresh-widgets');

	/**
	 * Add support for core custom logo.
	 *
	 * @link https://codex.wordpress.org/Theme_Logo
	 */
	add_theme_support(
		'custom-logo',
		array(
			'height'      => 250,
			'width'       => 250,
			'flex-width'  => true,
			'flex-height' => true,
		)
	);
}
add_action('after_setup_theme', 'vcmarketplace_setup');

function vcmarketplace_woocommerce_support()
{
	add_theme_support('woocommerce');
}
add_action('after_setup_theme', 'vcmarketplace_woocommerce_support');

/**
 * Set the content width in pixels, based on the theme's design and stylesheet.
 *
 * Priority 0 to make it available to lower priority callbacks.
 *
 * @global int $content_width
 */
function vcmarketplace_content_width()
{
	$GLOBALS['content_width'] = apply_filters('vcmarketplace_content_width', 640);
}
add_action('after_setup_theme', 'vcmarketplace_content_width', 0);

/**
 * Register widget area.
 *
 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
 */
function vcmarketplace_widgets_init()
{
	register_sidebar(
		array(
			'name'          => esc_html__('Sidebar', 'vcmarketplace'),
			'id'            => 'sidebar-1',
			'description'   => esc_html__('Add widgets here.', 'vcmarketplace'),
			'before_widget' => '<section id="%1$s" class="widget %2$s">',
			'after_widget'  => '</section>',
			'before_title'  => '<h2 class="widget-title">',
			'after_title'   => '</h2>',
		)
	);
}
add_action('widgets_init', 'vcmarketplace_widgets_init');

/**
 * Enqueue scripts and styles.
 */
function vcmarketplace_scripts()
{
	wp_enqueue_style('vcmarketplace-style', get_stylesheet_uri(), array(), _S_VERSION);
	wp_style_add_data('vcmarketplace-style', 'rtl', 'replace');

	wp_enqueue_script('vcmarketplace-navigation', get_template_directory_uri() . '/js/navigation.js', array(), _S_VERSION, true);

	if (is_singular() && comments_open() && get_option('thread_comments')) {
		wp_enqueue_script('comment-reply');
	}
}
add_action('wp_enqueue_scripts', 'vcmarketplace_scripts');

/**
 * Implement the Custom Header feature.
 */
// require get_template_directory() . '/inc/custom-header.php';

/**
 * Custom template tags for this theme.
 */
// require get_template_directory() . '/inc/template-tags.php';

/**
 * Functions which enhance the theme by hooking into WordPress.
 */
// require get_template_directory() . '/inc/template-functions.php';

/**
 * Customizer additions.
 */
// require get_template_directory() . '/inc/customizer.php';

/**
 * Load Jetpack compatibility file.
 */
if (defined('JETPACK__VERSION')) {
	require get_template_directory() . '/inc/jetpack.php';
}



/**
 * Enqueue Child Theme Assets
 */
function vc_enqueue_scripts()
{
	if (!is_admin()) {
		$version = wp_get_theme()->get('Version');
		wp_enqueue_style('csco_child_css', trailingslashit(get_stylesheet_directory_uri()) . 'style.css', array(), $version, 'all');
		wp_enqueue_style('child-theme-bootstrap', get_stylesheet_directory_uri() . '/assets/css/bootstrap.min.css');
		wp_enqueue_style('child-slick', get_stylesheet_directory_uri() . '/assets/css/slick.css');
		wp_enqueue_style('child-slick-theme', get_stylesheet_directory_uri() . '/assets/css/slick-theme.css');
		wp_enqueue_style('style', get_stylesheet_directory_uri() . '/assets/css/style.css');
		wp_enqueue_style('home', get_stylesheet_directory_uri() . '/assets/css/home.css');
		wp_enqueue_style('child-theme-all', get_stylesheet_directory_uri() . '/assets/css/all.min.css');
		wp_enqueue_script('jquery-3.6.0.min', get_template_directory_uri() . '/assets/js/jquery-3.6.0.min.js', array('jquery'), 1.1, true);
		wp_enqueue_script('child-theme-bootstrap', get_stylesheet_directory_uri() . '/assets/js/bootstrap.min.js', array('jquery'), '1.0', true);
		wp_enqueue_script('child-theme-slick', get_stylesheet_directory_uri() . '/assets/js/slick.min.js', array('jquery'), '1.0', true);
		wp_enqueue_script('custom', get_stylesheet_directory_uri() . '/assets/js/custom.js', array('jquery'), '1.0', true);
		wp_enqueue_script('slider', get_stylesheet_directory_uri() . '/assets/js/slider.js', array('jquery'), '1.0', true);
	}
}

add_action('wp_enqueue_scripts', 'vc_enqueue_scripts', 99);

function add_custom_mime_types($mimes)
{
	$mimes['ico'] = 'image/x-icon';
	return $mimes;
}
add_filter('upload_mimes', 'add_custom_mime_types');

// Add options page
if (function_exists('acf_add_options_page')) {
	acf_add_options_page(
		array(
			'page_title' => 'Theme Settings',
			'menu_title' => 'Theme Settings',
			'menu_slug'  => 'theme-general-settings',
			'capability' => 'edit_posts',
			'redirect'   => false,
		)
	);

	acf_add_options_sub_page(
		array(
			'page_title'  => 'Footer Options',
			'menu_title'  => 'Footer Options',
			'parent_slug' => 'theme-general-settings',
		)
	);
	acf_add_options_sub_page(
		array(
			'page_title'  => 'Blog sidebar',
			'menu_title'  => 'Blog sidebar',
			'parent_slug' => 'theme-general-settings',
		)
	);
}


function Allow_Svg_upload($mimes)
{
	$mimes['svg'] = 'image/svg+xml';
	return $mimes;
}
add_filter('upload_mimes', 'Allow_Svg_upload');

function marketplace_remove_fields($woo_checkout_fields_array)
{
	$woo_checkout_fields_array['billing']['billing_phone']['required'] = false;
	unset($woo_checkout_fields_array['billing']['billing_phone']);
	unset($woo_checkout_fields_array['billing']['billing_company']);
	unset($woo_checkout_fields_array['billing']['billing_country']);
	$woo_checkout_fields_array['billing']['billing_address_1']['required'] = false;
	unset($woo_checkout_fields_array['billing']['billing_address_1']);
	$woo_checkout_fields_array['billing']['billing_address_2']['required'] = false;
	unset($woo_checkout_fields_array['billing']['billing_address_2']);
	$woo_checkout_fields_array['billing']['billing_city']['required'] = false;
	unset($woo_checkout_fields_array['billing']['billing_city']);
	unset($woo_checkout_fields_array['billing']['billing_state']);
	unset($woo_checkout_fields_array['billing']['billing_postcode']);
	unset($woo_checkout_fields_array['shipping']['shipping_first_name']);
	unset($woo_checkout_fields_array['shipping']['shipping_last_name']);
	unset($woo_checkout_fields_array['shipping']['shipping_company']);
	unset($woo_checkout_fields_array['shipping']['shipping_address_1']);
	unset($woo_checkout_fields_array['shipping']['shipping_address_2']);
	unset($woo_checkout_fields_array['shipping']['shipping_city']);
	unset($woo_checkout_fields_array['shipping']['shipping_postcode']);
	unset($woo_checkout_fields_array['shipping']['shipping_country']);
	unset($woo_checkout_fields_array['shipping']['shipping_state']);
	unset($woo_checkout_fields_array['account']['account_password']);
	unset($woo_checkout_fields_array['account']['account_password-2']);
	unset($woo_checkout_fields_array['account']['account_username']);
	// remove order comment fields
	unset($woo_checkout_fields_array['order']['order_comments']);
	return $woo_checkout_fields_array;
}
add_filter('woocommerce_checkout_fields', 'marketplace_remove_fields', 9999);
add_filter('woocommerce_enable_order_notes_field', '__return_false');
add_filter('woocommerce_ship_to_different_address_checked', '__return_false');



function load_more_products()
{
	$paged = $_POST['paged'];
	$category_slug = $_POST['category_slug'];

	$args = array(
		'post_type' => 'product',
		'posts_per_page' => 12,
		'paged' => $paged,
		'tax_query' => array(
			array(
				'taxonomy' => 'product_cat',
				'field' => 'slug',
				'terms' => $category_slug,
			),
		),
	);

	$loop = new WP_Query($args);

	if ($loop->have_posts()) :
		while ($loop->have_posts()) : $loop->the_post();
			global $product;
			$thumbnail_id = get_post_thumbnail_id($product->ID);
			$thumbnail = get_the_post_thumbnail_url($product->ID, 'full');
			$thumbnail_alt = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true);
			$product_url = get_field('product_url', $product->ID);
			$upload_filters_video = get_field('upload_filters_video', $product->ID);
			$instagram_filter_url = get_field('instagram_filter_url', $product->ID);
			$snapchat_filter_url = get_field('snapchat_filter_url', $product->ID);
			$facebook_filter_url = get_field('facebook_filter_url', $product->ID);
			// Get the product categories
			$categories = get_the_terms($product->ID, 'product_cat');
			$category_name = '';
			if ($categories && !is_wp_error($categories)) {
				$category_name = $categories[0]->name;
			}
?>
			<div class="col-6 col-md-4 col-lg-3 col-xl-2">
				<div class="filter-card">
					<div class="filter-img position-relative">
						<?php if ($upload_filters_video) { ?>
							<video autoplay muted loop class="video-size" width="100%">
								<source src="<?php echo $upload_filters_video; ?>" type="video/mp4">
							</video>
						<?php } else { ?>
							<img src="<?php echo $thumbnail; ?>" alt="<?php echo $thumbnail_alt; ?>" width="100%" height="100%" />
						<?php } ?>
						<div class="social-media-buttons align-items-end justify-content-center position-absolute w-100 h-100 top-0">
							<?php if ($instagram_filter_url) { ?>
								<a href="<?php echo $instagram_filter_url; ?>" class="d-flex align-items-center justify-content-center" target="_blank" rel="noopener noreferrer"><i class="fa-brands fa-instagram"></i>
								</a>
							<?php }
							if ($facebook_filter_url) { ?>
								<a href="<?php echo $facebook_filter_url; ?>" class="d-flex align-items-center justify-content-center" target="_blank" rel="noopener noreferrer"><i class="fa-brands fa-facebook-f"></i>
								</a>
							<?php }
							if ($snapchat_filter_url) { ?>
								<a href="<?php echo $snapchat_filter_url; ?>" class="d-flex align-items-center justify-content-center" target="_blank" rel="noopener noreferrer"><i class="fa-brands fa-snapchat"></i>
								</a>
							<?php } ?>
						</div>
					</div>
					<p class="font-20 text-center text-black filter-title"><?php the_title(); ?></p>
					<p class="font-18 text-center font-black-light"><?php echo esc_html($category_name); ?></p>
				</div>
			</div>
<?php
		endwhile;
	else :
		echo '';
	endif;
	wp_reset_postdata();
	wp_die();
}

add_action('wp_ajax_nopriv_load_more_products', 'load_more_products');
add_action('wp_ajax_load_more_products', 'load_more_products');

// Add custom CSS to hide the Update Cart button on the checkout page
function hide_update_cart_button_checkout()
{
	if (is_checkout()) {
		echo '<style>
            .button[name="update_cart"] {
                display: none !important;
            }
        </style>';
	}
}
add_action('wp_head', 'hide_update_cart_button_checkout');

/**
 * SMTP Configuration
 *
 * @param [type] $phpmailer
 * @return void
 */
function configure_smtp($phpmailer)
{
	$phpmailer->isSMTP();
	$phpmailer->Host       = SMTP_HOST;
	$phpmailer->SMTPAuth   = SMTP_AUTH;
	$phpmailer->Port       = SMTP_PORT;
	$phpmailer->Username   = SMTP_USER;
	$phpmailer->Password   = SMTP_PASS;
	$phpmailer->SMTPSecure = SMTP_SECURE;
	$phpmailer->From       = SMTP_FROM;
	$phpmailer->FromName   = SMTP_NAME;
}

add_action('phpmailer_init', 'configure_smtp');

/**
 * Automatically completes orders in WooCommerce when their status changes to processing.
 *
 * This function hooks into the 'woocommerce_order_status_processing' action, which is triggered
 * when an order's status changes to 'processing'. It updates the order status to 'completed'.
 *
 * @param int $order_id The ID of the order being processed.
 * @return void
 */
function marketplace_change_order_status($order_id) {
    if (!$order_id) return;

    $order = wc_get_order($order_id);

    if ('paypal' === $order->get_payment_method()) {
        if ('on-hold' === $order->get_status()) {
            $order->update_status('processing');
        }

        // If the order contains only downloadable products, change the status to completed
        $all_products_downloadable = true;
        foreach ($order->get_items() as $item) {
            $product = $item->get_product();
            if (!$product->is_downloadable()) {
                $all_products_downloadable = false;
                break;
            }
        }

        if ($all_products_downloadable) {
            $order->update_status('completed');
        }
    }
}

add_action('woocommerce_thankyou', 'marketplace_change_order_status', 10, 1);

/**
 * Disable gutenberg editor
 */
add_filter('use_block_editor_for_post_type', '__return_false');
add_filter( 'use_widgets_block_editor', '__return_false' );