<?php
/**
 * Theme supports, menus, and image sizes.
 *
 * @package ttsunsolar
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Register theme supports.
 */
function ttsunsolar_setup() {
	load_theme_textdomain( 'ttsunsolar', TTSUNSOLAR_DIR . '/languages' );

	add_theme_support( 'automatic-feed-links' );
	add_theme_support( 'title-tag' );
	add_theme_support( 'post-thumbnails' );
	add_theme_support(
		'html5',
		array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script' )
	);
	add_theme_support(
		'custom-logo',
		array(
			'height'      => 80,
			'width'       => 240,
			'flex-height' => true,
			'flex-width'  => true,
		)
	);
	add_theme_support(
		'custom-background',
		array(
			'default-color' => 'ffffff',
		)
	);
	add_theme_support( 'custom-header', array(
		'default-image' => ttsunsolar_image_uri( 'slider-1.jpg' ),
		'width'         => 1920,
		'height'        => 800,
		'flex-height'   => true,
		'header-text'   => false,
	) );
	add_theme_support( 'align-wide' );
	add_theme_support( 'responsive-embeds' );
	add_theme_support( 'wp-block-styles' );
	add_theme_support( 'editor-styles' );
	add_editor_style( 'solarkit/css/solarkit-theme.css' );

	register_nav_menus(
		array(
			'primary' => __( 'Primary Menu', 'ttsunsolar' ),
			'footer'  => __( 'Footer Menu', 'ttsunsolar' ),
		)
	);

	add_image_size( 'ttsunsolar-service', 640, 420, true );

	// Soft defaults for Customizer / WordPress.org-style theme previews.
	add_theme_support(
		'starter-content',
		array(
			'options' => array(
				'blogname'        => 'TTSun Solar',
				'blogdescription' => 'Clean Energy Solutions',
			),
		)
	);

	register_block_style(
		'core/paragraph',
		array(
			'name'  => 'ttsunsolar-lead',
			'label' => __( 'Lead text', 'ttsunsolar' ),
		)
	);

	register_block_pattern(
		'ttsunsolar/cta-note',
		array(
			'title'       => __( 'Solar CTA note', 'ttsunsolar' ),
			'description' => __( 'A simple call-to-action paragraph for solar pages.', 'ttsunsolar' ),
			'content'     => '<!-- wp:paragraph {"className":"is-style-ttsunsolar-lead"} --><p class="is-style-ttsunsolar-lead">' . esc_html__( 'Ready for cleaner energy? Request a free solar consultation today.', 'ttsunsolar' ) . '</p><!-- /wp:paragraph -->',
		)
	);
}
add_action( 'after_setup_theme', 'ttsunsolar_setup' );

/**
 * Content width.
 */
function ttsunsolar_content_width() {
	$GLOBALS['content_width'] = apply_filters( 'ttsunsolar_content_width', 1140 );
}
add_action( 'after_setup_theme', 'ttsunsolar_content_width', 0 );
