layers_customizer_sections
This filter allows modification of the sections() array, which outputs the Customizer Sections for Layers, such as Site Settings, Header, Footer etc.
Location
/core/customizer/config.php
Usage
1 |
add_filter('layers_customizer_sections','layers_child_customizer_sections', 100); |
In most cases, the core panels should not be removed from a child theme or extension, but you may want to filter them to add additional sections, or add conditions on custom sites, such as hiding all but the Colors for users with a certain role or capability.
Adding a Custom Section
Each section should define a title and the panel it will be added to. This example shows how you would add a custom section called Social Media Profiles to a custom panel called theme-options (Theme Options)
1 2 3 4 5 6 7 8 9 |
if( !function_exists( 'child_customizer_sections' ) ) { function child_customizer_sections( $sections ){ $sections[ 'header-social-media' ] = array( 'title' => __( 'Social Media Profiles' , 'child' ), 'panel' => 'theme-options', ); return $sections; } } |
Adding Sections to Existing Panels
This example shows how you would add a custom section called Social Media Profiles to the existing Header (header) panel in Layers. The primary difference here is the array_merge which takes your section and merges it with the existing ones. You must merge on existing panels, whereas you don’t if using a custom panel.
1 2 3 4 5 6 7 8 9 10 11 |
if( !function_exists( 'child_customizer_sections' ) ) { function child_customizer_sections( $sections ){ $sections[ 'header-social-media' ] = array( 'title' => __( 'Social Media Profiles' , 'layerswp' ), 'panel' => 'header', ); $sections = array_merge( $sections, $sections[ 'header-social-media' ] ); return $sections; } } |
See How to Add Customizer Sections & Controls
To add Customizer Options using the WordPress Core API, go here