WP_Customize_Manager::add_panel PHP Method

add_panel() public method

Add a customize panel.
Since: 4.0.0
Since: 4.5.0 Return added WP_Customize_Panel instance.
public add_panel ( WP_Customize_Panel | string $id, array $args = [] ) : WP_Customize_Panel
$id WP_Customize_Panel | string Customize Panel object, or Panel ID.
$args array Optional. Panel arguments. Default empty array.
return WP_Customize_Panel The instance of the panel that was added.
    public function add_panel($id, $args = array())
    {
        if ($id instanceof WP_Customize_Panel) {
            $panel = $id;
        } else {
            $panel = new WP_Customize_Panel($this, $id, $args);
        }
        $this->panels[$panel->id] = $panel;
        return $panel;
    }

Usage Example

Exemplo n.º 1
1
/**
 * 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 theme_slug_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('theme_slug_panel_general', array('priority' => 10, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('Theme Name General Settings', 'theme-slug'), 'description' => __('Configure general settings for the Theme Name Theme', 'theme-slug')));
    /**
     * Add Panel for Color and Layout 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('theme_slug_panel_colorslayouts', array('priority' => 11, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('Theme Name Colors and Layouts', 'theme-slug'), 'description' => __('Configure color and layout settings for the Theme Name Theme', 'theme-slug')));
    /**
     * Add Panel for Advanced 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('theme_slug_panel_advanced', array('priority' => 12, 'capability' => 'edit_theme_options', 'theme_supports' => '', 'title' => __('Theme Name Advanced Settings', 'theme-slug'), 'description' => __('Configure advanced settings for the Theme Name Theme', 'theme-slug')));
}
All Usage Examples Of WP_Customize_Manager::add_panel
WP_Customize_Manager