# charitable/1.8.11.3/includes/admin/customizer/controls/class-charitable-customize-select-sections-control.php

Charitable – Donation &amp; Fundraising Platform (Donation Forms, Recurring Donations &amp; Fundraising Campaigns), version 1.8.11.3. 85 lines.

- Page: https://pluginprobe.com/plugins/charitable/1.8.11.3/code/includes/admin/customizer/controls/class-charitable-customize-select-sections-control.php
- Raw: https://pluginprobe.com/plugins/charitable/1.8.11.3/raw/includes/admin/customizer/controls/class-charitable-customize-select-sections-control.php
- Modified: 2025-02-20T16:43:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/charitable/1.8.11.3/code/includes/admin/customizer/controls/class-charitable-customize-select-sections-control.php#L10-L20`.

```php
<?php
/**
 * Add Select Sections control.
 *
 * @package   Charitable/Classes/Charitable_Customize_Select_Sections_Control
 * @author    David Bisset
 * @copyright Copyright (c) 2023, WP Charitable LLC
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU Public License
 * @since     1.6.5
 * @version   1.6.5
 */

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

if ( ! class_exists( 'Charitable_Customize_Select_Sections_Control' ) ) :

	/**
	 * Select Sections customizer control class.
	 *
	 * @since 1.6.5
	 */
	class Charitable_Customize_Select_Sections_Control extends WP_Customize_Control {

		/**
		 * The control type.
		 *
		 * @since 1.6.5
		 *
		 * @var   string
		 */
		public $type = 'select_sections';

		/**
		 * Render the control's content.
		 *
		 * @since  1.6.5
		 *
		 * @return void
		 */
		public function render_content() {
			if ( empty( $this->choices ) ) {
				return;
			}

			$input_id         = '_customize-input-' . $this->id;
			$description_id   = '_customize-description-' . $this->id;
			$describedby_attr = ( ! empty( $this->description ) ) ? ' aria-describedby="' . esc_attr( $description_id ) . '" ' : '';
			$output           = '';

			if ( ! empty( $this->label ) ) {
				$output .= '<label for="' . esc_attr( $input_id ) . '" class="customize-control-title">' . esc_html( $this->label ) . '</label>';
			}

			if ( ! empty( $this->description ) ) {
				$output .= '<span id="' . esc_attr( $description_id ) . '" class="description customize-control-description">' . $this->description . '</span>';
			}

			$output .= '<select id="' . esc_attr( $input_id ) . '" ' . $describedby_attr . ' ' . $this->get_link() . '>';

			foreach ( $this->choices as $section => $option ) {
				if ( ! is_array( $option ) ) {
					$output .= '<option value="' . esc_attr( $section ) . '"' . selected( $this->value(), $section, false ) . '>' . $option . '</option>';
				} else {
					$label   = array_key_exists( 'label', $option ) ? $option['label'] : '';
					$output .= '<optgroup label="' . $label . '">';

					foreach ( $option['options'] as $key => $opt ) {
						$output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $this->value(), $key ) . '>' . $opt . '</option>';
					}

					$output .= '</optgroup>';
				}
			}

			$output .= '</select>';

			echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
		}
	}

endif;

```
