Hi there!
Just wanted to find out if Wordpress Customizer panels can be created in Pinegrow, or if there are other methods for grouping related sections.
Also, do we have any detailed tutorials on how to use customizer controls and conditionals?
Would really appreciate a response on this.
You can easily add as many panels as you want/need into your custom themes with a few lines of code. Then from Pinegrow, you will just have to specify the panel name in your customizer settings.
Here is a code sample that you can add in your custom.php file (or directly in functions.php).
Don’t forget to replace all the st2 items with your own theme slug.
/**
* Customizer: Add Panels
* This file demonstrates how to add Panels to the Customizer.
* @package code-examples
* @copyright Copyright (c) 2015, WordPress Theme Review Team
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License, v2 (or newer)
*/
/**
* Theme Options Customizer Implementation.
* Implement the Theme Customizer for Theme Settings.
* @link http://ottopress.com/2012/how-to-leverage-the-theme-customizer-in-your-own-themes/
* @param WP_Customize_Manager $wp_customize Object that holds the customizer data.
*/
function st2_register_customizer_panels( $wp_customize ){
/*
* Failsafe is safe
*/
if ( ! isset( $wp_customize ) ) {
return;
}
/**
* Add Panel for General Settings.
* @uses $wp_customize->add_panel() https://developer.wordpress.org/reference/classes/wp_customize_manager/add_panel/
* @link $wp_customize->add_panel() https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_panel
*/
$wp_customize->add_panel(
// $id
'st2_panel_general',
// $args
array(
'priority' => 10,
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => __( 'ST2 General Settings', 'st2' ),
'description' => __( 'Configure general settings for the Theme Name Theme', 'st2' ),
)
);
}
// Settings API options initilization and validation
add_action( 'customize_register', 'st2_register_customizer_panels' );