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


 /**
 * Define Constants
 */
define('TEMPLATIC_THEME_VERSION', '1.0.6');
define('TEMPLATIC_THEME_DIR', get_template_directory());
define('TEMPLATIC_THEME_URI', get_template_directory_uri());



/**
* Basic Theme Setup
*/
if (! function_exists('foodblogger_litesetup')) :
    function foodblogger_litesetup()
    {

        // Make theme available for translation.
        load_theme_textdomain('food-blogger-lite', TEMPLATIC_THEME_DIR . '/languages');

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

        // Let WordPress manage the document title.
        add_theme_support('title-tag');

        // Enable support for Post Thumbnails on posts and pages.
        add_theme_support('post-thumbnails');

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

        // Switch default core markup for search form, comment form, and comments
        add_theme_support('html5', array(
            'comment-form',
            'comment-list',
            'gallery',
            'caption',
        ));

        // Set up the WordPress core custom background feature.
        add_theme_support('custom-background', apply_filters('foodblogger_litecustom_background_args', array(
            'default-color' => 'f4f4f4',
            '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,
        ));
    }
endif;
add_action('after_setup_theme', 'foodblogger_litesetup');



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



/**
 * Register widget area.
 */
function foodblogger_litewidgets_init()
{
    register_sidebar(array(
        'name'          => esc_html__('Sidebar', 'food-blogger-lite'),
        'id'            => 'sidebar-1',
        'description'   => esc_html__('Add widgets here.', 'food-blogger-lite'),
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget'  => '</section>',
        'before_title'  => '<h4 class="widget-title">',
        'after_title'   => '</h4>',
    ));
    register_sidebar(array(
        'name'          => esc_html__('Header - Top Widget Area', 'food-blogger-lite'),
        'id'            => 'header-top-widget-area',
        'description'   => esc_html__('Add widgets here.', 'food-blogger-lite'),
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget'  => '</section>',
        'before_title'  => '<h4 class="widget-title">',
        'after_title'   => '</h4>',
    ));
    register_sidebar(array(
        'name'          => esc_html__('Header Right', 'food-blogger-lite'),
        'id'            => 'header-right',
        'description'   => esc_html__('Add widgets to display in header right.', 'food-blogger-lite'),
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget'  => '</section>',
        'before_title'  => '<h6 class="widget-title">',
        'after_title'   => '</h6>',
    ));
    register_sidebar(array(
        'name'          => esc_html__('Footer - Full Width Widget Area', 'food-blogger-lite'),
        'id'            => 'footer-full-width-widget-area',
        'description'   => esc_html__('Add widgets to display in footer.', 'food-blogger-lite'),
        'before_widget' => '<section id="%1$s" class="widget %2$s">',
        'after_widget'  => '</section>',
        'before_title'  => '<h6 class="widget-title">',
        'after_title'   => '</h6>',
    ));
}
add_action('widgets_init', 'foodblogger_litewidgets_init');



/**
 * Enqueue scripts and styles.
 */
function foodblogger_litescripts()
{
    wp_enqueue_style('food_blogger_lite-fonts', '//fonts.googleapis.com/css?family=Open+Sans:400,600');
    wp_enqueue_style('slicknavcss', TEMPLATIC_THEME_URI . '/assets/css/slicknav.css', array(), 'v1.0.10', 'all');
    wp_enqueue_style('font-awesome-5', TEMPLATIC_THEME_URI . '/assets/css/fontawesome-all.css', array(), '5.0.13', 'all');
    wp_enqueue_style('bootstrap-4', TEMPLATIC_THEME_URI . '/assets/css/bootstrap.css', array(), 'v4.1.1', 'all');
    wp_enqueue_style('food_blogger_lite-style', get_stylesheet_uri(), array(), 'v1.0.0', 'all');

    wp_enqueue_script('slicknav', TEMPLATIC_THEME_URI . '/assets/js/jquery.slicknav.js', array( 'jquery' ), 'v1.0.10', true);
    wp_enqueue_script('food_blogger_lite-theme', TEMPLATIC_THEME_URI . '/assets/js/theme.js', array( 'jquery' ), '1.0.0', true);

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

// Add theme hooks.
require TEMPLATIC_THEME_DIR . '/inc/theme-hooks.php';

// Implement the Custom Header feature.
require TEMPLATIC_THEME_DIR . '/inc/custom-header.php';

// Custom template tags for this theme.
require TEMPLATIC_THEME_DIR . '/inc/template-tags.php';

// Functions which enhance the theme by hooking into WordPress.
require TEMPLATIC_THEME_DIR . '/inc/template-functions.php';

// Customizer additions.
require TEMPLATIC_THEME_DIR . '/inc/customizer.php';

// Load Jetpack compatibility file.
if (defined('JETPACK__VERSION')) {
    require TEMPLATIC_THEME_DIR . '/inc/jetpack.php';
}

// Install Plugins
require TEMPLATIC_THEME_DIR . '/inc/init-tgmpa.php';
