<?php
/**
 * Prime Spa Center functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Prime Spa Center
 */

if ( ! defined( 'PRIME_SPA_CENTER_URL' ) ) {
    define( 'PRIME_SPA_CENTER_URL', esc_url( 'https://www.themeignite.com/products/spa-wordpress-theme', 'prime-spa-center') );
}
if ( ! defined( 'PRIME_SPA_CENTER_FREE_DOC_URL' ) ) {
    define( 'PRIME_SPA_CENTER_FREE_DOC_URL', esc_url( 'https://demo.themeignite.com/documentation/prime-spa-center-free', 'prime-spa-center') );
}
if ( ! defined( 'PRIME_SPA_CENTER_PRO_DOC_URL' ) ) {
    define( 'PRIME_SPA_CENTER_PRO_DOC_URL', esc_url( 'https://demo.themeignite.com/documentation/prime-spa-center-pro/', 'prime-spa-center') );
}
if ( ! defined( 'PRIME_SPA_CENTER_DEMO_URL' ) ) {
    define( 'PRIME_SPA_CENTER_DEMO_URL', esc_url( 'https://demo.themeignite.com/prime-spa-center/', 'prime-spa-center') );
}
if ( ! defined( 'PRIME_SPA_CENTER_REVIEW_URL' ) ) {
    define( 'PRIME_SPA_CENTER_REVIEW_URL', esc_url( 'https://wordpress.org/support/theme/prime-spa-center/reviews/#new-post', 'prime-spa-center') );
}
if ( ! defined( 'PRIME_SPA_CENTER_SUPPORT_URL' ) ) {
    define( 'PRIME_SPA_CENTER_SUPPORT_URL', esc_url( 'https://wordpress.org/support/theme/prime-spa-center', 'prime-spa-center') );
}
if ( ! defined( 'PRIME_SPA_CENTER_BUNDLE_URL' ) ) {
    define( 'PRIME_SPA_CENTER_BUNDLE_URL', esc_url( 'https://www.themeignite.com/products/wp-theme-bundle', 'prime-spa-center') );
}


$prime_spa_center_theme_data = wp_get_theme();
if( ! defined( 'PRIME_SPA_CENTER_THEME_VERSION' ) ) define ( 'PRIME_SPA_CENTER_THEME_VERSION', $prime_spa_center_theme_data->get( 'Version' ) );
if( ! defined( 'PRIME_SPA_CENTER_THEME_NAME' ) ) define( 'PRIME_SPA_CENTER_THEME_NAME', $prime_spa_center_theme_data->get( 'Name' ) );
if( ! defined( 'PRIME_SPA_CENTER_THEME_TEXTDOMAIN' ) ) define( 'PRIME_SPA_CENTER_THEME_TEXTDOMAIN', $prime_spa_center_theme_data->get( 'TextDomain' ) );

if ( ! function_exists( 'prime_spa_center_setup' ) ) :
/**
 * 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 prime_spa_center_setup() {
	/*
	 * Make theme available for translation.
	 * Translations can be filed in the /languages/ directory.
	 * If you're building a theme based on Prime Spa Center, use a find and replace
	 * to change 'prime-spa-center' to the name of your theme in all the template files.
	 */
	load_theme_textdomain( 'prime-spa-center', 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(
		'primary' => esc_html__( 'Primary', 'prime-spa-center' ),
	) );

	// Enable support for custom logo.
	add_theme_support( 'custom-logo' , array(
		'height'		=>45,	
		'width'			=>45,	
		'flex-height'	=>true,	
		'flex-width'	=>true,
	));

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

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

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

	/*
	* This theme styles the visual editor to resemble the theme style,
	* specifically font, colors, icons, and column width.
	*/
	$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
	add_editor_style( array( '/assets/css/editor-style' . $min . '.css', prime_spa_center_fonts_url() ) );

	// Gutenberg support
	add_theme_support( 'editor-color-palette', array(
       	array(
			'name' => esc_html__( 'Tan', 'prime-spa-center' ),
			'slug' => 'tan',
			'color' => '#E6DBAD',
       	),
       	array(
           	'name' => esc_html__( 'Yellow', 'prime-spa-center' ),
           	'slug' => 'yellow',
           	'color' => '#FDE64B',
       	),
       	array(
           	'name' => esc_html__( 'Orange', 'prime-spa-center' ),
           	'slug' => 'orange',
           	'color' => '#ED7014',
       	),
       	array(
           	'name' => esc_html__( 'Red', 'prime-spa-center' ),
           	'slug' => 'red',
           	'color' => '#D0312D',
       	),
       	array(
           	'name' => esc_html__( 'Pink', 'prime-spa-center' ),
           	'slug' => 'pink',
           	'color' => '#b565a7',
       	),
       	array(
           	'name' => esc_html__( 'Purple', 'prime-spa-center' ),
           	'slug' => 'purple',
           	'color' => '#A32CC4',
       	),
       	array(
           	'name' => esc_html__( 'Blue', 'prime-spa-center' ),
           	'slug' => 'blue',
           	'color' => '#3A43BA',
       	),
       	array(
           	'name' => esc_html__( 'Green', 'prime-spa-center' ),
           	'slug' => 'green',
           	'color' => '#3BB143',
       	),
       	array(
           	'name' => esc_html__( 'Brown', 'prime-spa-center' ),
           	'slug' => 'brown',
           	'color' => '#231709',
       	),
       	array(
           	'name' => esc_html__( 'Grey', 'prime-spa-center' ),
           	'slug' => 'grey',
           	'color' => '#6C626D',
       	),
       	array(
           	'name' => esc_html__( 'Black', 'prime-spa-center' ),
           	'slug' => 'black',
           	'color' => '#000000',
       	),
   	));

	add_theme_support( 'align-wide' );
	add_theme_support( 'editor-font-sizes', array(
	   	array(
	       	'name' => esc_html__( 'small', 'prime-spa-center' ),
	       	'shortName' => esc_html__( 'S', 'prime-spa-center' ),
	       	'size' => 12,
	       	'slug' => 'small'
	   	),
	   	array(
	       	'name' => esc_html__( 'regular', 'prime-spa-center' ),
	       	'shortName' => esc_html__( 'M', 'prime-spa-center' ),
	       	'size' => 16,
	       	'slug' => 'regular'
	   	),
	   	array(
	       	'name' => esc_html__( 'larger', 'prime-spa-center' ),
	       	'shortName' => esc_html__( 'L', 'prime-spa-center' ),
	       	'size' => 36,
	       	'slug' => 'larger'
	   	),
	   	array(
	       	'name' => esc_html__( 'huge', 'prime-spa-center' ),
	       	'shortName' => esc_html__( 'XL', 'prime-spa-center' ),
	       	'size' => 48,
	       	'slug' => 'huge'
	   	)
	));
	add_theme_support('editor-styles');
	add_theme_support( 'wp-block-styles' );
	add_theme_support( 'woocommerce' );
	add_theme_support( 'wc-product-gallery-zoom' );
    add_theme_support( 'wc-product-gallery-slider' );
    add_theme_support( 'responsive-embeds' );
}
endif;
add_action( 'after_setup_theme', 'prime_spa_center_setup' );

/**
 * 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 prime_spa_center_content_width() {
	$GLOBALS['content_width'] = apply_filters( 'prime_spa_center_content_width', 640 );
}
add_action( 'after_setup_theme', 'prime_spa_center_content_width', 0 );

/**
 * Register widget area.
 *
 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
 */
function prime_spa_center_widgets_init() {
	register_sidebar( array(
		'name'          => esc_html__( 'Sidebar Option', 'prime-spa-center' ),
		'id'            => 'right-sidebar',
		'description'   => '',
		'before_widget' => '<section id="%1$s" class="widget %2$s">',
		'after_widget'  => '</section>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',
	) );
	register_sidebar( array(
		'name'          => esc_html__( 'Sidebar Two', 'prime-spa-center' ),
		'id'            => 'sidebar-2',
		'description'   => '',
		'before_widget' => '<section id="%1$s" class="widget %2$s">',
		'after_widget'  => '</section>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',
	) );
	register_sidebar( array(
		'name'          => esc_html__( 'Sidebar Three', 'prime-spa-center' ),
		'id'            => 'sidebar-3',
		'description'   => '',
		'before_widget' => '<section id="%1$s" class="widget %2$s">',
		'after_widget'  => '</section>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',
	) );
		register_sidebar( array(
		'name'          => esc_html__( 'Footer 1', 'prime-spa-center' ),
		'id'            => 'footer-1',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',
	) );
	register_sidebar( array(
		'name'          => esc_html__( 'Footer 2', 'prime-spa-center' ),
		'id'            => 'footer-2',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',
	) );
	register_sidebar( array(
		'name'          => esc_html__( 'Footer 3', 'prime-spa-center' ),
		'id'            => 'footer-3',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',
	) );
	register_sidebar( array(
		'name'          => esc_html__( 'Footer 4', 'prime-spa-center' ),
		'id'            => 'footer-4',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',
	) );
}
add_action( 'widgets_init', 'prime_spa_center_widgets_init' );

/**
 * Register custom fonts.
 */
function prime_spa_center_fonts_url() {
	$font_family   = array(
		'Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900',		
	);
	
	$fonts_url = add_query_arg( array(
		'family' => implode( '&family=', $font_family ),
		'display' => 'swap',
	), 'https://fonts.googleapis.com/css2' );

	$contents = wptt_get_webfont_url( esc_url_raw( $fonts_url ) );
	return $contents;
}

/**
 * Enqueue scripts and styles.
 */
function prime_spa_center_scripts() {
	$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
	$fonts_url = prime_spa_center_fonts_url();
	$primary_color = prime_spa_center_get_option( 'primary_color' );
	if ( ! empty( $fonts_url ) ) {
		wp_enqueue_style( 'prime-spa-center-google-fonts', $fonts_url, array(), null );
	}
	
	wp_enqueue_style( 'bootstrap-style', get_template_directory_uri().'/assets/css/bootstrap.css' );

	wp_enqueue_style( 'fontawesome-all', get_template_directory_uri() . '/assets/css/all' . $min . '.css', '', '4.7.0' );
	
	wp_enqueue_style( 'slick-theme-css', get_template_directory_uri() .'/assets/css/slick-theme' . $min . '.css', '', 'v2.2.0');

	wp_enqueue_style( 'slick-css', get_template_directory_uri() .'/assets/css/slick' . $min . '.css', '', 'v1.8.0');

	wp_enqueue_style( 'prime-spa-center-blocks', get_template_directory_uri() . '/assets/css/blocks' . $min . '.css' );
	
	wp_enqueue_style( 'prime-spa-center-style', get_stylesheet_uri() );

	wp_style_add_data('prime-spa-center-style', 'rtl', 'replace');

	require get_parent_theme_file_path( '/inc/css_custom.php' );

	wp_add_inline_style( 'prime-spa-center-style',$prime_spa_center_custom_css );
	
	wp_enqueue_script( 'jquery-slick', get_template_directory_uri() . '/assets/js/slick' . $min . '.js', array('jquery'), '2017417', true );
	
	wp_enqueue_script( 'prime-spa-center-navigation', get_template_directory_uri() . '/assets/js/navigation' . $min . '.js', array(), '20151215', true );

	wp_enqueue_script( 'custom-js', get_template_directory_uri(). '/assets/js/custom.js', array('jquery') ,'',true);

	wp_enqueue_script( 'prime-spa-center-skip-link-focus-fix', get_template_directory_uri() . '/assets/js/skip-link-focus-fix' . $min . '.js', array(), '20151215', true );
	// Wow script.
	wp_enqueue_script( 'wow-jquery', get_template_directory_uri() . '/assets/js/wow.js', array('jquery'),'' ,true );
	// Animate CSS
	wp_enqueue_style( 'animate-style', get_template_directory_uri() . '/assets/css/animate.css' );

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

if( ! function_exists( 'prime_spa_center_admin_scripts' ) ) :
/**
 * Addmin scripts
*/
function prime_spa_center_admin_scripts() {
	wp_enqueue_style( 'prime-spa-center-admin-style',get_template_directory_uri().'/assets/css/admin.css', PRIME_SPA_CENTER_THEME_VERSION, 'screen' );
}
endif;
add_action( 'admin_enqueue_scripts', 'prime_spa_center_admin_scripts' );

/**
 * Enqueue editor styles for Gutenberg
 *
 * @since Prime Spa Center 1.0.0
 */
function prime_spa_center_block_editor_styles() {
	$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
	// Block styles.
	wp_enqueue_style( 'prime-spa-center-block-editor-style', get_theme_file_uri( '/assets/css/editor-blocks' . $min . '.css' ) );
	// Add custom fonts.
	wp_enqueue_style( 'prime-spa-center-fonts', prime_spa_center_fonts_url(), array(), null );
}
add_action( 'enqueue_block_editor_assets', 'prime_spa_center_block_editor_styles' );

// Change number or products per row to 3
add_filter('loop_shop_columns', 'prime_spa_center_loop_columns');
	if (!function_exists('prime_spa_center_loop_columns')) {
		function prime_spa_center_loop_columns() {
		return 3; // 3 products per row
	}
}

//Change number of products that are displayed per page (shop page)
add_filter( 'loop_shop_per_page', 'prime_spa_center_products_per_page' );
function prime_spa_center_products_per_page( $cols ) {
  	return  9;
}
/**
 * AJAX handler to dismiss Whizzie notice
 */
if ( ! function_exists( 'prime_spa_center_dismiss_whizzie_notice' ) ) {
    function prime_spa_center_dismiss_whizzie_notice() {

        update_user_meta(
            get_current_user_id(),
            'prime_spa_center_whizzie_dismissed',
            true
        );

        wp_die();
    }
}
add_action(
    'wp_ajax_prime_spa_center_dismiss_whizzie_notice',
    'prime_spa_center_dismiss_whizzie_notice'
);


/**
 * Check if Whizzie notice is dismissed
 */
if ( ! function_exists( 'prime_spa_center_is_whizzie_dismissed' ) ) {
    function prime_spa_center_is_whizzie_dismissed() {

        return (bool) get_user_meta(
            get_current_user_id(),
            'prime_spa_center_whizzie_dismissed',
            true
        );

    }
}

/**
 * Reset Whizzie notice when theme is activated
 */
add_action( 'after_switch_theme', function () {

    $users = get_users( array(
        'fields' => 'ID',
    ) );

    foreach ( $users as $user_id ) {
        delete_user_meta( $user_id, 'prime_spa_center_whizzie_dismissed' );
    }

});

/**
 * Display the admin notice unless dismissed.
 */
function prime_spa_center_dashboard_notice() {
    // Check if the notice is dismissed
    $dismissed = get_user_meta( get_current_user_id(), 'prime_spa_center_dismissable_notice', true );

    // Display the notice only if not dismissed
    if ( ! $dismissed ) {

        // Get the theme name dynamically
        $theme_name = wp_get_theme()->get( 'Name' );
        ?>
        <div class="updated notice notice-success is-dismissible notice-get-started-class" data-notice="get-start">
            <div class="notice-details">
                <div class="notice-content">
                    <h2>
                        <?php 
                        /* translators: %s: Theme name */
                        printf(
                            esc_html__( 'Thank you for installing %s.', 'prime-spa-center' ),
                            '<strong>' . esc_html( $theme_name ) . '</strong>'
                        );
                        ?>
                    </h2>
                    <p><?php echo esc_html__( 'Your journey to a powerful and stylish website begins here. Let’s get everything set up in just a few clicks!', 'prime-spa-center' ); ?></p>
                    <div class="notice-btns">
                        <a style="margin-bottom: 15px; padding: 8px 15px;" class="button button-primary getstart"
                           href="<?php echo esc_url( admin_url( 'themes.php?page=prime-spa-center' ) ); ?>">
                           <?php esc_html_e( 'Getting Started', 'prime-spa-center' ); ?>
                        </a>                         
                        <a style="margin-left: 30px; padding: 8px 15px;" class="button button-primary premium"
                           target="_blank" href="<?php echo esc_url( 'https://www.themeignite.com/products/spa-wordpress-theme' ); ?>">
                           <?php esc_html_e( 'Go To Premium', 'prime-spa-center' ); ?>
                        </a>
						<a style="margin-left: 30px; padding: 8px 15px; background-color: #fff; color: #000;" class="button button-primary demo" target="_blank" href="<?php echo esc_url(PRIME_SPA_CENTER_DEMO_URL); ?>"><?php esc_html_e('View Demo', 'prime-spa-center') ?></a>
                    </div>
                </div>
                <div class="notice-img">
                    <img src="<?php echo esc_url( get_template_directory_uri() . '/assets/images/notice.png' ); ?>" alt="<?php echo esc_attr( $theme_name ); ?>">
                </div>  
            </div>
        </div>
        <?php
    }
}

// Hook to display the notice
add_action( 'admin_notices', 'prime_spa_center_dashboard_notice' );

/**
 * AJAX handler to dismiss the notice.
 */
function prime_spa_center_dismissable_notice() {
    // Set user meta to indicate the notice is dismissed
    update_user_meta(get_current_user_id(), 'prime_spa_center_dismissable_notice', true);
    die();
}

// Hook for the AJAX action
add_action('wp_ajax_prime_spa_center_dismissable_notice', 'prime_spa_center_dismissable_notice');

/**
 * Clear dismissed notice state when switching themes.
 */
function prime_spa_center_switch_theme() {
    // Clear the dismissed notice state when switching themes
    delete_user_meta(get_current_user_id(), 'prime_spa_center_dismissable_notice');
}

// Hook for switching themes
add_action('after_switch_theme', 'prime_spa_center_switch_theme');

function prime_spa_center_template_setup() {

/**
 * Load init.
 */
require_once get_template_directory() . '/inc/init.php';

/**
 * Getting Started
*/
require get_template_directory() . '/inc/getting-started/getting-started.php';

/**
 * Load plugin for right and no sidebar
 */
require get_template_directory() . '/inc/woocommerce-functions.php';

/**
 * Pro Link.
 */
require_once get_template_directory() . '/inc/premium-link/class-button-link.php';

/**
 * setup wizard
 */
require get_parent_theme_file_path( '/theme-wizard/config.php' );

}
add_action('after_setup_theme', 'prime_spa_center_template_setup');

/**
 *  Webfonts 
 */
require get_template_directory() . '/inc/wptt-webfont-loader.php';

// range contol
function prime_spa_center_sanitize_number_absint( $number, $setting ) {

	// Ensure input is an absolute integer.
	$number = absint( $number );

	// Get the input attributes associated with the setting.
	$atts = $setting->manager->get_control( $setting->id )->input_attrs;

	// Get minimum number in the range.
	$min = ( isset( $atts['min'] ) ? $atts['min'] : $number );

	// Get maximum number in the range.
	$max = ( isset( $atts['max'] ) ? $atts['max'] : $number );

	// Get step.
	$step = ( isset( $atts['step'] ) ? $atts['step'] : 1 );

	// If the number is within the valid range, return it; otherwise, return the default
	return ( $min <= $number && $number <= $max && is_int( $number / $step ) ? $number : $setting->default );
}


/**
 * Set the number of products displayed per row on WooCommerce archive pages.
 *
 * @param int $columns Number of columns per row.
 * @return int Number of columns to display per row.
 */
function customize_woocommerce_archive_per_row($columns) {
    // Set the desired number of columns per row.
    $columns = prime_spa_center_get_option( 'prime_spa_center_archive_product_per_row' ); // You can change this to your preferred number.

    return $columns;
}

// Add a filter to modify the number of columns per row on WooCommerce archive pages.
add_filter('loop_shop_columns', 'customize_woocommerce_archive_per_row');

/**
 * Set the number of products displayed per page on WooCommerce archive pages.
 *
 * @param int $posts_per_page Number of products per page.
 * @return int Number of products to display per page.
 */
function customize_woocommerce_archive_per_page($posts_per_page) {
    // Set the desired number of products per page.
    $posts_per_page = prime_spa_center_get_option( 'prime_spa_center_archive_product_per_page' ); // You can change this to your preferred number.

    return $posts_per_page;
}

// Add a filter to modify the number of products displayed per page on WooCommerce archive pages.
add_filter('loop_shop_per_page', 'customize_woocommerce_archive_per_page');


// Retrieve the slider visibility setting
$prime_spa_center_slider = get_theme_mod('enable_featured_slider_section', false);

// Function to output custom CSS directly in the head section
function prime_spa_center_custom_css() {
    global $prime_spa_center_slider;
    if ($prime_spa_center_slider == false) {
        echo '<style type="text/css">
            .page-template-template-home .header-main {
                position: static;
                background:#fff;
                border-bottom: 1px solid #1c1c1c;
            }
        </style>';
    }
}

// Hook the function into the wp_head action
add_action('wp_head', 'prime_spa_center_custom_css');

function prime_spa_center_enqueue_google_fontss() {
    $prime_spa_center_heading_font_family = get_theme_mod('prime_spa_center_heading_font_family', '');
    $prime_spa_center_body_font_family = get_theme_mod('prime_spa_center_body_font_family', '');

    // Google Fonts URL builder
    $google_fonts = array(
        'arial'          => '',
        'verdana'        => '',
        'helvetica'      => '',
        'times-new-roman'=> '',
        'georgia'        => '',
        'courier-new'    => '',
        'trebuchet-ms'   => '',
        'tahoma'         => '',
        'palatino'       => '',
        'garamond'       => '',
        'impact'         => '',
        'comic-sans-ms'  => '',
        'lucida-sans'    => '',
        'arial-black'    => '',
        'gill-sans'      => '',
        'segoe-ui'       => '',
        'open-sans'      => 'Open+Sans:wght@400;700',
        'roboto'         => 'Roboto:wght@400;700',
        'lato'           => 'Lato:wght@400;700',
        'montserrat'     => 'Montserrat:wght@400;700',
        'libre-baskerville' => 'Libre+Baskerville:wght@400;700'
    );

    $prime_spa_center_google_fonts_url = '';

    if (!empty($google_fonts[$prime_spa_center_heading_font_family]) || !empty($google_fonts[$prime_spa_center_body_font_family])) {
        $fonts = array();

        if (!empty($google_fonts[$prime_spa_center_heading_font_family])) {
            $fonts[] = $google_fonts[$prime_spa_center_heading_font_family];
        }

        if (!empty($google_fonts[$prime_spa_center_body_font_family])) {
            $fonts[] = $google_fonts[$prime_spa_center_body_font_family];
        }

        // Build Google Fonts URL
        $prime_spa_center_google_fonts_url = add_query_arg(
            'family',
            implode('|', $fonts),
            'https://fonts.googleapis.com/css2'
        );
    }

    if ($prime_spa_center_google_fonts_url) {
        wp_enqueue_style('prime-spa-center-google-fonts', $prime_spa_center_google_fonts_url, false);
    }
}
add_action('wp_enqueue_scripts', 'prime_spa_center_enqueue_google_fontss');


function prime_spa_center_apply_typography() {
    $prime_spa_center_heading_font_family = get_theme_mod('prime_spa_center_heading_font_family');
    $prime_spa_center_body_font_family = get_theme_mod('prime_spa_center_body_font_family');

    $prime_spa_center_custom_css = '';

    if ($prime_spa_center_body_font_family) {
        $prime_spa_center_custom_css .= "body, a, a:active, a:hover { font-family: " . esc_html($prime_spa_center_body_font_family) . " !important; }";
    }

    if ($prime_spa_center_heading_font_family) {
        $prime_spa_center_custom_css .= "h1, h2, h3, h4, h5, h6 { font-family: " . esc_html($prime_spa_center_heading_font_family) . " !important; }";
    }

    if (!empty($prime_spa_center_custom_css)) {
        wp_add_inline_style('prime-spa-center-style', $prime_spa_center_custom_css);
    }
}
add_action('wp_enqueue_scripts', 'prime_spa_center_apply_typography');