add_panel( 'header_section_panel', array(
'priority' => 21,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => 'Header Section',
'description' => '',
) );
// ================================
// = Hero Header Media Type Options =
// ================================
$wp_customize->add_section( 'ananya_frontpage_header_type_section', array(
'title' => __( 'Hero Section Text', 'ananya' ),
'panel' => 'header_section_panel',
'priority' => 1,
'capability' => 'edit_theme_options',
) );
// =============================
// = Hero Header/Banner Options =
// =============================
$wp_customize->add_setting( 'ananya_header_title', array(
'capability' => 'edit_theme_options',
'default' => __( 'Enter the title here', 'ananya' ),
'transport' => 'refresh',
'sanitize_callback' => 'ananya_sanitize_text',
) );
$wp_customize->add_control( 'ananya_header_title', array(
'type' => 'text',
'priority' => 2,
'section' => 'ananya_frontpage_header_type_section',
'label' => __( 'Enter Header/Banner Title', 'ananya' ),
'description' => __( 'This title will appear over the header image.','ananya' ),
'settings' => 'ananya_header_title',
) );
//Hero Header/Banner Subtitle
$wp_customize->add_setting( 'ananya_header_subtitle', array(
'capability' => 'edit_theme_options',
'default' => __( 'Eneter the subtitle here', 'ananya' ),
'transport' => 'refresh',
'sanitize_callback' => 'ananya_sanitize_text',
) );
$wp_customize->add_control( 'ananya_header_subtitle', array(
'type' => 'text',
'priority' => 3,
'section' => 'ananya_frontpage_header_type_section',
'label' => __( 'Enter Header/Banner Sub Title', 'ananya' ),
'description' => __( 'This sub title will appear over the header image.', 'ananya' ),
'settings' => 'ananya_header_subtitle',
) );
$wp_customize->add_setting( 'ananya_header_button_text', array(
'capability'=> 'edit_theme_options',
'default' => __( 'Read More', 'ananya' ),
'sanitize_callback' => 'ananya_sanitize_text',
) );
$wp_customize->add_control( 'ananya_header_button_text', array(
'label' => __( 'Button text', 'ananya' ),
'section' => 'ananya_frontpage_header_type_section',
'type' => 'text',
'priority' => 4,
) );
$wp_customize->add_setting( 'ananya_header_button_url', array(
'capability' => 'edit_theme_options',
'default' => '#',
'sanitize_callback' => 'esc_url_raw',
) );
$wp_customize->add_control( 'ananya_header_button_url',array(
'label' => __( 'Button URL', 'ananya' ),
'section' => 'ananya_frontpage_header_type_section',
'type' => 'text',
'priority' => 5,
) );
// ===================================================
// = Move Header Image Section To Header Section Panel =
// ===================================================
$wp_customize->get_section( 'header_image' )->panel = 'header_section_panel';
// =============================
// = Hero Media Overlay Options =
// =============================
$wp_customize->add_section( 'ananya_header_overlay_type_section', array(
'title' => __( 'Header Media OVerlay', 'ananya' ),
'panel' => 'header_section_panel',
'priority' => 61,
'capability' => 'edit_theme_options',
) );
$wp_customize->add_setting( 'ananya_header_overlay_type', array(
'type' => 'theme_mod',
'capability' => 'edit_theme_options',
'default' => 'default',
'sanitize_callback' => 'ananya_sanitize_radio',
) );
$wp_customize->add_control( 'ananya_header_overlay_type', array(
'type' => 'radio',
'priority' => 1,
'section' => 'ananya_header_overlay_type_section',
'label' => __( 'Header Overlay Type', 'ananya' ),
'settings' => 'ananya_header_overlay_type',
'choices' => array(
'default' => __( 'Default', 'ananya'),
'color' => __( 'Dark Color', 'ananya'),
'no_overlay' => __( 'No Overlay', 'ananya'),
),
) );
}
add_action( 'customize_register', 'ananya_custom_hero_section_setup' );
/**
* Returns true if header media type is image.
* @since 1.0.0
*/
function ananya_is_header_media_image( $control ) {
if ( 'image' === $control->manager->get_setting( 'ananya_frontpage_header_type' )->value() ) {
return true;
} else {
return false;
}
}