* * @link https://developer.wordpress.org/themes/functionality/custom-headers/ * * @package Ananya * @since 1.0 */ /** * Set up the WordPress core custom header feature. * * @uses ananya_header_style() */ function ananya_custom_header_setup() { add_theme_support( 'custom-header', apply_filters( 'ananya_custom_header_args', array( 'default-image' => get_parent_theme_file_uri( '/assets/images/header.jpg' ), 'header-text' => false, 'default-text-color' => '000000', 'width' => 2000, 'height' => 1000, 'flex-height' => true, 'flex-width' => true, 'video' => true, 'wp-head-callback' => 'ananya_header_style', ) ) ); register_default_headers( array( 'default-image' => array( 'url' => '%s/assets/images/header.jpg', 'thumbnail_url' => '%s/assets/images/header.jpg', 'description' => __( 'Default Header Image', 'ananya' ), ), ) ); } add_action( 'after_setup_theme', 'ananya_custom_header_setup' ); /** * Customizer setting to dispaly full screen header video/image on the front page. * * @since 1.0.0 */ function ananya_custom_header_image_height_setup( $wp_customize ) { $wp_customize->add_setting( 'ananya_full_screen_header_image_setting', array( 'capability' => 'edit_theme_options', 'default' => true, 'transport' => 'refresh', 'sanitize_callback' => 'ananya_sanitize_checkbox', ) ); $wp_customize->add_control( 'ananya_full_screen_header_image_setting', array( 'type' => 'checkbox', 'priority' => 1, 'section' => 'header_image', 'label' => __( 'Full screen header', 'ananya' ), 'description' => __('(Select the checkbox if you want full screen header video/image on the frontpage/homepage of your website.)', 'ananya'), 'settings' => 'ananya_full_screen_header_image_setting', ) ); } add_action( 'customize_register', 'ananya_custom_header_image_height_setup' ); /** * Customizer setting to dispaly header image on other pages. * * @since 1.0.0 */ function ananya_custom_header_media_appearance_setup( $wp_customize ) { $wp_customize->add_setting( 'ananya_use_header_image_only_on_front_page_setting', array( 'capability' => 'edit_theme_options', 'default' => false, 'transport' => 'refresh', 'sanitize_callback' => 'ananya_sanitize_checkbox', ) ); $wp_customize->add_control( 'ananya_use_header_image_only_on_front_page_setting', array( 'type' => 'checkbox', 'priority' => 2, 'section' => 'header_image', 'label' => __( 'Use selected header image only on frontpage/homepage. ', 'ananya' ), 'description' => __('(Select the checkbox if you do not want to use the header image on single post pages and other pages.)', 'ananya'), 'settings' => 'ananya_use_header_image_only_on_front_page_setting', ) ); } add_action( 'customize_register', 'ananya_custom_header_media_appearance_setup' );