3 * Customize Section Class.
5 * A UI container for controls, managed by the WP_Customize_Manager.
8 * @subpackage Customize
11 class WP_Customize_Section {
14 * WP_Customize_Manager instance.
18 * @var WP_Customize_Manager
32 * Priority of the section which informs load order of sections.
38 public $priority = 10;
41 * Capability required for the section.
47 public $capability = 'edit_theme_options';
50 * Theme feature support for the section.
56 public $theme_supports = '';
59 * Title of the section to show in UI.
68 * Description to show in the UI.
74 public $description = '';
77 * Customizer controls for this section.
88 * Any supplied $args override class property defaults.
92 * @param WP_Customize_Manager $manager Customizer bootstrap instance.
93 * @param string $id An specific ID of the section.
94 * @param array $args Section arguments.
96 function __construct( $manager, $id, $args = array() ) {
97 $keys = array_keys( get_class_vars( __CLASS__ ) );
98 foreach ( $keys as $key ) {
99 if ( isset( $args[ $key ] ) )
100 $this->$key = $args[ $key ];
103 $this->manager = $manager;
106 $this->controls = array(); // Users cannot customize the $controls array.
112 * Checks required user capabilities and whether the theme has the
113 * feature support required by the section.
117 * @return bool False if theme doesn't support the section or user doesn't have the capability.
119 public final function check_capabilities() {
120 if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) )
123 if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) )
130 * Check capabilities and render the section.
134 public final function maybe_render() {
135 if ( ! $this->check_capabilities() )
139 * Fires before rendering a Customizer section.
143 * @param WP_Customize_Section $this WP_Customize_Section instance.
145 do_action( 'customize_render_section', $this );
147 * Fires before rendering a specific Customizer section.
149 * The dynamic portion of the hook name, $this->id, refers to the ID
150 * of the specific Customizer section to be rendered.
154 do_action( "customize_render_section_{$this->id}" );
160 * Render the section, and the controls that have been added to it.
164 protected function render() {
166 <li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="control-section accordion-section">
167 <h3 class="accordion-section-title" tabindex="0"><?php echo esc_html( $this->title ); ?></h3>
168 <ul class="accordion-section-content">
169 <?php if ( ! empty( $this->description ) ) : ?>
170 <li><p class="description"><?php echo $this->description; ?></p></li>
173 foreach ( $this->controls as $control )
174 $control->maybe_render();