HEX
Server: nginx/1.27.1
System: Linux in-3 5.15.0-161-generic #171-Ubuntu SMP Sat Oct 11 08:17:01 UTC 2025 x86_64
User: ivenus-clone (3297)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,proc_open,popen,parse_ini_file,show_source
Upload Files
File: /storage/v4513/ivenus-clone/public_html/wp-content/themes/astra/functions_bak.php
<?php

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

if (!defined('ABSPATH')) {
	exit; // Exit if accessed directly.
}

/**
 * Define Constants
 */
define('ASTRA_THEME_VERSION', '4.3.1');
define('ASTRA_THEME_SETTINGS', 'astra-settings');
define('ASTRA_THEME_DIR', trailingslashit(get_template_directory()));
define('ASTRA_THEME_URI', trailingslashit(esc_url(get_template_directory_uri())));
define('ASTRA_PRO_UPGRADE_URL', 'https://wpastra.com/pro/?utm_source=dashboard&utm_medium=free-theme&utm_campaign=upgrade-now');
define('ASTRA_PRO_CUSTOMIZER_UPGRADE_URL', 'https://wpastra.com/pro/?utm_source=customizer&utm_medium=free-theme&utm_campaign=upgrade');

/**
 * Minimum Version requirement of the Astra Pro addon.
 * This constant will be used to display the notice asking user to update the Astra addon to the version defined below.
 */
define('ASTRA_EXT_MIN_VER', '4.1.0');
/**
 * Setup helper functions of Astra.
 */
require_once ASTRA_THEME_DIR . 'inc/core/class-astra-theme-options.php';
require_once ASTRA_THEME_DIR . 'inc/core/class-theme-strings.php';
require_once ASTRA_THEME_DIR . 'inc/core/common-functions.php';
require_once ASTRA_THEME_DIR . 'inc/core/class-astra-icons.php';

/**
 * Update theme
 */
require_once ASTRA_THEME_DIR . 'inc/theme-update/astra-update-functions.php';
require_once ASTRA_THEME_DIR . 'inc/theme-update/class-astra-theme-background-updater.php';

/**
 * Fonts Files
 */
require_once ASTRA_THEME_DIR . 'inc/customizer/class-astra-font-families.php';
if (is_admin()) {
	require_once ASTRA_THEME_DIR . 'inc/customizer/class-astra-fonts-data.php';
}

require_once ASTRA_THEME_DIR . 'inc/lib/webfont/class-astra-webfont-loader.php';
require_once ASTRA_THEME_DIR . 'inc/customizer/class-astra-fonts.php';

require_once ASTRA_THEME_DIR . 'inc/dynamic-css/custom-menu-old-header.php';
require_once ASTRA_THEME_DIR . 'inc/dynamic-css/container-layouts.php';
require_once ASTRA_THEME_DIR . 'inc/dynamic-css/astra-icons.php';
require_once ASTRA_THEME_DIR . 'inc/core/class-astra-walker-page.php';
require_once ASTRA_THEME_DIR . 'inc/core/class-astra-enqueue-scripts.php';
require_once ASTRA_THEME_DIR . 'inc/core/class-gutenberg-editor-css.php';
require_once ASTRA_THEME_DIR . 'inc/core/class-astra-wp-editor-css.php';
require_once ASTRA_THEME_DIR . 'inc/dynamic-css/block-editor-compatibility.php';
require_once ASTRA_THEME_DIR . 'inc/dynamic-css/inline-on-mobile.php';
require_once ASTRA_THEME_DIR . 'inc/dynamic-css/content-background.php';
require_once ASTRA_THEME_DIR . 'inc/class-astra-dynamic-css.php';
require_once ASTRA_THEME_DIR . 'inc/class-astra-global-palette.php';

/**
 * Custom template tags for this theme.
 */
require_once ASTRA_THEME_DIR . 'inc/core/class-astra-attr.php';
require_once ASTRA_THEME_DIR . 'inc/template-tags.php';

require_once ASTRA_THEME_DIR . 'inc/widgets.php';
require_once ASTRA_THEME_DIR . 'inc/core/theme-hooks.php';
require_once ASTRA_THEME_DIR . 'inc/admin-functions.php';
require_once ASTRA_THEME_DIR . 'inc/core/sidebar-manager.php';

/**
 * Markup Functions
 */
require_once ASTRA_THEME_DIR . 'inc/markup-extras.php';
require_once ASTRA_THEME_DIR . 'inc/extras.php';
require_once ASTRA_THEME_DIR . 'inc/blog/blog-config.php';
require_once ASTRA_THEME_DIR . 'inc/blog/blog.php';
require_once ASTRA_THEME_DIR . 'inc/blog/single-blog.php';

/**
 * Markup Files
 */
require_once ASTRA_THEME_DIR . 'inc/template-parts.php';
require_once ASTRA_THEME_DIR . 'inc/class-astra-loop.php';
require_once ASTRA_THEME_DIR . 'inc/class-astra-mobile-header.php';

/**
 * Functions and definitions.
 */
require_once ASTRA_THEME_DIR . 'inc/class-astra-after-setup-theme.php';

// Required files.
require_once ASTRA_THEME_DIR . 'inc/core/class-astra-admin-helper.php';

require_once ASTRA_THEME_DIR . 'inc/schema/class-astra-schema.php';

/* Setup API */
require_once ASTRA_THEME_DIR . 'admin/includes/class-astra-api-init.php';

if (is_admin()) {
	/**
	 * Admin Menu Settings
	 */
	require_once ASTRA_THEME_DIR . 'inc/core/class-astra-admin-settings.php';
	require_once ASTRA_THEME_DIR . 'admin/class-astra-admin-loader.php';
	require_once ASTRA_THEME_DIR . 'inc/lib/astra-notices/class-astra-notices.php';
}

/**
 * Metabox additions.
 */
require_once ASTRA_THEME_DIR . 'inc/metabox/class-astra-meta-boxes.php';

require_once ASTRA_THEME_DIR . 'inc/metabox/class-astra-meta-box-operations.php';

/**
 * Customizer additions.
 */
require_once ASTRA_THEME_DIR . 'inc/customizer/class-astra-customizer.php';

/**
 * Astra Modules.
 */
require_once ASTRA_THEME_DIR . 'inc/modules/posts-structures/class-astra-post-structures.php';
require_once ASTRA_THEME_DIR . 'inc/modules/related-posts/class-astra-related-posts.php';

/**
 * Compatibility
 */
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-gutenberg.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-jetpack.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/woocommerce/class-astra-woocommerce.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/edd/class-astra-edd.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/lifterlms/class-astra-lifterlms.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/learndash/class-astra-learndash.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-beaver-builder.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-bb-ultimate-addon.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-contact-form-7.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-visual-composer.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-site-origin.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-gravity-forms.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-bne-flyout.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-ubermeu.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-divi-builder.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-amp.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-yoast-seo.php';
require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-starter-content.php';
require_once ASTRA_THEME_DIR . 'inc/addons/transparent-header/class-astra-ext-transparent-header.php';
require_once ASTRA_THEME_DIR . 'inc/addons/breadcrumbs/class-astra-breadcrumbs.php';
require_once ASTRA_THEME_DIR . 'inc/addons/scroll-to-top/class-astra-scroll-to-top.php';
require_once ASTRA_THEME_DIR . 'inc/addons/heading-colors/class-astra-heading-colors.php';
require_once ASTRA_THEME_DIR . 'inc/builder/class-astra-builder-loader.php';

// Elementor Compatibility requires PHP 5.4 for namespaces.
if (version_compare(PHP_VERSION, '5.4', '>=')) {
	require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-elementor.php';
	require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-elementor-pro.php';
	require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-web-stories.php';
}

// Beaver Themer compatibility requires PHP 5.3 for anonymus functions.
if (version_compare(PHP_VERSION, '5.3', '>=')) {
	require_once ASTRA_THEME_DIR . 'inc/compatibility/class-astra-beaver-themer.php';
}

require_once ASTRA_THEME_DIR . 'inc/core/markup/class-astra-markup.php';

/**
 * Load deprecated functions
 */
require_once ASTRA_THEME_DIR . 'inc/core/deprecated/deprecated-filters.php';
require_once ASTRA_THEME_DIR . 'inc/core/deprecated/deprecated-hooks.php';
require_once ASTRA_THEME_DIR . 'inc/core/deprecated/deprecated-functions.php';


//start: show a lowest price for product hook

add_filter('woocommerce_get_price_html', 'change_variable_products_price_display', 10, 2);
function change_variable_products_price_display($price, $product)
{

	// Only for variable products type
	if (!$product->is_type('variable'))
		return $price;

	$prices = $product->get_variation_prices(true);

	if (empty($prices['price']))
		return apply_filters('woocommerce_variable_empty_price_html', '', $product);

	$min_price = current($prices['price']);
	$max_price = end($prices['price']);
	$prefix_html = '<span class="price-prefix">' . __('') . '</span>';

	$prefix = $min_price !== $max_price ? $prefix_html : ''; // HERE the prefix

	return apply_filters('woocommerce_variable_price_html', $prefix . wc_price($min_price) . $product->get_price_suffix(), $product);
}

//end: show a lowest price for product hook


// Start : text before a add to car butoon hook

add_action('woocommerce_before_add_to_cart_button', 'mish_before_add_to_cart_btn');

function mish_before_add_to_cart_btn()
{
	global $product;
	$exchange_bonus = get_field('exchange_bonus', $product->get_id());
	echo '<div class="elementor-element elementor-element-c7bb6b7 elementor-widget elementor-widget-button" data-id="c7bb6b7" data-element_type="widget" data-widget_type="button.default">
				<div class="elementor-widget-container">
					<div class="elementor-button-wrapper">
			             <a class="elementor-button elementor-button-link elementor-size-sm" href="#elementor-action%3Aaction%3Dpopup%3Aopen%26settings%3DeyJpZCI6IjkxNiIsInRvZ2dsZSI6ZmFsc2V9">
						   <span class="elementor-button-content-wrapper">
						    <span class="elementor-button-text">' . sprintf(__('%s', 'woocommerce'), $exchange_bonus) . '</span>
		                   </span>
					     </a>
		            </div>
				</div>
			</div>';
}

// end : text before a add to car butoon hook


// Start: change add to cart button text hook

add_filter('woocommerce_product_single_add_to_cart_text', 'custom_woocommerce_button_text');

function custom_woocommerce_button_text()
{

	return __('Add to Cart', 'text-domain');

}

// End: change add to cart button text hook


// Start: change add to cart button text in shop page hook

// add_filter('woocommerce_product_add_to_cart_text', 'bbloomer_change_select_options_button_text', 9999, 2);

// function bbloomer_change_select_options_button_text($label, $product)
// {
// 	if ($product->is_type('variable')) {
// 		return 'Add to Bag';
// 	}
// 	return $label;
// }

// end: change add to cart button text in shop page hook


//Start : add buy now button


function wpamit_add_buy_now_button_single()
{
	global $product;
	printf('<button id="wpamit-adding-button" type="submit" name="wpamit-buy-now" value="%d" class="single_add_to_cart_btn buy_now_button button alt">%s</button>', $product->get_ID(), esc_html__('Buy Now', 'wpamit'));
}

add_action('woocommerce_after_add_to_cart_button', 'wpamit_add_buy_now_button_single');

function wpamit_handle_buy_now()
{
	if (!isset($_REQUEST['wpamit-buy-now'])) {
		return false;
	}

	WC()->cart->empty_cart();

	$product_id = absint($_REQUEST['wpamit-buy-now']);
	$quantity = absint($_REQUEST['quantity']);

	if (isset($_REQUEST['variation_id'])) {

		$variation_id = absint($_REQUEST['variation_id']);
		WC()->cart->add_to_cart($product_id, 1, $variation_id);

	} else {
		WC()->cart->add_to_cart($product_id, $quantity);
	}

	wp_safe_redirect(wc_get_checkout_url());
	exit;
}

add_action('wp_loaded', 'wpamit_handle_buy_now');
//end: add buy now buttoun





/**
 * Add Continue Shopping Button on Cart Page
 **/

add_action('woocommerce_before_cart_table', 'my_add_continue_shopping_button_to_cart');

function my_add_continue_shopping_button_to_cart()
{
	$my_shop_page_url = get_permalink(woocommerce_get_page_id('shop'));
	echo '<div class="woocommerce-message">';
	echo ' <a href="' . $my_shop_page_url . '" class="button continue_shopping_button">Continue Shopping</a>';
	echo '</div>';
}

// start: add custom field to the shop page for new tag
add_action('woocommerce_before_shop_loop_item_title', 'new_tag');
function new_tag()
{
	global $product;

	$new_tag = $product->get_meta('new_tag');

	// Check if the offer statement is not empty
	if (!empty($new_tag)) {
		echo '<p class="ri ri-clock">' . sprintf(__('%s', 'woocommerce'), $new_tag) . '</p>';
	}
}
// end: add custom field to the shop page for new tag

// start: add custom field to the shop page for offer tag
add_action('woocommerce_before_shop_loop_item_title', 'offer_tag');
function offer_tag()
{
	global $product;

	$offer_tag = $product->get_meta('offer_tag');

	// Check if the offer statement is not empty
	if (!empty($offer_tag)) {
		echo '<p class="ri ri-clock">' . sprintf(__('%s', 'woocommerce'), $offer_tag) . '</p>';
	}
}
// end: add custom field to the shop page for offer tag

// start: same variable price show hook
add_filter('woocommerce_show_variation_price', function () {
	return TRUE;
});
// end: same variable price show hook

// start: regular price and sale price show
function wc_codevyne_custom_variable_price($price, $product)
{
	if ($product->is_type('variable')) {
		$min_reg_price = $product->get_variation_regular_price('min');
		$min_sale_price = $product->get_variation_sale_price('min');

		if ($min_reg_price !== $min_sale_price) {
			$price = '<ins style="font-weight:600;">' . wc_price($min_sale_price) . '&nbsp;</ins><del style="font-size: 16px;">' . wc_price($min_reg_price) . '</del>';
		}
	}

	return $price;
}
add_filter('woocommerce_get_price_html', 'wc_codevyne_custom_variable_price', 10, 2);
// end: regular price and sale price show

// start: offer statement in shop page
// function offer()
// {
// 	global $product;

// 	$offer = get_field('offer_statment_prod', $product->get_id());
// 	$offer_flat = get_field('offre_flat', $product->get_id());

// 	if (!empty($offer)) {
// 		echo '<p class="ri ri-clock" style="color: #4775ff;font-size: 12px;">' . sprintf(__('%s', 'woocommerce'), $offer) . '</p>';
// 		echo '<p class="ri ri-clock" style="color: #008000;font-size: 12px;margin-bottom: 5px !important;margin-top: -8px">' . sprintf(__('%s', 'woocommerce'), $offer_flat) . '</p>';
// 	}
// }
// add_action('woocommerce_get_price_html', 'offer', 5);
// end: offer statement in shop page

function custom_wc_stock_status_text($availability, $product)
{
	// Check if the product is in stock
	if ($product->is_in_stock()) {
		$availability['availability'] = __('In Stock', 'woocommerce');
	} else {
		$availability['availability'] = __('Out of Stock', 'woocommerce');
	}

	return $availability;
}

// Hook into the woocommerce_get_availability filter
add_filter('woocommerce_get_availability', 'custom_wc_stock_status_text', 10, 2);

add_action( 'woocommerce_after_main_content', 'woocommerce_taxonomy_archive_description', 5 );