3 * Customize Section Class.
6 * @subpackage Customize
9 class WP_Customize_Section {
12 public $priority = 10;
13 public $capability = 'edit_theme_options';
14 public $theme_supports = '';
16 public $description = '';
24 * @param WP_Customize_Manager $manager
25 * @param string $id An specific ID of the section.
26 * @param array $args Section arguments.
28 function __construct( $manager, $id, $args = array() ) {
29 $keys = array_keys( get_class_vars( __CLASS__ ) );
30 foreach ( $keys as $key ) {
31 if ( isset( $args[ $key ] ) )
32 $this->$key = $args[ $key ];
35 $this->manager = $manager;
38 $this->controls = array(); // Users cannot customize the $controls array.
44 * Check if the theme supports the section and check user capabilities.
48 * @return bool False if theme doesn't support the section or user doesn't have the capability.
50 public final function check_capabilities() {
51 if ( $this->capability && ! call_user_func_array( 'current_user_can', (array) $this->capability ) )
54 if ( $this->theme_supports && ! call_user_func_array( 'current_theme_supports', (array) $this->theme_supports ) )
61 * Check capabilities and render the section.
65 public final function maybe_render() {
66 if ( ! $this->check_capabilities() )
69 do_action( 'customize_render_section', $this );
70 do_action( 'customize_render_section_' . $this->id );
80 protected function render() {
82 <li id="accordion-section-<?php echo esc_attr( $this->id ); ?>" class="control-section accordion-section">
83 <h3 class="accordion-section-title" tabindex="0" title="<?php echo esc_attr( $this->description ); ?>"><?php echo esc_html( $this->title ); ?></h3>
84 <ul class="accordion-section-content">
86 foreach ( $this->controls as $control )
87 $control->maybe_render();