Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Customizer Add New Panel
<?php
add_action( 'customize_register', 'bt_register_theme_customizer', 20 );
/**
* Add new panel
* Register for the Customizer
* @since 1.0.0
*/
function bt_register_theme_customizer( $wp_customize ) {
global $wp_customize;
/**
* Create custom panel
* Create Custom Section
* Add setting
* Add control
* Also can be done with FLCustomizer::add_panel - see example commented further down
* @since 1.0.0
*/
// Add Panel
$wp_customize->add_panel( 'featured_images', array(
'priority' => 70,
'theme_supports' => '',
'title' => __( 'Featured Images', 'beavertron' ),
'description' => __( 'Set background images for certain widgets.', 'beavertron' ),
) );
// Add Featured Image for Hero Widget
// Add section.
$wp_customize->add_section( 'hero_background' , array(
'title' => __( 'Hero Background','beavertron' ),
'panel' => 'featured_images',
'priority' => 20,
) );
// Add setting.
$wp_customize->add_setting( 'hero_bg', array(
//'default' => get_stylesheet_directory_uri() . '/images/hero-bg.jpg',
) );
// Add control.
$wp_customize->add_control( new WP_Customize_Image_Control(
$wp_customize, 'hero_background_image', array(
'label' => __( 'Add Hero Background Here, the width should be approx 1400px', 'beavertron' ),
'section' => 'hero_background',
'settings' => 'hero_bg',
)
) );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment