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 = 160;
41 * Panel in which to show the section, making it a sub-section.
50 * Capability required for the section.
56 public $capability = 'edit_theme_options';
59 * Theme feature support for the section.
65 public $theme_supports = '';
68 * Title of the section to show in UI.
77 * Description to show in the UI.
83 public $description = '';
86 * Customizer controls for this section.
97 * Any supplied $args override class property defaults.
101 * @param WP_Customize_Manager $manager Customizer bootstrap instance.
102 * @param string $id An specific ID of the section.
103 * @param array $args Section arguments.
105 public function __construct( $manager, $id, $args = array() ) {
106 $keys = array_keys( get_object_vars( $this ) );
107 foreach ( $keys as $key ) {
108 if ( isset( $args[ $key ] ) )
109 $this->$key = $args[ $key ];
112 $this->manager = $manager;
115 $this->controls = array(); // Users cannot customize the $controls array.
121 * Checks required user capabilities and whether the theme has the
122 * feature support required by the section.
126 * @return bool False if theme doesn't support the section or user doesn't have the capability.
128 public final function check_capabilities() {
129 if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) )
132 if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) )
139 * Check capabilities and render the section.
143 public final function maybe_render() {
144 if ( ! $this->check_capabilities() )
148 * Fires before rendering a Customizer section.
152 * @param WP_Customize_Section $this WP_Customize_Section instance.
154 do_action( 'customize_render_section', $this );
156 * Fires before rendering a specific Customizer section.
158 * The dynamic portion of the hook name, $this->id, refers to the ID
159 * of the specific Customizer section to be rendered.
163 do_action( "customize_render_section_{$this->id}" );
169 * Render the section, and the controls that have been added to it.
173 protected function render() {
174 $classes = 'control-section accordion-section';
175 if ( $this->panel ) {
176 $classes .= ' control-subsection';
179 <li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="<?php echo esc_attr( $classes ); ?>">
180 <h3 class="accordion-section-title" tabindex="0">
181 <?php echo esc_html( $this->title ); ?>
182 <span class="screen-reader-text"><?php _e( 'Press return or enter to expand' ); ?></span>
184 <ul class="accordion-section-content">
185 <?php if ( ! empty( $this->description ) ) : ?>
186 <li><p class="description customize-section-description"><?php echo $this->description; ?></p></li>
189 foreach ( $this->controls as $control )
190 $control->maybe_render();