<?php
/**
 * Shoe Outlet functions and definitions
 *
 * @package shoe_outlet
 * @since 1.0
 */

if ( ! function_exists( 'shoe_outlet_support' ) ) :
	function shoe_outlet_support() {

		load_theme_textdomain( 'shoe-outlet', get_template_directory() . '/languages' );

		add_theme_support( 'custom-background', apply_filters( 'shoe_outlet_custom_background', array(
            'default-color' => 'ffffff',
            'default-image' => '',
        )));

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

		add_theme_support('woocommerce');

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

		define('SHOE_OUTLET_FREE_BUY_NOW',__('https://www.themepixels.net/products/shoe-outlet/','shoe-outlet'));
		define('SHOE_OUTLET_BUY_NOW',__('https://www.themepixels.net/products/shoes-wordpress-theme/','shoe-outlet'));
		define('SHOE_OUTLET_LIVE_DEMO',__('https://themepixels.net/demo-site/shoe-outlet/','shoe-outlet'));
		define('SHOE_OUTLET_FREE_DOC',__('https://www.themepixels.net/docs/shoe-outlet-free/','shoe-outlet'));
		define('SHOE_OUTLET_BUNDLE',__('https://www.themepixels.net/products/wp-theme-bundle/','shoe-outlet'));
		define('SHOE_OUTLET_THEME_SUPPORT',__('https://wordpress.org/support/theme/shoe-outlet','shoe-outlet'));

    	require_once get_theme_file_path( '/inc/customizer.php' );
	}
endif;

add_action( 'after_setup_theme', 'shoe_outlet_support' );

if ( ! function_exists( 'shoe_outlet_styles' ) ) :
	function shoe_outlet_styles() {
		// Register theme stylesheet.
		$shoe_outlet_theme_version = wp_get_theme()->get( 'Version' );

		$shoe_outlet_version_string = is_string( $shoe_outlet_theme_version ) ? $shoe_outlet_theme_version : false;
		wp_enqueue_style(
			'shoe-outlet-style',
			get_template_directory_uri() . '/style.css',
			array(),
			$shoe_outlet_version_string
		);

		wp_style_add_data('shoe-outlet', 'rtl', 'replace');

		wp_enqueue_style( 'dashicons' );

		wp_enqueue_style( 'animate-css', esc_url(get_template_directory_uri()).'/assets/css/animate.css' );

		wp_enqueue_style( 'owl.carousel-css', esc_url(get_template_directory_uri()).'/assets/css/owl.carousel.css' );

		wp_enqueue_script( 'jquery-wow', esc_url(get_template_directory_uri()) . '/assets/js/wow.js', array('jquery') );
        
        wp_enqueue_style( 'shoe-outlet-fonts', get_template_directory_uri() . '/assets/css/fonts.css', array(), $shoe_outlet_version_string );
	    wp_enqueue_script( 'owl.carousel-js', get_template_directory_uri(). '/assets/js/owl.carousel.js', array('jquery') ,'',true);
	    
	    wp_enqueue_script( 'shoe-outlet-custom-scripts', get_template_directory_uri() . '/assets/js/custom-script.js', array('jquery'),'' ,true );

		 //font-awesome
		 wp_enqueue_style( 'fontawesome', get_template_directory_uri() . '/inc/fontawesome/css/all.css'
		 	, array(), '6.7.0' );
	}
endif;

add_action( 'wp_enqueue_scripts', 'shoe_outlet_styles' );

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

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

// Block Filters
require get_template_directory() . '/inc/block-filters.php';

// Svg icons
require get_template_directory() . '/inc/icon-function.php';

/**
* GET START.
*/
require get_template_directory() . '/themeinfo/shoe_outlet_themeinfo_page.php';

// TGM
require get_template_directory() . '/inc/TGM/tgm.php';

// NOTICE FUNCTION
function shoe_outlet_activation_notice() {
    if (get_option('shoe_outlet_notice_dismissed')) {
        return;
    }

    if (isset($_GET['page']) && $_GET['page'] === 'shoe-outlet-themeinfo-page') {
        return;
    }
    ?>
    <div class="updated notice notice-theme-info-class is-dismissible" data-notice="theme_info">
        <div class="shoe-outlet-theme-info-notice clearfix">
            <div class="shoe-outlet-theme-notice-content">
				<div class="notice-content">
					<div class="inner-notice-contetn">
						<h2 class="shoe-outlet-notice-h2">
							<?php
							printf(
								/* translators: 1: Theme name */
								esc_html__('Hello! Thank you for choosing our %1$s!', 'shoe-outlet'), '<strong>' . esc_html(wp_get_theme()->get('Name')) . '</strong>'
							);
							?>
						</h2>

						<p class="shoe-outlet-notice-p">
							<?php
							printf(
								/* translators: 1: Theme name */
								esc_html__('%1$s has been successfully installed and is ready for use. The links below will help you get started.', 'shoe-outlet'), '<strong>' . esc_html(wp_get_theme()->get('Name')) . '</strong>'
							);
							?>
						</p>
					</div>
					<div class="inner-notice-buttons">
						<a class="shoe-outlet-btn-theme-info button button-primary" target="_blank" href="<?php echo esc_url(admin_url('themes.php?page=shoe-outlet-themeinfo-page')); ?>" id="shoe-outlet-themeinfo-button"> <?php esc_html_e('Shoe Outlet Theme Information', 'shoe-outlet') ?></a>
						
						<a class="shoe-outlet-btn-theme-info button button-primary buy-noww" target="_blank" href="<?php echo esc_url(SHOE_OUTLET_BUY_NOW); ?>" id="shoe-outlet-bundle-button"> <?php esc_html_e('Buy Now', 'shoe-outlet') ?></a>
						<a class="shoe-outlet-btn-theme-info button button-primary bundlee" target="_blank" href="<?php echo esc_url(SHOE_OUTLET_BUNDLE); ?>" id="shoe-outlet-bundle-button"> <?php esc_html_e('Get All Themes', 'shoe-outlet') ?></a>
						<a class="shoe-outlet-btn-theme-info button button-primary live-demoo" target="_blank" href="<?php echo esc_url(SHOE_OUTLET_LIVE_DEMO); ?>" id="shoe-outlet-bundle-button"> <?php esc_html_e('Live Demo', 'shoe-outlet') ?></a>
					</div>
				</div>
				<div class="notice-image">
					<img src="<?php echo esc_url( get_stylesheet_directory_uri() . '/assets/images/bundle-img.png' ); ?>" alt="<?php esc_attr_e( 'Theme Screenshot', 'shoe-outlet' ); ?>">
				</div>
            </div>
        </div>
    </div>
    <?php
}

add_action('admin_notices', 'shoe_outlet_activation_notice');

add_action('wp_ajax_shoe_outlet_dismiss_notice', 'shoe_outlet_dismiss_notice');

function shoe_outlet_notice_status() {
    delete_option('shoe_outlet_notice_dismissed');
}
add_action('after_switch_theme', 'shoe_outlet_notice_status');

function shoe_outlet_dismiss_notice() {
    update_option('shoe_outlet_notice_dismissed', true);
    wp_send_json_success();
}

function shoe_outlet_admin_enqueue_scripts(){
	wp_enqueue_style('shoe-outlet-admin-style', esc_url( get_template_directory_uri() ) . '/assets/css/shoe-outlet-notice.css');
	wp_enqueue_script('shoe-outlet-dismiss-notice-script', get_stylesheet_directory_uri() . '/assets/js/shoe-outlet-notice.js', array('jquery'), null, true);
}
add_action( 'admin_enqueue_scripts', 'shoe_outlet_admin_enqueue_scripts' );