<?php
/* ==========================================================================
 *  Theme settings
 * ========================================================================== */
if ( ! function_exists( 'cgs_fashion_trend_setup' ) ) :
	function cgs_fashion_trend_setup() {
		if ( ! isset( $content_width ) ) {
			$content_width = 725;
		}

		load_theme_textdomain( 'cgs-fashion-trend', get_template_directory() . '/languages' );

		add_theme_support( 'woocommerce' );
		add_theme_support( 'bbpress' );
		add_theme_support( 'automatic-feed-links' );
		add_theme_support( 'post-thumbnails' );
		add_image_size( 'img_348_201', 348, 201, true );
		add_theme_support( 'title-tag' );
		add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );

		add_theme_support( 'custom-background', apply_filters( 'basic_custom_background_args', array( 'default-color' => 'ffffff' ) ) );
		add_theme_support( 'custom-header', array(
			'width'       => 1080,
			'height'      => 190,
			'flex-height' => true,
			'flex-width' => true,
		) );

		register_nav_menus( array(
			'top'    => __( 'Main Menu', 'cgs-fashion-trend' )
		) );


		// logo
		$args = array();
		$lpos = esc_html(get_theme_mod( 'display_logo_and_title' ));
		if ( false === $lpos || 'image' == $lpos ) {
			$args['header-text'] = array( 'blog-name' );
		}
		add_theme_support( 'custom-logo', $args );
	}
endif;
add_action( 'after_setup_theme', 'cgs_fashion_trend_setup' );

/* ==========================================================================
 *  Load scripts and styles
 * ========================================================================== */
if ( ! function_exists( 'cgs_fashion_trend_enqueue_style_and_script' ) ) :
	function cgs_fashion_trend_enqueue_style_and_script() {

		global $post, $wp_query;

		// STYLES
		wp_enqueue_style( 'cgs-fashion-trend-fonts', '//fonts.googleapis.com/css?family=Open+Sans:400,600,700,800|Playfair+Display:400,700,900|Poppins:400,500,600,700', array(), true );
		wp_enqueue_style( 'bootstrap', get_template_directory_uri().'/css/bootstrap.min.css', array(), true );
		wp_enqueue_style( 'cgs-fashion-trend-style', get_stylesheet_uri(), array(), true );

		// SCRIPTS
		wp_enqueue_script( 'html5shiv', get_template_directory_uri() . '/js/html5shiv.min.js', array(), '3.7.3', true );
		wp_script_add_data( 'html5shiv', 'conditional', 'lt IE 9' );
		wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.bundle.min.js', array( 'jquery' ), true, true );

		if(is_singular()){
			if(comments_open() && get_option('thread_comments')){
				wp_enqueue_script( 'comment-reply', false, true, true );
			}
		}
	}
endif;
add_action( 'wp_enqueue_scripts', 'cgs_fashion_trend_enqueue_style_and_script' );
/* =========================================================================== */
add_action( 'widgets_init', 'cgs_fashion_trend_widgets_init' );
function cgs_fashion_trend_widgets_init() {
	/* translators: %s: search term */
	register_sidebar( array(
		'name' => __('Primary Sidebar', 'cgs-fashion-trend'),
		'id' => 'sidebar-1',
		'before_widget' => '<div id="%1$s" class="widget_box %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="side_title">',
		'after_title' => '</h3>',
	) );
}

add_action( 'admin_init', 'cgs_fashion_trend_add_editor_styles' );
function cgs_fashion_trend_add_editor_styles() {
	add_editor_style('editor-style.css');
}
function cgs_fashion_trend_footer_copyright(){
	$site_link  = '<a href="' . esc_url( home_url( '/' ) ) . '" title="' . esc_attr( get_bloginfo( 'name', 'display' ) ) . '" >' . esc_html(get_bloginfo( 'name', 'display'), 'cgs-fashion-trend') . '</a>';
	$theme_link = '<a href="'.esc_url(CGS_FASHION_TREND_THEME_LINK).'" target="_blank" title="' . esc_attr__( 'CGS Themes', 'cgs-fashion-trend' )                                   . '" rel="author">' . __( 'CGS Fashion Trend', 'cgs-fashion-trend' ) . '</a>';

	/* translators: 1: Current Year, 2: Site Name, 3: Theme Name. */
	$footer_copyright = sprintf( esc_html__( 'Copyright &copy; %1$s %2$s. Theme: %3$s By CGS Themes.', 'cgs-fashion-trend' ), esc_attr( date( 'Y' ) ), $site_link, $theme_link);

	return $footer_copyright;
}
function custom_css() {
	?>
    <style>
        <?php
        $cgs_fashion_trend_link_color = get_theme_mod('cgs_fashion_trend_link_color');
        if(!empty($cgs_fashion_trend_link_color)){
            echo 'a{color: '.esc_html($cgs_fashion_trend_link_color).' !important;}';
        }
        $cgs_fashion_trend_button_color = get_theme_mod('cgs_fashion_trend_button_color');
        if(!empty($cgs_fashion_trend_button_color)){
            echo '.btn-primary{background-color: '.esc_html($cgs_fashion_trend_button_color).' !important; border-color: '.esc_html($cgs_fashion_trend_button_color).' !important;}';
            echo 'nav.pagination .page-numbers{background: '.esc_html($cgs_fashion_trend_button_color).' !important;}';
        }

        $cgs_fashion_trend_h1_color = get_theme_mod('cgs_fashion_trend_h1_color');
        $cgs_fashion_trend_h2_color = get_theme_mod('cgs_fashion_trend_h2_color');
        $cgs_fashion_trend_h3_color = get_theme_mod('cgs_fashion_trend_h3_color');
        $cgs_fashion_trend_h4_color = get_theme_mod('cgs_fashion_trend_h4_color');
        $cgs_fashion_trend_p_color = get_theme_mod('cgs_fashion_trend_p_color');
        $cgs_fashion_trend_background_color = get_theme_mod('background_color');
        $cgs_fashion_trend_header_textcolor = get_theme_mod('header_textcolor');

        if(!empty($cgs_fashion_trend_h1_color)){
            echo 'h1{color: '.esc_html($cgs_fashion_trend_h1_color).' !important;}';
        }
        if(!empty($cgs_fashion_trend_h2_color)){
            echo 'h2{color: '.esc_html($cgs_fashion_trend_h2_color).' !important;}';
        }
        if(!empty($cgs_fashion_trend_h3_color)){
            echo 'h3{color: '.esc_html($cgs_fashion_trend_h3_color).' !important;}';
        }
        if(!empty($cgs_fashion_trend_h4_color)){
            echo 'h4{color: '.esc_html($cgs_fashion_trend_h4_color).' !important;}';
        }
        if(!empty($cgs_fashion_trend_p_color)){
            echo 'p{color: '.esc_html($cgs_fashion_trend_p_color).' !important;} .post-content p, .search-results p, .main-content-wrapper p{color: '.esc_html($cgs_fashion_trend_p_color).' !important;} .post-content li{color: '.esc_html($cgs_fashion_trend_p_color).' !important;}';
        }
        if(!empty($cgs_fashion_trend_background_color)){
            echo '.main-content-wrapper{background:#'.esc_html($cgs_fashion_trend_background_color).' !important;}';
        }
        if(!empty($cgs_fashion_trend_header_textcolor)){
            echo 'h1{color: #'.esc_html($cgs_fashion_trend_header_textcolor).' !important;} h2{color: #'.esc_html($cgs_fashion_trend_header_textcolor).' !important;} h3{color: #'.esc_html($cgs_fashion_trend_header_textcolor).' !important;} h4{color: #'.esc_html($cgs_fashion_trend_header_textcolor).' !important;} h5{color: #'.esc_html($cgs_fashion_trend_header_textcolor).' !important;} h6{color: #'.esc_html($cgs_fashion_trend_header_textcolor).' !important;} h1 a{color: #'.esc_html($cgs_fashion_trend_header_textcolor).' !important;} h2 a{color: #'.esc_html($cgs_fashion_trend_header_textcolor).' !important;} h3 a{color: #'.esc_html($cgs_fashion_trend_header_textcolor).' !important;} h4 a{color: #'.esc_html($cgs_fashion_trend_header_textcolor).' !important;} h5 a{color: #'.esc_html($cgs_fashion_trend_header_textcolor).' !important;} h6 a{color: #'.esc_html($cgs_fashion_trend_header_textcolor).' !important;}';
        }
        if (display_header_text()==true){
            echo '.header-wrapper ul.menu{padding: 10px 0 0 0};';
        }
        ?>
    </style>
	<?php
}
add_action('wp_head', 'custom_css');
require_once get_template_directory() . '/bs4navwalker.php';
/* =========================================================================== */
require_once( get_template_directory() . '/customizer.php' );

define('CGS_FASHION_TREND_URL','https://www.cgsthemes.com/');
define('CGS_FASHION_TREND_PRO_THEME_URL','https://www.cgsthemes.com/product/fashion/');
define('CGS_FASHION_TREND_FREE_THEME_URL','https://www.cgsthemes.com/product/free-fashion/');
define('CGS_FASHION_TREND_THEME_DOC','https://www.cgsthemes.com/documentation/fashion-free-theme-documentation/');
define('CGS_FASHION_TREND_LIVE_DEMO','https://cgsthemesdemo.com/fashion/?action=preview');
define('CGS_FASHION_TREND_THEMES_BUY_NOW','https://www.cgsthemes.com/cart/?add-to-cart=217');
define('CGS_FASHION_TREND_THEMES_ALL_FREE_THEMES','https://www.cgsthemes.com/product-category/free-wordpress-themes/');
define('WORDPRESS_URL','https://wordpress.org');
define('CGS_FASHION_TREND_THEME_LINK','https://www.cgsthemes.com/product-category/free-wordpress-themes/');
function cgs_fashion_trend_admin_theme_style() {
	wp_enqueue_style('cgs-theme-admin-style', get_template_directory_uri() . '/css/admin_style.css');
}
add_action('admin_enqueue_scripts', 'cgs_fashion_trend_admin_theme_style');
require get_template_directory() . '/about-themes.php';
