<?php

function edify_setup() {
	load_theme_textdomain( 'edify', get_template_directory() . '/languages' );

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

	add_theme_support( 'title-tag' );
	add_theme_support( 'post-thumbnails' );
	add_image_size( 'edify_blog', 550,367, true );
	add_image_size( 'edify_product_thumb', 550,550, true );
	add_image_size( 'edify_single_blog', 1170,600, true );

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

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

    add_theme_support( 'register_block_pattern' );
    add_theme_support( 'register_block_style' );

    // Add support for full and wide align images.
    add_theme_support( 'align-wide' );

    // Add support for responsive embeds.
    add_theme_support( 'responsive-embeds' );
    add_theme_support( 'custom-header' );

    // Add support for custom line height.
    add_theme_support( 'custom-line-height' );

	// This theme uses wp_nav_menu() in one location.
	register_nav_menus(
		array(
			'menu-1' => esc_html__( 'Primary', 'edify' ),
			'menu-2' => esc_html__( 'Footer', 'edify' ),
		)
	);

	/*
		* 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',
			'style',
			'script',
		)
	);
	
	/*
	 * Set woocommerce support  
	 */
    add_theme_support('woocommerce');
            
    // Remove woocommerce defauly styles
    add_filter( 'woocommerce_enqueue_styles', '__return_false' );
    
    add_theme_support( 'wc-product-gallery-lightbox' );
    add_theme_support( 'wc-product-gallery-slider' );

    add_theme_support( 'woocommerce', array(
        'thumbnail_image_width' => 200,
        'gallery_thumbnail_image_width' => 200,
    ) );	

    /*
     * Set FluentCart support.
     * Without this, FluentCart::TemplateLoader::hasThemeSupport() is false
     * and FluentCart falls back to its bare "unsupported theme" mode for
     * single product / product taxonomy pages instead of using theme
     * templates via template_include.
     */
    add_theme_support( 'fluent_cart' );
		
	// Set up the WordPress core custom background feature.
	add_theme_support(
		'custom-background',
		apply_filters(
			'edify_custom_background_args',
			array(
				'default-color' => 'ffffff',
				'default-image' => '',
			)
		)
	);
	
	// Add theme support for selective refresh for widgets.
	add_theme_support( 'customize-selective-refresh-widgets' );

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

 // Add custom editor font sizes.
add_theme_support(
    'editor-font-sizes',
    array(
        array(
            'name'      => esc_html__( 'Extra small', 'edify' ),
            'shortName' => esc_html__( 'XS', 'edify' ),
            'size'      => 12,
            'slug'      => 'extra-small',
        ),
        array(
            'name'      => esc_html__( 'Small', 'edify' ),
            'shortName' => esc_html__( 'S', 'edify' ),
            'size'      => 16,
            'slug'      => 'small',
        ),
        array(
            'name'      => esc_html__( 'Normal', 'edify' ),
            'shortName' => esc_html__( 'N', 'edify' ),
            'size'      => 18,
            'slug'      => 'normal',
        ),
        array(
            'name'      => esc_html__( 'Medium', 'edify' ),
            'shortName' => esc_html__( 'M', 'edify' ),
            'size'      => 24,
            'slug'      => 'medium',
        ),
        array(
            'name'      => esc_html__( 'Medium Small', 'edify' ),
            'shortName' => esc_html__( 'MS', 'edify' ),
            'size'      => 28,
            'slug'      => 'medium-small',
        ),
        array(
            'name'      => esc_html__( 'Medium Plus', 'edify' ),
            'shortName' => esc_html__( 'ML', 'edify' ),
            'size'      => 36,
            'slug'      => 'medium-plus',
        ),
        array(
            'name'      => esc_html__( 'Large', 'edify' ),
            'shortName' => esc_html__( 'L', 'edify' ),
            'size'      => 46,
            'slug'      => 'large',
        ),
        array(
            'name'      => esc_html__( 'Extra large', 'edify' ),
            'shortName' => esc_html__( 'XL', 'edify' ),
            'size'      => 58,
            'slug'      => 'extra-large',
        ),
        array(
            'name'      => esc_html__( 'Huge', 'edify' ),
            'shortName' => esc_html__( 'XL', 'edify' ),
            'size'      => 70,
            'slug'      => 'huge',
        ),
    )
);

    // Add support for custom color scheme.
    add_theme_support( 'editor-color-palette', array(
        array(
            'name'  => esc_html__( 'White', 'edify' ),
            'slug'  => 'white',
            'color' => '#ffffff',
        ),
        array(
            'name'  => esc_html__( 'Black', 'edify' ),
            'slug'  => 'black',
            'color' => '#000000',
        ),
        array(
            'name'  => esc_html__( 'Primary', 'edify' ),
            'slug'  => 'primary',
            'color' => '#F14D5D',
        ),
        array(
            'name'  => esc_html__( 'Secondary', 'edify' ),
            'slug'  => 'secondary',
            'color' => '#FFCE4C',
        ),
        
        array(
            'name'  => esc_html__( 'Text Color', 'edify' ),
            'slug'  => 'text-color',
            'color' => '#505050',
        ),

        array(
            'name'  => esc_html__( 'Medium Black', 'edify' ),
            'slug'  => 'medium-black',
            'color' => '#222222',
        ),
        array(
            'name'  => esc_html__( 'Gray', 'edify' ),
            'slug'  => 'gray',
            'color' => '#999999',
        ),
        array(
            'name'  => esc_html__( 'Light Gray', 'edify' ),
            'slug'  => 'light-gray',
            'color' => '#f8f8f8',
        ),
        array(
            'name'  => esc_html__( 'Orange', 'edify' ),
            'slug'  => 'orange',
            'color' => '#f95042',
        ),
        array(
            'name'  => esc_html__( 'Pink', 'edify' ),
            'slug'  => 'pink',
            'color' => '#e03ae0',
        ),
    ) );

}
add_action( 'after_setup_theme', 'edify_setup' );

/**
 * Set the content width in pixels, based on the theme's design and stylesheet.
 */
function edify_content_width() {
	$GLOBALS['content_width'] = apply_filters( 'edify_content_width', 640 );
}
add_action( 'after_setup_theme', 'edify_content_width', 0 );

//  Default menu

function edify_default_menu(){ ?>
	<ul class="navbar-nav mx-auto">                  
		<li><a href="<?php echo admin_url('nav-menus.php'); ?>"><?php esc_html_e( 'Add Menu', 'edify' ); ?></a></li>
	</ul>
<?php	
}

// Main_menu
function edify_main_menu() {
		wp_nav_menu( array(
		'theme_location'    => 'menu-1',
		'depth'             => 5,
		'container'         => false,
		'menu_class'        => ' primary-menu ',
		'fallback_cb'       => 'edify_default_menu',
		
		)
	); 	
}

// Footer_menu
function edify_footer_menu() {
		wp_nav_menu( array(
		'theme_location'    => 'menu-2',
		'depth'             => 5,
		'container'         => false,
		'menu_class'        => 'navbar-nav mx-auto',
		'fallback_cb'       => 'edify_default_menu',
		
		)
	); 	
}

// top_menu
function edify_top_menu() {
		wp_nav_menu( array(
		'theme_location'    => 'menu-2',
		'depth'             => 5,
		'container'         => false,
		'menu_class'        => '',
		'fallback_cb'       => 'edify_default_menu',
		
		)
	); 	
}



/**
 * Registers an editor stylesheet in a sub-directory.
 */
function add_editor_styles_sub_dir() {
	add_editor_style( trailingslashit( get_template_directory_uri() ) . 'assets/css/editor-style.css' );
}
add_action( 'after_setup_theme', 'add_editor_styles_sub_dir' );
