3 * Customize Section Class
6 * @subpackage Customize
10 class WP_Customize_Section {
13 public $priority = 10;
14 public $capability = 'edit_theme_options';
15 public $theme_supports = '';
17 public $description = '';
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 );
81 protected function render() {
83 <li id="customize-section-<?php echo esc_attr( $this->id ); ?>" class="control-section customize-section">
84 <h3 class="customize-section-title" title="<?php echo esc_attr( $this->description ); ?>"><?php echo esc_html( $this->title ); ?></h3>
85 <ul class="customize-section-content">
87 foreach ( $this->controls as $control )
88 $control->maybe_render();