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

if ( ! defined( 'INFLUENCER_AGENCY_VERSION' ) ) {
	// Replace the version number of the theme on each release.
	define( 'INFLUENCER_AGENCY_VERSION', wp_get_theme()->get( 'Version' ) );
}

if ( ! function_exists( 'influencer_agency_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 influencer_agency_setup() {

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

		add_theme_support( 'align-wide' );

		add_theme_support( 'woocommerce' );

		// Add support for block styles.
		add_theme_support( 'wp-block-styles' );

		// Enqueue editor styles.
		//add_editor_style( 'style.css' );

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

		// Experimental support for adding blocks inside nav menus
		add_theme_support( 'block-nav-menus' );

		// Add support for experimental link color control.
		add_theme_support( 'experimental-link-color' );

		// Register nav menus.
		register_nav_menus(
			array(
				'primary' => __( 'Primary Navigation', 'influencer-agency' ),
			)
		);

		// Theme Activation Notice
		global $pagenow;

		if (
		is_admin()
		&&
		('themes.php' == $pagenow)
		// &&
		// isset( $_GET['activated'] )
	) {
		add_action('admin_notices', 'influencer_agency_activation_notice');
	}
}
endif;
add_action( 'after_setup_theme', 'influencer_agency_setup' );

// Notice after Theme Activation
add_action('admin_notices', 'influencer_agency_activation_notice');

function influencer_agency_activation_notice() {
   
    if ( get_option('influencer_agency_admin_notice') == 1 ) {
        return;
    }

    // FIXED slug
    if ( isset($_GET['page']) && $_GET['page'] === 'influencer-agency-info' ) {
        return;
    }
	echo '<div id="influencer-agency-welcome-notice" class="notice is-dismissible influencer-agency-notice welcome-notice">';
		echo '<div class="influencer-agency-banner">';
			echo '<div class="influencer-agency-text">';
				echo '<h2>' . esc_html__( 'Thanks For Installing the "Influencer Agency Theme"!', 'influencer-agency' ) . '</h2>';
				echo '<p>' . esc_html__( 'We’re excited to help you get started with your new theme! Set up your website quickly and easily by importing our demo content and customizing it to suit your needs.', 'influencer-agency' ) . '</p>';
				echo '<div class="influencer-agency-buttons">';
					echo '<a href="' . esc_url( admin_url( 'themes.php?page=influencer-agency-info' ) ) . '">' . esc_html__( 'Get Started', 'influencer-agency' ) . '</a>';
					echo '<a href="'. esc_url( 'https://preview.themescaliber.com/doc/free-influencer-agency/' ) .'" target=_blank>' . esc_html__( 'Documentation', 'influencer-agency' ) . '</a>';
					echo '<a href="'. esc_url( 'https://www.themescaliber.com/products/influencer-agency-wordpress-theme' ) .'" target=_blank>' . esc_html__( 'Get Premium', 'influencer-agency' ) . '</a>';
					echo '<a href="'. esc_url( 'https://www.themescaliber.com/products/wordpress-theme-bundle' ) .'" target=_blank class="bundle-btn">' . esc_html__( 'Bundle Of 220+ Themes at $99', 'influencer-agency' ) . '</a>';
				echo '</div>';
			echo '</div>';
			echo '<div class="influencer-agency-image">';
				echo '<img src="' . esc_url(get_template_directory_uri()) . '/images/bundle-notice.png">';
			echo '</div>';
		echo '</div>';
    echo '</div>';
}
    //Hook (VERY IMPORTANT)
	add_action('admin_notices', 'influencer_agency_activation_notice');


/**
 * Theme Fonts.
 *
 * @return array
 */
function influencer_agency_theme_font_families() {
    return array_filter( array( 'Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900', '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', 'Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900', 'Outfit:wght@100;200;300;400;500;600;700;800;900', 'Inter:wght@100;200;300;400;500;600;700;800;900', 'Jost:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900', 'Oswald:wght@200;300;400;500;600;700',
    'Raleway:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900',
    'Spartan:wght@100;200;300;400;500;600;700;800;900' ) );
}

if ( ! function_exists( 'influencer_agency_fonts_url' ) ) :
    /**
     * Register Google fonts for Influencer Agency
     *
     * Create your own influencer_agency_fonts_url() function to override in a child theme.
     *
     * @since 1.0
     *
     * @return string Google fonts URL for the theme.
     */
    function influencer_agency_fonts_url() {
        $fonts_url = '';

        /* Translators: If there are characters in your language that are not
        * supported by Poppins, translate this to 'off'. Do not translate
        * into your own language.
        */
        $font_families = influencer_agency_theme_font_families();

        if ( ! empty( $font_families ) ) {

            $query_args = array(
                'family' => implode( '&family=', $font_families ), //urlencode( implode( '|', $font_families ) ),
                // 'subset' => urlencode( 'latin,latin-ext' ),
                'display' => 'swap',
            );

            $fonts_url = add_query_arg( $query_args, 'https://fonts.googleapis.com/css2' );
        }

        if ( ! class_exists( 'WPTT_WebFont_Loader' ) ) {
            // Load Google fonts from Local.
            require_once get_theme_file_path( 'inc/wptt-webfont-loader.php' );
        }

        return esc_url( wptt_get_webfont_url( $fonts_url ) );
    }
endif;


/**
 * Enqueue scripts and styles.
 */
function influencer_agency_scripts() {
	wp_enqueue_style('influencer-agency-font', influencer_agency_fonts_url(), array());
	wp_enqueue_style('influencer-agency-style', get_stylesheet_uri(), array() );
	wp_enqueue_script( 'jquery-wow', esc_url(get_template_directory_uri()) . '/js/wow.js', array('jquery') );
	wp_enqueue_style( 'animate-css', esc_url(get_template_directory_uri()).'/css/animate.css' );
	wp_enqueue_script( 'influencer-agency-custom-scripts', get_template_directory_uri() . '/js/custom.js', array('jquery'),'' ,true );
	$font_families = influencer_agency_theme_font_families();
    if ( ! empty( $font_families ) ) {
        wp_enqueue_style( 'influencer-agency-fonts', influencer_agency_fonts_url(), array(), null );
    }
    wp_style_add_data( 'influencer-agency-style', 'rtl', 'replace' );
}
add_action( 'wp_enqueue_scripts', 'influencer_agency_scripts' );


add_action( 'admin_enqueue_scripts', function( $hook ) {
  // if ( 'user-edit.php' == $hook ) {
    wp_enqueue_script(
      'influencer_agency',get_template_directory_uri() . '/js/custom-admin.js',array('jquery'),'',true);
  // }
} );

/**
 * Enqueue block editor style
 */
function influencer_agency_block_editor_styles() {
	wp_enqueue_style( 'influencer-agency-block-patterns-style-editor', get_theme_file_uri( '/css/block-editor.css' ), false, '1.0', 'all' );
	wp_enqueue_style('influencer-agency-font', influencer_agency_fonts_url(), array());
}
add_action( 'enqueue_block_editor_assets', 'influencer_agency_block_editor_styles' );


function influencer_agency_init_setup() {
	define('INFLUENCER_AGENCY_BUY_NOW',__('https://www.themescaliber.com/products/influencer-agency-wordpress-theme','influencer-agency'));
	define('INFLUENCER_AGENCY_SUPPORT',__('https://wordpress.org/support/theme/influencer-agency/','influencer-agency'));
	define('INFLUENCER_AGENCY_REVIEW',__('https://wordpress.org/support/theme/influencer-agency/reviews/','influencer-agency'));
	define('INFLUENCER_AGENCY_LIVE_DEMO',__('https://preview.themescaliber.com/tc-inluencer-agency-pro/','influencer-agency'));
	define('INFLUENCER_AGENCY_PRO_DOC',__('https://preview.themescaliber.com/doc/influencer-agency-pro/','influencer-agency'));
	define('INFLUENCER_AGENCY_FREE_DOC',__('https://preview.themescaliber.com/doc/free-influencer-agency/','influencer-agency'));
	define('INFLUENCER_AGENCY_FAQ',__('https://www.vwthemes.com/faqs/','influencer-agency'));
	define('INFLUENCER_AGENCY_CHILD_THEME',__('https://developer.wordpress.org/themes/advanced-topics/child-themes/','influencer-agency'));
	define('INFLUENCER_AGENCY_CONTACT',__('https://www.vwthemes.com/contact/','influencer-agency'));
	define('INFLUENCER_AGENCY_THEME_BUNDLE_BUY_NOW',__('https://www.themescaliber.com/products/wordpress-theme-bundle','influencer-agency'));


	// Add block patterns
	require get_template_directory() . '/inc/block-patterns.php';

	/**
	 * Section Pro
	 */
	require get_template_directory() . '/inc/section-pro/customizer.php';


	/**
	 * Load core file.
	 */
	require_once get_template_directory() . '/inc/core/theme-info.php';
	require_once get_template_directory() . '/inc/core/template-functions.php';
}
add_action( 'after_setup_theme', 'influencer_agency_init_setup' );	

// Admin notice code START
add_action('wp_ajax_influencer_agency_dismiss_notice', 'influencer_agency_dismiss_notice');
function influencer_agency_dismiss_notice() {
    update_option('influencer_agency_admin_notice', 1);
    wp_die();
}

//After Switch theme function
add_action('after_switch_theme', 'influencer_agency_getstart_setup_options');
function influencer_agency_getstart_setup_options () {
    delete_option('influencer_agency_admin_notice');
}
// Admin notice code END

add_filter( 'woocommerce_enable_setup_wizard', '__return_false' );