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

if ( ! defined( 'PRIME_INTERIOR_DESIGNER_URL' ) ) {
    define( 'PRIME_INTERIOR_DESIGNER_URL', esc_url( 'https://www.themeignite.com/products/interior-designer-wordpress-theme', 'prime-interior-designer') );
}
if ( ! defined( 'PRIME_INTERIOR_DESIGNER_FREE_DOC_URL' ) ) {
    define( 'PRIME_INTERIOR_DESIGNER_FREE_DOC_URL', esc_url( 'https://demo.themeignite.com/documentation/prime-interior-designer-free', 'prime-interior-designer') );
}
if ( ! defined( 'PRIME_INTERIOR_DESIGNER_PRO_DOC_URL' ) ) {
    define( 'PRIME_INTERIOR_DESIGNER_PRO_DOC_URL', esc_url( 'https://demo.themeignite.com/documentation/prime-interior-designer-pro/', 'prime-interior-designer') );
}
if ( ! defined( 'PRIME_INTERIOR_DESIGNER_DEMO_URL' ) ) {
    define( 'PRIME_INTERIOR_DESIGNER_DEMO_URL', esc_url( 'https://demo.themeignite.com/prime-interior-designer/', 'prime-interior-designer') );
}
if ( ! defined( 'PRIME_INTERIOR_DESIGNER_REVIEW_URL' ) ) {
    define( 'PRIME_INTERIOR_DESIGNER_REVIEW_URL', esc_url( 'https://wordpress.org/support/theme/prime-interior-designer/reviews/#new-post', 'prime-interior-designer') );
}
if ( ! defined( 'PRIME_INTERIOR_DESIGNER_SUPPORT_URL' ) ) {
    define( 'PRIME_INTERIOR_DESIGNER_SUPPORT_URL', esc_url( 'https://wordpress.org/support/theme/prime-interior-designer', 'prime-interior-designer') );
}
if ( ! defined( 'PRIME_INTERIOR_DESIGNER_BUNDLE_URL' ) ) {
    define( 'PRIME_INTERIOR_DESIGNER_BUNDLE_URL', esc_url( 'https://www.themeignite.com/products/wp-theme-bundle', 'prime-interior-designer') );
}

$prime_interior_designer_theme_data = wp_get_theme();
if( ! defined( 'PRIME_INTERIOR_DESIGNER_THEME_VERSION' ) ) define ( 'PRIME_INTERIOR_DESIGNER_THEME_VERSION', $prime_interior_designer_theme_data->get( 'Version' ) );
if( ! defined( 'PRIME_INTERIOR_DESIGNER_THEME_NAME' ) ) define( 'PRIME_INTERIOR_DESIGNER_THEME_NAME', $prime_interior_designer_theme_data->get( 'Name' ) );
if( ! defined( 'PRIME_INTERIOR_DESIGNER_THEME_TEXTDOMAIN' ) ) define( 'PRIME_INTERIOR_DESIGNER_THEME_TEXTDOMAIN', $prime_interior_designer_theme_data->get( 'TextDomain' ) );

if ( ! function_exists( 'prime_interior_designer_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_interior_designer_setup() {
	/*
	 * Make theme available for translation.
	 * Translations can be filed in the /languages/ directory.
	 * If you're building a theme based on Prime Interior Designer, use a find and replace
	 * to change 'prime-interior-designer' to the name of your theme in all the template files.
	 */
	load_theme_textdomain( 'prime-interior-designer', 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-interior-designer' ),
	) );

	// 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_interior_designer_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_interior_designer_fonts_url() ) );

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

	add_theme_support( 'align-wide' );
	add_theme_support( 'editor-font-sizes', array(
	   	array(
	       	'name' => esc_html__( 'small', 'prime-interior-designer' ),
	       	'shortName' => esc_html__( 'S', 'prime-interior-designer' ),
	       	'size' => 12,
	       	'slug' => 'small'
	   	),
	   	array(
	       	'name' => esc_html__( 'regular', 'prime-interior-designer' ),
	       	'shortName' => esc_html__( 'M', 'prime-interior-designer' ),
	       	'size' => 16,
	       	'slug' => 'regular'
	   	),
	   	array(
	       	'name' => esc_html__( 'larger', 'prime-interior-designer' ),
	       	'shortName' => esc_html__( 'L', 'prime-interior-designer' ),
	       	'size' => 36,
	       	'slug' => 'larger'
	   	),
	   	array(
	       	'name' => esc_html__( 'huge', 'prime-interior-designer' ),
	       	'shortName' => esc_html__( 'XL', 'prime-interior-designer' ),
	       	'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_interior_designer_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_interior_designer_content_width() {
	$GLOBALS['content_width'] = apply_filters( 'prime_interior_designer_content_width', 640 );
}
add_action( 'after_setup_theme', 'prime_interior_designer_content_width', 0 );

/**
 * Register widget area.
 *
 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
 */
function prime_interior_designer_widgets_init() {
	register_sidebar( array(
		'name'          => esc_html__( 'Sidebar Option', 'prime-interior-designer' ),
		'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-interior-designer' ),
		'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-interior-designer' ),
		'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-interior-designer' ),
		'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-interior-designer' ),
		'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-interior-designer' ),
		'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-interior-designer' ),
		'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_interior_designer_widgets_init' );

/**
 * Register custom fonts.
 */
function prime_interior_designer_fonts_url() {
	$font_family   = array(
		'Playfair Display:ital,wght@0,400;0,500;0,600;0,700;0,800;0,900;1,400;1,500;1,600;1,700;1,800;1,900',
		'Sofia Sans:ital,wght@0,1;0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;0,1000;1,1;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900;1,1000'
	);
	
	$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_interior_designer_scripts() {
	$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
	$fonts_url = prime_interior_designer_fonts_url();
	$primary_color = prime_interior_designer_get_option( 'primary_color' );
	if ( ! empty( $fonts_url ) ) {
		wp_enqueue_style( 'prime-interior-designer-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( 'owl.carousel-style', get_template_directory_uri().'/assets/css/owl.carousel.css' );

	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-interior-designer-blocks', get_template_directory_uri() . '/assets/css/blocks' . $min . '.css' );
	
	wp_enqueue_style( 'prime-interior-designer-style', get_stylesheet_uri() );

	wp_style_add_data('prime-interior-designer-style', 'rtl', 'replace');

	require get_parent_theme_file_path( '/inc/css_custom.php' );
	wp_add_inline_style( 'prime-interior-designer-style',$prime_interior_designer_custom_css );
	
	wp_enqueue_script( 'jquery-slick', get_template_directory_uri() . '/assets/js/slick' . $min . '.js', array('jquery'), '2017417', true );
	
	wp_enqueue_script( 'prime-interior-designer-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( 'owl.carousel-js', get_template_directory_uri(). '/assets/js/owl.carousel.js', array('jquery') ,'',true);

	wp_enqueue_script( 'prime-interior-designer-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_interior_designer_scripts' );

if( ! function_exists( 'prime_interior_designer_admin_scripts' ) ) :
/**
 * Addmin scripts
*/
function prime_interior_designer_admin_scripts() {
	wp_enqueue_style( 'prime-interior-designer-admin-style',get_template_directory_uri().'/assets/css/admin.css', PRIME_INTERIOR_DESIGNER_THEME_VERSION, 'screen' );
}
endif;
add_action( 'admin_enqueue_scripts', 'prime_interior_designer_admin_scripts' );

/**
 * Enqueue editor styles for Gutenberg
 *
 * @since Prime Interior Designer 1.0.0
 */
function prime_interior_designer_block_editor_styles() {
	$min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
	// Block styles.
	wp_enqueue_style( 'prime-interior-designer-block-editor-style', get_theme_file_uri( '/assets/css/editor-blocks' . $min . '.css' ) );
	// Add custom fonts.
	wp_enqueue_style( 'prime-interior-designer-fonts', prime_interior_designer_fonts_url(), array(), null );
}
add_action( 'enqueue_block_editor_assets', 'prime_interior_designer_block_editor_styles' );

// Change number or products per row to 3
add_filter('loop_shop_columns', 'prime_interior_designer_loop_columns');
	if (!function_exists('prime_interior_designer_loop_columns')) {
		function prime_interior_designer_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_interior_designer_products_per_page' );
function prime_interior_designer_products_per_page( $cols ) {
  	return  9;
}

/**
 * AJAX handler to dismiss Whizzie notice
 */
if ( ! function_exists( 'prime_interior_designer_dismiss_whizzie_notice' ) ) {
    function prime_interior_designer_dismiss_whizzie_notice() {

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

        wp_die();
    }
}
add_action(
    'wp_ajax_prime_interior_designer_dismiss_whizzie_notice',
    'prime_interior_designer_dismiss_whizzie_notice'
);


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

        return (bool) get_user_meta(
            get_current_user_id(),
            'prime_interior_designer_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_interior_designer_whizzie_dismissed' );
    }

});

/**
 * Display the admin notice unless dismissed.
 */
function prime_interior_designer_dashboard_notice() {
    // Check if the notice is dismissed
    $dismissed = get_user_meta( get_current_user_id(), 'prime_interior_designer_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-interior-designer' ),
                            '<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-interior-designer' ); ?></p>
                    <div class="notice-btns">
                        <a class="button button-primary getstart"
                           href="<?php echo esc_url( admin_url( 'themes.php?page=prime-interior-designer' ) ); ?>">
                           <?php esc_html_e( 'Getting Started', 'prime-interior-designer' ); ?>
                        </a>                         
                        <a class="button button-primary premium"
                           target="_blank" href="<?php echo esc_url( 'https://www.themeignite.com/products/interior-designer-wordpress-theme' ); ?>">
                           <?php esc_html_e( 'Go To Premium', 'prime-interior-designer' ); ?>
                        </a>
						<a class="button button-primary demo" target="_blank" href="<?php echo esc_url(PRIME_INTERIOR_DESIGNER_DEMO_URL); ?>"><?php esc_html_e('View Demo', 'prime-interior-designer') ?></a>
                    </div>
                </div>
				<div class="notice-img">
                    <a href="<?php echo esc_url( PRIME_INTERIOR_DESIGNER_BUNDLE_URL ); ?>" target="_blank"><img src="<?php echo esc_url( get_template_directory_uri() . '/assets/images/notice.png' ); ?>"></a>
                </div> 
            </div>
        </div>
        <?php
    }
}

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

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

// Hook for the AJAX action
add_action('wp_ajax_prime_interior_designer_dismissable_notice', 'prime_interior_designer_dismissable_notice');

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

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

function prime_interior_designer_template_setup() {

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

/**
 * Pro Link.
 */
require_once get_template_directory() . '/inc/premium-link/class-button-link.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';

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

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

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

/**
 * 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_interior_designer_get_option( 'prime_interior_designer_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_interior_designer_get_option( 'prime_interior_designer_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');


function prime_interior_designer_enqueue_google_fontss() {
    $prime_interior_designer_heading_font_family = get_theme_mod('prime_interior_designer_heading_font_family', '');
    $prime_interior_designer_body_font_family = get_theme_mod('prime_interior_designer_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_interior_designer_google_fonts_url = '';

    if (!empty($google_fonts[$prime_interior_designer_heading_font_family]) || !empty($google_fonts[$prime_interior_designer_body_font_family])) {
        $fonts = array();

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

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

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

    if ($prime_interior_designer_google_fonts_url) {
        wp_enqueue_style('prime-interior-designer-google-fonts', $prime_interior_designer_google_fonts_url, false);
    }
}
add_action('wp_enqueue_scripts', 'prime_interior_designer_enqueue_google_fontss');


function prime_interior_designer_apply_typography() {
    $prime_interior_designer_heading_font_family = get_theme_mod('prime_interior_designer_heading_font_family');
    $prime_interior_designer_body_font_family = get_theme_mod('prime_interior_designer_body_font_family');

    $prime_interior_designer_custom_css = '';

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

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

    if (!empty($prime_interior_designer_custom_css)) {
        wp_add_inline_style('prime-interior-designer-style', $prime_interior_designer_custom_css);
    }
}
add_action('wp_enqueue_scripts', 'prime_interior_designer_apply_typography');