tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
// Add theme support for Custom Logo.
// Custom logo.
$logo_width = 300;
$logo_height = 80;
// If the retina setting is active, double the recommended width and height.
if ( get_theme_mod( 'retina_logo', false ) ) {
$logo_width = floor( $logo_width * 2 );
$logo_height = floor( $logo_height * 2 );
}
$args = array(
'height' => $logo_height,
'width' => $logo_width,
'flex-height' => true,
'flex-width' => true,
);
add_theme_support('custom-logo', $args);
/*
* 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' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus( array(
'primary' => esc_html__( 'Primary Menu', 'firstsite' ),
'secondary' => esc_html__( 'Secondary Menu', 'firstsite' ),
'footer' => esc_html__( 'Footer Menu', 'firstsite' ),
'mobile' => esc_html__( 'Mobile Menu', 'firstsite' ),
) );
/*
* 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( 'firstsite_custom_background_args', array(
'default-color' => 'ffffff',
'default-image' => '',
) ) );
// Add support for editor styles.
add_theme_support( 'editor-styles' );
$editor_stylesheet_path = './assets/css/editor-style.css';
// Enqueue editor styles.
add_editor_style( $editor_stylesheet_path );
}
endif;
add_action( 'after_setup_theme', 'firstsite_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function firstsite_content_width() {
$GLOBALS['content_width'] = apply_filters( 'firstsite_content_width', 760 );
}
add_action( 'after_setup_theme', 'firstsite_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function firstsite_sidebar_init() {
register_sidebar( array(
'name' => esc_html__( 'Sidebar', 'firstsite' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'firstsite' ),
'before_widget' => '
',
'after_widget' => '
',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Footer Columns', 'firstsite' ),
'id' => 'footer',
'description' => esc_html__( '4 Columns widget area.', 'firstsite' ),
'before_widget' => '',
'after_widget' => '
',
'before_title' => '',
) );
register_sidebar( array(
'name' => esc_html__( 'Header Ad', 'firstsite' ),
'id' => 'header-ad',
'description' => esc_html__( 'Add the "Image" and "Custom HTML" widget here.', 'firstsite' ),
'before_widget' => '',
'before_title' => '',
) );
}
add_action( 'widgets_init', 'firstsite_sidebar_init' );
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Custom functions that act independently of the theme templates.
*/
require get_template_directory() . '/inc/extras.php';
/**
* Load Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
/**
* Load about page.
*/
require get_template_directory() . '/inc/about.php';
// Block Patterns.
require get_template_directory() . '/inc/block-patterns.php';
// Block Styles.
require get_template_directory() . '/inc/block-styles.php';
/**
* SVG Icons.
*/
require get_template_directory() . '/inc/classes/class-firstsite-svg-icons.php';
/**
* Menu Walker.
*/
require get_template_directory() . '/inc/classes/class-firstsite-walker-page.php';
/**
* Enqueues scripts and styles.
*/
function firstsite_scripts() {
// load jquery if it isn't
wp_enqueue_script('jquery');
// Enqueues Javascripts
wp_enqueue_script( 'superfish', get_template_directory_uri() . '/assets/js/superfish.js', array(), '', true );
wp_enqueue_script( 'html5', get_template_directory_uri() . '/assets/js/html5.js', array(), '', true );
wp_enqueue_script( 'owl-carousel', get_template_directory_uri() . '/assets/js/owl.carousel.js', array(), '', true );
wp_enqueue_script( 'tabslet', get_template_directory_uri() . '/assets/js/jquery.tabslet.js', array(), '20230701', true );
wp_enqueue_script( 'firstsite-index', get_template_directory_uri() . '/assets/js/index.js', array(), '20220601', true );
wp_enqueue_script( 'firstsite-custom', get_template_directory_uri() . '/assets/js/jquery.custom.js', array(), '20220601', true );
// Enqueues CSS styles
wp_enqueue_style( 'firstsite-googlefonts', 'https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap', array(), null );
wp_enqueue_style( 'firstsite-style', get_stylesheet_uri(), array(), '20220601' );
wp_enqueue_style( 'genericons-style', get_template_directory_uri() . '/genericons/genericons.css' );
wp_enqueue_style( 'firstsite-responsive-style', get_template_directory_uri() . '/responsive.css', array(), '20220601' );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'firstsite_scripts' );
/**
* Post Thumbnails.
*/
if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 300, 300, true ); // default Post Thumbnail dimensions (cropped)
add_image_size( 'firstsite_featured_thumb', 730, 360, true );
add_image_size( 'firstsite_featured_grid_thumb', 300, 170, true );
add_image_size( 'firstsite_widget_thumb', 300, 150, true );
}
/**
* Registers custom widgets.
*/
function firstsite_widgets_init() {
require trailingslashit( get_template_directory() ) . 'inc/widgets/widget-most-commented.php';
register_widget( 'FirstSite_Most_Commented_Widget' );
require trailingslashit( get_template_directory() ) . 'inc/widgets/widget-recent.php';
register_widget( 'FirstSite_Recent_Widget' );
require trailingslashit( get_template_directory() ) . 'inc/widgets/widget-category-posts.php';
register_widget( 'FirstSite_Category_Posts_Widget' );
require trailingslashit( get_template_directory() ) . 'inc/widgets/widget-tabs.php';
register_widget( 'FirstSite_Tabs_Widget' );
}
add_action( 'widgets_init', 'firstsite_widgets_init' );