<?php
/**
 * Mina functions and definitions.
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Mina
 */
 
/************************************* Basic *************************************/

if ( ! function_exists( 'mina_setup' ) ) :

function mina_setup() {

	load_theme_textdomain( 'mina', get_template_directory() . '/languages' );
	add_theme_support( 'automatic-feed-links' );
	add_theme_support( 'title-tag' );
	add_theme_support( 'post-thumbnails' );
	add_theme_support( 'woocommerce' );
    add_theme_support( 'wc-product-gallery-zoom' );
    add_theme_support( 'wc-product-gallery-lightbox' );
    add_theme_support( 'wc-product-gallery-slider' );	
	register_nav_menus( array(
		'primary' => esc_html__( 'Primary', 'mina' ),
	) );

	/*
	 * 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( 'mina_custom_background_args', array(
		'default-color' => 'ffffff',
		'default-image' => '',
	) ) );
}
endif;
add_action( 'after_setup_theme', 'mina_setup' );

function mina_content_width() {
	$GLOBALS['content_width'] = apply_filters( 'mina_content_width', 640 );
}
add_action( 'after_setup_theme', 'mina_content_width', 0 );

/************************************* Widgets *************************************/

function mina_widgets_init() {
	register_sidebar( array(
		'name'          => esc_html__( 'Sidebar', 'mina' ),
		'id'            => 'sidebar-1',
		'description'   => esc_html__( 'Add widgets here.', 'mina' ),
		'before_widget' => '<section id="%1$s" class="widget %2$s">',
		'after_widget'  => '</section>',
		'before_title'  => '<h2 class="widget-title">',
		'after_title'   => '</h2>',
	) );
}
add_action( 'widgets_init', 'mina_widgets_init' );


/************************************* Enqueue scripts and styles. *************************************/
 
function mina_scripts() {
	wp_enqueue_style( 'mina-style', get_stylesheet_uri() );

	wp_enqueue_style( 'mina-fontawesome', get_template_directory_uri() . '/css/font-awesome.min.css' );
	
	wp_enqueue_style( 'mina-animation', get_template_directory_uri() . '/css/animate.css' );
		
	wp_enqueue_script( 'mina-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true );

	wp_enqueue_script( 'mina-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );

	if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
		wp_enqueue_script( 'comment-reply' );
	}
}
add_action( 'wp_enqueue_scripts', 'mina_scripts' );

function mina_add_editor_styles() {
    add_editor_style( 'editor-style.css' );
}
add_action( 'admin_init', 'mina_add_editor_styles' );

/************************************* Include *************************************/

require get_template_directory() . '/inc/custom-header.php';
require get_template_directory() . '/inc/template-tags.php';
require get_template_directory() . '/inc/extras.php';
require get_template_directory() . '/inc/customizer.php';
require get_template_directory() . '/inc/jetpack.php';
require get_template_directory() . '/inc/costomize-google-fonst.php';
require get_template_directory() . '/inc/customize-footer.php';
require get_template_directory() . '/inc/customize-main.php';
require get_template_directory() . '/inc/customize-sidebar.php';
require get_template_directory() . '/inc/font-sizes.php';
require get_template_directory() . '/inc/header-options.php';
require get_template_directory() . '/inc/menu-options.php';
require get_template_directory() . '/inc/mina-slider.php';
require get_template_directory() . '/inc/sidebar-position.php';
require get_template_directory() . '/inc/woo-options-customize.php';
require get_template_directory() . '/inc/recent-post.php';


/*********************************************************************************************************
* Excerpt
**********************************************************************************************************/


		function mina_excerpt_more( $more ) {
			return ' <br /><br /><br /><a class="read-more" href="'. get_permalink( get_the_ID() ) . '">' . __('Read More', 'mina') . '</a>';
		}
			add_filter( 'excerpt_more', 'mina_excerpt_more' );

		function custom_excerpt_length( $length ) {
			return 50;
		}
		add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );	
