Last active
June 12, 2021 02:52
-
-
Save neilgee/3dc24a8108e095e65a5e3e77813960fb to your computer and use it in GitHub Desktop.
Customizer Add New Panel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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