<?php

require get_template_directory() . '/inc/customizer.php';
require get_template_directory() . '/inc/widgets/about.php';
require get_template_directory() . '/inc/widgets/sticky.php';


if (!function_exists(('sofia_set_content_width'))) {
    function sofia_set_content_width()
    {
        if (!isset($content_width)) {
            $content_width = 840;
        }
    }
}

/*
* 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');

// This theme uses Featured Images (also known as post thumbnails) for per-post/per-page.
add_theme_support('post-thumbnails');

// Adding excerpt option box for pages as well
add_post_type_support('page', 'excerpt');

// 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',));

// Adds the support for the Custom Logo introduced in WordPress 4.5
add_theme_support('custom-logo',array('height'      => 50,'width'       => 192,));

// Support for selective refresh widgets in Customizer
add_theme_support('customize-selective-refresh-widgets');

add_theme_support('automatic-feed-links');

// Gutenberg layout support.
add_theme_support('align-wide');

// Support for selective refresh widgets in Customizer
add_theme_support('customize-selective-refresh-widgets');

// Support for Guttemberg blocks
add_theme_support( 'responsive-embeds' );
 
add_theme_support( 'wp-block-styles' );

add_theme_support( 'align-wide' );

add_image_size('thumb-custom', 200, 200, true);


add_action('after_setup_theme', 'sofia_set_content_width', 0);

function register_header_menu()
{
    register_nav_menu('header-menu', __('Header Menu', 'sofia-wp'));
}
add_action('init', 'register_header_menu');

function register_social_menu()
{
    register_nav_menu('social-menu', __('Social Menu', 'sofia-wp'));
}
add_action('init', 'register_social_menu');

function register_sofia_script()
{
    wp_enqueue_script('jquery', get_template_directory_uri() . '/jquery-3.4.1.min', false);
    wp_enqueue_script('myscript', get_template_directory_uri() . '/main.js');
    wp_enqueue_style('mystyle', get_template_directory_uri() . '/style.css');
    wp_enqueue_style('sofia-icons', get_template_directory_uri() . '/assets/css/fontawesome-all.min.css');
}

add_action('wp_enqueue_scripts', 'register_sofia_script');

function register_sofia_sidebar_widget()
{
    register_sidebar(array(
        'name' => 'Sidebar',
        'id' => 'sofia_sidebar_widget',

        'before_title' => '<h2>',
        'after_title' => '</h2>',
    ));
}

add_action('widgets_init', 'register_sofia_sidebar_widget');


function sofia_enqueue_comments_reply()
{
    if (get_option('thread_comments')) {
        wp_enqueue_script('comment-reply');
    }
}
add_action('comment_form_before', 'sofia_enqueue_comments_reply');

// Filter except length to 25 words.
// tn custom excerpt length
function sofia_custom_excerpt_length($length)
{
    return 25;
}
add_filter('excerpt_length', 'sofia_custom_excerpt_length', 999);


add_action( 'widgets_init', function(){
    register_widget( 'AboutAuthor_Widget' );
});



add_action( 'widgets_init', function(){
    register_widget( 'StickyPosts_Widget' );
});



