<?php

/**
 * Glowify Wp functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Glowify WP
 */

if ( ! function_exists( 'glowify_wp_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 glowify_wp_setup() {
		/*
		 * Make theme available for translation.
		 * Translations can be filed in the /languages/ directory.
		 * If you're building a theme based on Saepearl, use a find and replace
		 * to change 'glowify-wp' to the name of your theme in all the template files.
		 */

		load_theme_textdomain( 'glowify-wp', 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' );

		// Theme Supports
		add_image_size( 'glowify-blog-thumb-list', '1284', '698', true );
		add_image_size( 'glowify-blog-thumb-grid', '700', '735', true );
		add_image_size( 'glowify-blog-single-thumb', '1300', '684', true );
		add_image_size( 'glowify-room-grid-thumb', '500', '345', true );

		
		// Register Nav Menu
		register_nav_menus( array(
			'menu-1' => esc_html__( 'Primary Menu', 'glowify-wp' ),
		) );

		/*
		 * Switch default core markup for search form, comment form, and comments
		 * to output valid HTML5.
		 */
		add_theme_support( 'html5', array(
			'search-form',
			'comment-form',
			'comment-list',
			'gallery',
			'caption',
		) );

		// Set up the WordPress core custom background feature.
		add_theme_support( 'custom-background', apply_filters( 'glowify_wp_custom_background_args', array(
			'default-color' => 'ffffff',
			'default-image' => '',
		) ) );

		// Woocommerce
		add_theme_support( 'woocommerce' );

		// Add theme support for selective refresh for widgets.
		add_theme_support( 'customize-selective-refresh-widgets' );


		/**
		 * Add support for core custom logo.
		 *
		 * @link https://codex.wordpress.org/Theme_Logo
		 */
		add_theme_support( 'custom-logo', array(
			'height'      => 250,
			'width'       => 250,
			'flex-width'  => true,
			'flex-height' => true,
		) );


		// Enable supports for gutenberg blocks
		add_theme_support( 'align-wide' );
		add_theme_support( 'editor-styles' );
		add_theme_support( 'wp-block-styles' );
	}

endif;

add_action( 'after_setup_theme', 'glowify_wp_setup' );



/**
 * Register widget area.
 *

 * @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar

 */

function glowify_wp_widgets_init() {

	register_sidebar( array(
		'name'          => esc_html__( 'Blog Sidebar', 'glowify-wp' ),
		'id'            => 'glowify-blog-sidebar',
		'description'   => esc_html__( 'Add widgets here.', 'glowify-wp' ),
		'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__( 'Blog Archive Sidebar', 'glowify-wp' ),
		'id'            => 'glowify-blog-archive-sidebar',
		'description'   => esc_html__( 'Add archive blog widgets here.', 'glowify-wp' ),
		'before_widget' => '<div id="%1$s" class="single-widget widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',

	) );

	register_sidebar( array(

		'name'          => esc_html__( 'Blog Single Sidebar', 'glowify-wp' ),
		'id'            => 'glowify-blog-single-sidebar',
		'description'   => esc_html__( 'Add single blog widgets here.', 'glowify-wp' ),
		'before_widget' => '<div id="%1$s" class="single-widget widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',

	) );

	
	register_sidebar( array(

		'name'          => esc_html__( 'Shop Sidebar', 'glowify-wp' ),
		'id'            => 'glowify-shop-sidebar',
		'description'   => esc_html__( 'Add shop widgets here.', 'glowify-wp' ),
		'before_widget' => '<div id="%1$s" class="single-widget widget shop-widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h2 class="widget-title cs_shop_sidebar_widget_title">',
		'after_title'   => '</h2>',

	) );

	register_sidebar( array(
		'name'          => esc_html__( 'Footer Widget 1', 'glowify-wp' ),
		'id'            => 'glowify-footer-1',
		'description'   => esc_html__( 'Add footer widget here.', 'glowify-wp' ),
		'before_widget' => '<div id="%1$s" class="single-widget f-link widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',

	) );

	register_sidebar( array(
		'name'          => esc_html__( 'Footer Widget 2', 'glowify-wp' ),
		'id'            => 'glowify-footer-2',
		'description'   => esc_html__( 'Add footer widget here.', 'glowify-wp' ),
		'before_widget' => '<div id="%1$s" class="single-widget f-link footer-2-col-2 widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',

	) );

	register_sidebar( array(
		'name'          => esc_html__( 'Footer Widget 3', 'glowify-wp' ),
		'id'            => 'glowify-footer-3',
		'description'   => esc_html__( 'Add footer widget here.', 'glowify-wp' ),
		'before_widget' => '<div id="%1$s" class="single-widget f-link footer-2-col-2 widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );

	register_sidebar( array(
		'name'          => esc_html__( 'Footer Widget 4', 'glowify-wp' ),
		'id'            => 'glowify-footer-4',
		'description'   => esc_html__( 'Add footer widget here.', 'glowify-wp' ),
		'before_widget' => '<div id="%1$s" class="single-widget f-link footer-4-col-2 widget %2$s">',
		'after_widget'  => '</div>',
		'before_title'  => '<h3 class="widget-title">',
		'after_title'   => '</h3>',
	) );

}

add_action( 'widgets_init', 'glowify_wp_widgets_init' );


/**
 * Functions which enhance the theme by hooking into WordPress.
 */
require get_template_directory() . '/inc/template-functions.php';
require get_template_directory() . '/inc/comment-template.php';
require get_template_directory() . '/inc/google-fonts.php';
require get_template_directory() . '/inc/import-demo-files.php';
require get_template_directory() . '/inc/scripts-styles.php';
require get_template_directory() . '/inc/tgm/recommended-plugins.php';
require get_template_directory() . '/inc/template-tags.php';
require get_template_directory() . '/inc/metabox-and-options/metabox-option.php';
require get_template_directory() . '/inc/woow-functions.php';