<?php
/**
 * Wall Decor Wallpaper functions and definitions
 *
 * @package Wall Decor Wallpaper
 */ 
/* Breadcrumb Begin */
function wall_decor_wallpaper_the_breadcrumb() {
	if (!is_home()) {
		echo '<a href="';
			echo esc_url( home_url() );
		echo '">';
			bloginfo('name');
		echo "</a> ";
		if (is_category() || is_single()) {
			the_category(',');
			if (is_single()) {
				echo "<span> ";
					the_title();
				echo "</span> ";
			}
		} elseif (is_page()) {
			echo "<span> ";
				the_title();
		}
	} 
}
/* Theme Setup */
if ( ! function_exists( 'wall_decor_wallpaper_setup' ) ) :
 
function wall_decor_wallpaper_setup() {

	$GLOBALS['content_width'] = apply_filters( 'wall_decor_wallpaper_content_width', 640 );

	load_theme_textdomain( 'wall-decor-wallpaper', get_template_directory() . '/languages' );
	
	add_theme_support( 'automatic-feed-links' );
	add_theme_support( 'woocommerce' );
	add_theme_support( 'wc-product-gallery-zoom' );
	add_theme_support( 'wc-product-gallery-slider' );
	add_theme_support( 'wc-product-gallery-lightbox' );
	add_theme_support( 'post-thumbnails' );
	add_theme_support( 'title-tag' );
	add_theme_support( 'align-wide' );
	add_theme_support( 'wp-block-styles' );
	add_theme_support( 'responsive-embeds' );
	add_theme_support( 'html5', array( 'comment-list', 'search-form', 'comment-form', ) );
	add_theme_support( 'custom-logo', array(
		'height'      => 240,
		'width'       => 240,
		'flex-height' => true,
	) );
	add_image_size('wall-decor-wallpaper-homepage-thumb',240,145,true);
	
    register_nav_menus( array(
		'primary' => __( 'Primary Menu', 'wall-decor-wallpaper' ),
	) );

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

	//selective refresh for sidebar and widgets
	add_theme_support( 'customize-selective-refresh-widgets' );

	/*
	 * Enable support for Post Formats.
	 *
	 * See: https://codex.wordpress.org/Post_Formats
	 */
	add_theme_support( 'post-formats', array('image','video','gallery','audio',) );

	/*
	 * This theme styles the visual editor to resemble the theme style,
	 * specifically font, colors, icons, and column width.
	 */
	add_editor_style( array( 'css/editor-style.css', wall_decor_wallpaper_font_url() ) );

	// Theme Activation Notice
	global $pagenow;

	if ( is_admin() && $pagenow === 'themes.php' && (!isset($_GET['page']) || $_GET['page'] !== 'wall_decor_wallpaper_guide')
) {
		add_action('admin_notices', 'wall_decor_wallpaper_activation_notice');
	}
}
endif;

add_action( 'after_setup_theme', 'wall_decor_wallpaper_setup' );

// Notice after Theme Activation

function wall_decor_wallpaper_activation_notice() {

	$meta = get_option( 'wall_decor_wallpaper_admin_notice' );

	if (!$meta) {
		echo '<div id="wall-decor-wallpaper-welcome-notice" class="notice notice-success is-dismissible welcome-notice">';
		echo '<div class="notice-row">';
			echo '<div class="notice-img2">';
				echo '<img src="' . esc_url( get_template_directory_uri() . '/screenshot.png' ) . '" width="180" alt="' . esc_attr__( 'Wall Decor Wallpaper', 'wall-decor-wallpaper' ) . '" />';
			echo '</div>';	

			echo '<div class="notice-text">';
				echo '<p class="welcome-text1">'. esc_html__( 'Thanks For Installing Wall Decor Wallpaper, You Rock !', 'wall-decor-wallpaper' ) .'</p>';
				echo '<p class="welcome-text3">'. esc_html__( 'Take benefit of a variety of features, functionalities, elements, and an exclusive set of customization options to build your own professional charity website. Please Click on the link below to know the theme setup information.', 'wall-decor-wallpaper' ) .'</p>';
				echo '<span class="import-btn"><a href="'. esc_url( admin_url( 'themes.php?page=wall_decor_wallpaper_guide' ) ) .'" class="button button-primary">'. esc_html__( 'Import Demo', 'wall-decor-wallpaper' ) .'</a></span>';
				echo '<span class="demo-btn"><a href="'. esc_url( 'https://demos.buywptemplates.com/wall-decor-wallpaper' ) .'" class="button button-primary" target=_blank>'. esc_html__( 'Pro Demo', 'wall-decor-wallpaper' ) .'</a></span>';
				
				echo '<span class="bundle-btn"><a href="'. esc_url( 'https://demos.buywptemplates.com/demo/docs/free-wall-decor-wallpaper/' ) .'" class="button button-primary" target=_blank>'. esc_html__( 'Free Doc', 'wall-decor-wallpaper' ) .'</a></span>';
				echo '<span class="upgrade-btn"><a href="'. esc_url( 'http://buywptemplates.com/products/wall-decor-wordpress-theme' ) .'" class="button button-primary" target=_blank>'. esc_html__( 'Upgrade To Pro', 'wall-decor-wallpaper' ) .'</a></span>';
			echo '</div>';	
		echo '</div>';	
	echo '</div>';
}
}

/* Theme Widgets Setup */
function wall_decor_wallpaper_widgets_init() {
	register_sidebar( array(
		'name'          => __( 'Blog Sidebar', 'wall-decor-wallpaper' ),
		'description'   => __( 'Appears on blog page sidebar', 'wall-decor-wallpaper' ),
		'id'            => 'sidebar-1',
		'before_widget' => '<aside id="%1$s" class="widget mb-5 p-3 %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title py-2 px-3">',
		'after_title'   => '</h3>',
	) );
	
	register_sidebar( array(
		'name'          => __( 'Page Sidebar', 'wall-decor-wallpaper' ),
		'description'   => __( 'Appears on page sidebar', 'wall-decor-wallpaper' ),
		'id'            => 'sidebar-2',
		'before_widget' => '<aside id="%1$s" class="widget mb-5 p-3 %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title py-2 px-3">',
		'after_title'   => '</h3>',
	) );

	register_sidebar( array(
		'name'          => __( 'Footer Navigation 1', 'wall-decor-wallpaper' ),
		'description'   => __( 'Appears on footer 1', 'wall-decor-wallpaper' ),
		'id'            => 'footer-1',
		'before_widget' => '<aside id="%1$s" class="widget py-3 %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title px-0 py-2">',
		'after_title'   => '</h3>',
	) );

	register_sidebar( array(
		'name'          => __( 'Footer Navigation 2', 'wall-decor-wallpaper' ),
		'description'   => __( 'Appears on footer 2', 'wall-decor-wallpaper' ),
		'id'            => 'footer-2',
		'before_widget' => '<aside id="%1$s" class="widget py-3 %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title px-0 py-2">',
		'after_title'   => '</h3>',
	) );

	register_sidebar( array(
		'name'          => __( 'Footer Navigation 3', 'wall-decor-wallpaper' ),
		'description'   => __( 'Appears on footer 3', 'wall-decor-wallpaper' ),
		'id'            => 'footer-3',
		'before_widget' => '<aside id="%1$s" class="widget py-3 %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title px-0 py-2">',
		'after_title'   => '</h3>',
	) );

	register_sidebar( array(
		'name'          => __( 'Footer Navigation 4', 'wall-decor-wallpaper' ),
		'description'   => __( 'Appears on footer 4', 'wall-decor-wallpaper' ),
		'id'            => 'footer-4',
		'before_widget' => '<aside id="%1$s" class="widget py-3 %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title px-0 py-2">',
		'after_title'   => '</h3>',
	) );

	register_sidebar( array(
		'name'          => __( 'Shop Page Sidebar', 'wall-decor-wallpaper' ),
		'description'   => __( 'Appears on shop page', 'wall-decor-wallpaper' ),
		'id'            => 'woocommerce-shop-sidebar',
		'before_widget' => '<aside id="%1$s" class="widget mb-5 p-3 %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title px-3 py-2">',
		'after_title'   => '</h3>',
	) );

	register_sidebar( array(
		'name'          => __( 'Single Product Sidebar', 'wall-decor-wallpaper' ),
		'description'   => __( 'Appears on single product page', 'wall-decor-wallpaper' ),
		'id'            => 'woocommerce-single-sidebar',
		'before_widget' => '<aside id="%1$s" class="widget mb-5 p-3 %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title px-3 py-2">',
		'after_title'   => '</h3>',
	) );

	register_sidebar( array(
		'name'          => __( 'Slider Social Icons', 'wall-decor-wallpaper' ),
		'description'   => __( 'Appears on slider', 'wall-decor-wallpaper' ),
		'id'            => 'social-links',
		'before_widget' => '<aside id="%1$s" class="widget %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );

	register_sidebar( array(
		'name'          => __( 'Footer Social Icon', 'wall-decor-wallpaper' ),
		'description'   => __( 'Appears on right side footer', 'wall-decor-wallpaper' ),
		'id'            => 'footer-icon',
		'before_widget' => '<aside id="%1$s" class="widget mb-5 p-3 %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title px-3 py-2">',
		'after_title'   => '</h3>',
	) );

	register_sidebar( array(
		'name'          => __( 'Sidebar 3', 'wall-decor-wallpaper' ),
		'description'   => __( 'Appears on page sidebar', 'wall-decor-wallpaper' ),
		'id'            => 'sidebar-3',
		'before_widget' => '<aside id="%1$s" class="widget mb-5 p-3 %2$s">',
		'after_widget'  => '</aside>',
		'before_title'  => '<h3 class="widget-title px-3 py-2">',
		'after_title'   => '</h3>',
	) );
}
add_action( 'widgets_init', 'wall_decor_wallpaper_widgets_init' );

/* Theme Font URL */
function wall_decor_wallpaper_font_url() {
	$font_family   = array(
		'ABeeZee:ital@0;1',
		'Abril Fatfac',
		'Acme',
		'Allura',
		'Amatic SC:wght@400;700',
		'Anton',
		'Architects Daughter',
		'Archivo: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',
		'Arimo:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700',
		'Arsenal:ital,wght@0,400;0,700;1,400;1,700',
		'Arvo:ital,wght@0,400;0,700;1,400;1,700',
		'Alegreya: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',
		'Asap: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',
		'Assistant:wght@200;300;400;500;600;700;800',
		'Alfa Slab One',
		'Averia Serif Libre:ital,wght@0,300;0,400;0,700;1,300;1,400;1,700',
		'Bangers',
		'Boogaloo',
		'Bad Script',
		'Barlow: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',
		'Barlow Condensed: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',
		'Berkshire Swash',
		'Bitter: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',
		'Bree Serif',
		'BenchNine:wght@300;400;700',
		'Cabin:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700',
		'Courgette',
		'Caveat:wght@400;500;600;700',
		'Caveat Brush',
		'Cherry Swash:wght@400;700',
		'Cormorant Garamond:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700',
		'Crimson Text:ital,wght@0,400;0,600;0,700;1,400;1,600;1,700',
		'Cuprum:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700',
		'Cookie',
		'Coming Soon',
		'Charm:wght@400;700',
		'Chewy',
		'Cardo:ital,wght@0,400;0,700;1,400',
		'Figtree:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,300;1,400;1,500;1,600;1,700;1,800;1,900'
	);

	$query_args = array(
		'family'	=> rawurlencode(implode('|',$font_family)),
	);
	$font_url = add_query_arg($query_args,'//fonts.googleapis.com/css');
	return $font_url;
	$contents = wall_decor_wallpaper_wptt_get_webfont_url( esc_url_raw( $fonts_url ) );
}

/**
 * Enqueue block editor style
 */
function wall_decor_wallpaper_block_editor_styles() {
	wp_enqueue_style( 'wall-decor-wallpaper-font', wall_decor_wallpaper_font_url(), array() );
	wp_enqueue_style( 'wall-decor-wallpaper-block-patterns-style-editor', get_theme_file_uri( '/inc/block-patterns/css/block-editor.css' ), false, '1.0', 'all' );
    wp_enqueue_style( 'bootstrap-style', get_template_directory_uri().'/assets/css/bootstrap.css' );
}
add_action( 'enqueue_block_editor_assets', 'wall_decor_wallpaper_block_editor_styles' );

/* Theme enqueue scripts */
function wall_decor_wallpaper_scripts() {
	wp_enqueue_style( 'wall-decor-wallpaper-font', wall_decor_wallpaper_font_url(), array() );
	wp_enqueue_style( 'wall-decor-wallpaper-block-patterns-style-frontend', get_theme_file_uri('/inc/block-patterns/css/block-frontend.css') );
	wp_enqueue_style( 'wall-decor-wallpaper-block-style', get_theme_file_uri('/assets/css/blocks.css') );
	wp_enqueue_style( 'bootstrap-style', get_template_directory_uri().'/assets/css/bootstrap.css' );
	wp_enqueue_style( 'wall-decor-wallpaper-basic-style', get_stylesheet_uri() );
	wp_style_add_data('wall-decor-wallpaper-basic-style', 'rtl', 'replace');
	/* Inline style sheet */
	require get_parent_theme_file_path( '/custom-style.php' );
	wp_add_inline_style( 'wall-decor-wallpaper-basic-style',$wall_decor_wallpaper_custom_css );
	wp_enqueue_style( 'font-awesome-css', get_template_directory_uri().'/assets/css/fontawesome-all.css' );
	wp_enqueue_script( 'jquery-superfish', get_theme_file_uri( '/assets/js/jquery.superfish.js' ), array( 'jquery' ), '2.1.2', true );
	wp_enqueue_script( 'bootstrap-js', get_template_directory_uri(). '/assets/js/bootstrap.js', array('jquery') ,'',true);
	wp_enqueue_script( 'wall-decor-wallpaper-custom-scripts', get_template_directory_uri() . '/assets/js/custom.js', array('jquery'),'' ,true );
	if (get_theme_mod('wall_decor_wallpaper_animation', true) == true){
		wp_enqueue_script( 'jquery-wow', get_template_directory_uri() . '/assets/js/wow.js', array('jquery') );
		wp_enqueue_style( 'animate-css', get_template_directory_uri().'/assets/css/animate.css' );
	}
	
	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
		wp_enqueue_script( 'comment-reply' );
	}

	/* Enqueue the Dashicons script */
	wp_enqueue_style( 'dashicons' );
}
add_action( 'wp_enqueue_scripts', 'wall_decor_wallpaper_scripts' );


function wall_decor_wallpaper_sanitize_dropdown_pages( $page_id, $setting ) {
  	// Ensure $input is an absolute integer.
  	$page_id = absint( $page_id );
  	// If $page_id is an ID of a published page, return it; otherwise, return the default.
  	return ( 'publish' == get_post_status( $page_id ) ? $page_id : $setting->default );
}

function wall_decor_wallpaper_sanitize_choices( $input, $setting ) {
    global $wp_customize; 
    $control = $wp_customize->get_control( $setting->id ); 
    if ( array_key_exists( $input, $control->choices ) ) {
        return $input;
    } else {
        return $setting->default;
    }
}

function wall_decor_wallpaper_sanitize_number_range( $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 );
}

function wall_decor_wallpaper_sanitize_number_absint( $number, $setting ) {
	// Ensure $number is an absolute integer (whole number, zero or greater).
	$number = absint( $number );
	
	// If the input is an absolute integer, return it; otherwise, return the default
	return ( $number ? $number : $setting->default );
}

/* Excerpt Limit Begin */
function wall_decor_wallpaper_string_limit_words($string, $word_limit) {
	$words = explode(' ', $string, ($word_limit + 1));
	if(count($words) > $word_limit)
	array_pop($words);
	return implode(' ', $words);
}

if ( ! function_exists( 'wall_decor_wallpaper_switch_sanitization' ) ) {
	function wall_decor_wallpaper_switch_sanitization( $input ) {
		if ( true === $input ) {
			return 1;
		} else {
			return 0;
		}
	}
}

function wall_decor_wallpaper_sanitize_phone_number( $phone ) {
	return preg_replace( '/[^\d+]/', '', $phone );
}

function wall_decor_wallpaper_sanitize_float( $input ) {
	return filter_var($input, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
}

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

//Change number of products that are displayed per page (shop page)
add_filter( 'loop_shop_per_page', 'wall_decor_wallpaper_products_per_page' );
function wall_decor_wallpaper_products_per_page( $cols ) {
  	return  get_theme_mod( 'wall_decor_wallpaper_products_per_page',9);
}


function wall_decor_wallpaper_logo_title_hide_show(){
	if(get_theme_mod('wall_decor_wallpaper_logo_title_hide_show') == '1' ) {
		return true;
	}
	return false;
}

function wall_decor_wallpaper_tagline_hide_show(){
	if(get_theme_mod('wall_decor_wallpaper_tagline_hide_show',0) == '1' ) {
		return true;
	}
	return false;
}

//Active Callback
function wall_decor_wallpaper_default_slider(){
	if(get_theme_mod('wall_decor_wallpaper_slider_type', 'Default slider') == 'Default slider' ) {
		return true;
	}
	return false;
}

function wall_decor_wallpaper_advance_slider(){
	if(get_theme_mod('wall_decor_wallpaper_slider_type', 'Default slider') == 'Advance slider' ) {
		return true;
	}
	return false;
}

function wall_decor_wallpaper_blog_post_featured_image_dimension(){
	if(get_theme_mod('wall_decor_wallpaper_blog_post_featured_image_dimension') == 'custom' ) {
		return true;
	}
	return false;
}


// edit

if (!function_exists('wall_decor_wallpaper_edit_link')) :

    function wall_decor_wallpaper_edit_link($view = 'default')
    {
        global $post;
            edit_post_link(
                sprintf(
                    wp_kses(
                    /* translators: %s: Name of current post. Only visible to screen readers */
                        __('Edit <span class="screen-reader-text">%s</span>', 'wall-decor-wallpaper'),
                        array(
                            'span' => array(
                                'class' => array(),
                            ),
                        )
                    ),
                    get_the_title()
                ),
                '<span class="edit-link"><i class="fas fa-edit"></i>',
                '</span>'
            );

    }
endif;

/* Implement the Custom Header feature. */
require get_template_directory() . '/inc/custom-header.php';

function wall_decor_wallpaper_init_setup() {
	/* Custom template tags for this theme. */
	require get_template_directory() . '/inc/template-tags.php';

	/* Customizer additions. */
	require get_template_directory() . '/inc/customizer.php';

	/* Typography */
	require get_template_directory() . '/inc/typography/ctypo.php';

	/* Implement the About theme page */
	require get_template_directory() . '/inc/getstart/getstart.php';

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

	/* Social Icons */
	require get_template_directory() . '/inc/themes-widgets/social-icon.php';

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

	/* Block Pattern */
	require get_template_directory() . '/inc/block-patterns/block-patterns.php';

	/* Customizer additions. */
	require get_template_directory() . '/inc/themes-widgets/about-us-widget.php';

	/* Customizer additions. */
	require get_template_directory() . '/inc/themes-widgets/contact-us-widget.php';

	define('WALL_DECOR_WALLPAPER_FREE_THEME_DOC',__('https://demos.buywptemplates.com/demo/docs/free-wall-decor-wallpaper/','wall-decor-wallpaper'));
	define('WALL_DECOR_WALLPAPER_SUPPORT',__('https://wordpress.org/support/theme/wall-decor-wallpaper/','wall-decor-wallpaper'));
	define('WALL_DECOR_WALLPAPER_PRO_SUPPORT',__('https://www.buywptemplates.com/pages/community','wall-decor-wallpaper'));
	define('WALL_DECOR_WALLPAPER_REVIEW',__('https://wordpress.org/support/theme/wall-decor-wallpaper/reviews/','wall-decor-wallpaper'));
	define('WALL_DECOR_WALLPAPER_BUY_NOW',__('http://buywptemplates.com/products/wall-decor-wordpress-theme','wall-decor-wallpaper'));
	define('WALL_DECOR_WALLPAPER_LIVE_DEMO',__('https://demos.buywptemplates.com/wall-decor-wallpaper','wall-decor-wallpaper'));
	define('WALL_DECOR_WALLPAPER_PRO_DOC',__('https://demos.buywptemplates.com/demo/docs/bwt-wall-decor-wallpaper-pro/','wall-decor-wallpaper'));
	define('WALL_DECOR_WALLPAPER_FAQ',__('https://www.vwthemes.com/faqs/','wall-decor-wallpaper'));
	define('WALL_DECOR_WALLPAPER_CHILD_THEME',__('https://developer.wordpress.org/themes/advanced-topics/child-themes/','wall-decor-wallpaper'));
	define('WALL_DECOR_WALLPAPER_CONTACT',__('https://www.vwthemes.com/contact/','wall-decor-wallpaper'));
	define('WALL_DECOR_WALLPAPER_CREDIT',__('https://www.buywptemplates.com/products/free-wallpaper-wordpress-theme','wall-decor-wallpaper'));

	if ( ! function_exists( 'wall_decor_wallpaper_credit' ) ) {
		function wall_decor_wallpaper_credit(){
			echo "<a href=".esc_url(WALL_DECOR_WALLPAPER_CREDIT)." target='_blank'>".esc_html__('Wall Decor Wallpaper WordPress Theme ','wall-decor-wallpaper')."</a>";
		}
	}
}
add_action( 'after_setup_theme', 'wall_decor_wallpaper_init_setup' );	

// Admin notice code START
function wall_decor_wallpaper_dismissed_notice() {
	update_option( 'wall_decor_wallpaper_admin_notice', true );
}
add_action( 'wp_ajax_wall_decor_wallpaper_dismissed_notice', 'wall_decor_wallpaper_dismissed_notice' );

//After Switch theme function
add_action('after_switch_theme', 'wall_decor_wallpaper_getstart_setup_options');
function wall_decor_wallpaper_getstart_setup_options () {
    update_option('wall_decor_wallpaper_admin_notice', false );
}
// Admin notice code END

// Reset Setting
function wall_decor_wallpaper_reset_demo_import_settings() {

	if ( ! current_user_can( 'manage_options' ) ) {
		wp_send_json_error();
	}

	// Reset demo related theme mods
	remove_theme_mod('wall_decor_wallpaper_topbar_hide_show',false);
		remove_theme_mod( 'wall_decor_wallpaper_topbar_text1' );
		remove_theme_mod('wall_decor_wallpaper_slider_hide_show',false);
		remove_theme_mod( 'wall_decor_wallpaper_topbar_text2' );
		remove_theme_mod( 'wall_decor_wallpaper_slider_title' );
		remove_theme_mod( 'wall_decor_wallpaper_banner_button_label' );
		remove_theme_mod( 'wall_decor_wallpaper_slider_button_link' );
		remove_theme_mod( 'wall_decor_wallpaper_slider_page' );
		remove_theme_mod( 'wall_decor_wallpaper_product_title' );
		remove_theme_mod( 'wall_decor_wallpaper_product_heading_product' );
		remove_theme_mod( 'wall_decor_wallpaper_product_settings' );

	wp_send_json_success();
}
add_action( 'wp_ajax_wall_decor_wallpaper_reset_demo_import_settings', 'wall_decor_wallpaper_reset_demo_import_settings' );

function wall_decor_wallpaper_customizer_js() {

	wp_enqueue_script(
		'real-estate-customizer',
		get_template_directory_uri() . '/assets/js/customize-controls.js',
		array( 'jquery', 'customize-controls' ),
		'1.0',
		true
	);

	wp_localize_script(
		'real-estate-customizer',
		'real_estate_reset_obj',
		array(
			'ajax_url' => admin_url( 'admin-ajax.php' ),
			'nonce'    => wp_create_nonce( 'real_estate_reset_nonce' ),
		)
	);
}
add_action( 'customize_controls_enqueue_scripts', 'wall_decor_wallpaper_customizer_js' );
