<?php
/**
 * Theme Customizer Controls - Blog Settings
 *
 * @package shopbar
 */

defined( 'ABSPATH' ) || exit;


if ( ! function_exists( 'shopbar_customizer_blog_register' ) ) :
function shopbar_customizer_blog_register( $wp_customize ) {

	/**
	 * Blog Settings Section
	 */
	$wp_customize->add_section(
		'shopbar_blog_settings',
		array(
			'priority'   => 22,
			'capability' => 'edit_theme_options',
			'title'      => esc_html__( 'Blog Settings', 'shopbar' ),
		)
	);

	// Title label - Blog Page Header
	$wp_customize->add_setting(
		'shopbar_blog_header_label',
		array(
			'sanitize_callback' => 'shopbar_sanitize_title',
		)
	);

	$wp_customize->add_control(
		new Shopbar_Title_Info_Control( $wp_customize, 'shopbar_blog_header_label',
		array(
			'label'    => esc_html__( 'Blog Page Header', 'shopbar' ),
			'section'  => 'shopbar_blog_settings',
			'type'     => 'shopbar-title',
			'settings' => 'shopbar_blog_header_label',
		)
	));

	// Blog page heading text
	$wp_customize->add_setting(
		'shopbar_blog_heading',
		array(
			'default'           => __( 'Blog', 'shopbar' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'shopbar_sanitize_text_field',
			'transport'         => 'refresh',
		)
	);

	$wp_customize->add_control(
		'shopbar_blog_heading',
		array(
			'settings'    => 'shopbar_blog_heading',
			'section'     => 'shopbar_blog_settings',
			'type'        => 'text',
			'label'       => esc_html__( 'Blog Page Heading', 'shopbar' ),
			'description' => esc_html__( 'Heading text displayed on the blog listing page.', 'shopbar' ),
		)
	);

	// Blog page subheading text
	$wp_customize->add_setting(
		'shopbar_blog_subheading',
		array(
			'default'           => esc_html__( 'Stories on design, craftsmanship, and the art of intentional living.', 'shopbar' ),
			'type'              => 'theme_mod',
			'sanitize_callback' => 'shopbar_sanitize_textarea_field',
			'transport'         => 'refresh',
		)
	);

	$wp_customize->add_control(
		'shopbar_blog_subheading',
		array(
			'settings'    => 'shopbar_blog_subheading',
			'section'     => 'shopbar_blog_settings',
			'type'        => 'textarea',
			'label'       => esc_html__( 'Blog Page Subheading', 'shopbar' ),
			'description' => esc_html__( 'Subheading text displayed below the heading on the blog listing page.', 'shopbar' ),
		)
	);
}
endif;

add_action( 'customize_register', 'shopbar_customizer_blog_register' );
