<?php
/**
 * Theme setup: supports, menus, content width.
 *
 * @package Northfield_Theatre
 * @since 1.0.0
 */

function northfield_setup() {
	load_theme_textdomain( 'northfield-theatre', NORTHFIELD_DIR . '/languages' );

	add_theme_support( 'title-tag' );
	add_theme_support( 'post-thumbnails' );
	add_theme_support( 'automatic-feed-links' );
	add_theme_support( 'editor-styles' );

	add_theme_support(
		'html5',
		array(
			'search-form',
			'comment-form',
			'comment-list',
			'gallery',
			'caption',
			'style',
			'script',
			'navigation-widgets',
		)
	);

	add_theme_support(
		'custom-logo',
		array(
			'height'      => 60,
			'width'       => 300,
			'flex-height' => true,
			'flex-width'  => true,
		)
	);

	register_nav_menus(
		array(
			'primary' => esc_html__( 'Primary Navigation', 'northfield-theatre' ),
			'footer'  => esc_html__( 'Footer Navigation', 'northfield-theatre' ),
		)
	);

	add_theme_support( 'responsive-embeds' );
	add_theme_support( 'wp-block-styles' );
	add_theme_support( 'align-wide' );
}
add_action( 'after_setup_theme', 'northfield_setup' );

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

// This is a portfolio demo — suppress the WordPress admin bar on the front
// end so the site is judged on its own chrome, not WP's.
add_filter( 'show_admin_bar', '__return_false' );

function northfield_widgets_init() {
	register_sidebar(
		array(
			'name'          => esc_html__( 'Footer Column 1', 'northfield-theatre' ),
			'id'            => 'footer-1',
			'description'   => esc_html__( 'First footer widget area.', 'northfield-theatre' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget'  => '</div>',
			'before_title'  => '<h3 class="widget-title">',
			'after_title'   => '</h3>',
		)
	);

	register_sidebar(
		array(
			'name'          => esc_html__( 'Footer Column 2', 'northfield-theatre' ),
			'id'            => 'footer-2',
			'description'   => esc_html__( 'Second footer widget area.', 'northfield-theatre' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget'  => '</div>',
			'before_title'  => '<h3 class="widget-title">',
			'after_title'   => '</h3>',
		)
	);

	register_sidebar(
		array(
			'name'          => esc_html__( 'Footer Column 3', 'northfield-theatre' ),
			'id'            => 'footer-3',
			'description'   => esc_html__( 'Third footer widget area.', 'northfield-theatre' ),
			'before_widget' => '<div id="%1$s" class="widget %2$s">',
			'after_widget'  => '</div>',
			'before_title'  => '<h3 class="widget-title">',
			'after_title'   => '</h3>',
		)
	);
}
add_action( 'widgets_init', 'northfield_widgets_init' );
