PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.11.3
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.11.3
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / includes / admin / customizer / controls / class-charitable-customize-select-sections-control.php

class-charitable-customize-select-sections-control.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.11.3, at includes/admin/customizer/controls/class-charitable-customize-select-sections-control.php

85 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Add Select Sections control.
4 *
5 * @package Charitable/Classes/Charitable_Customize_Select_Sections_Control
6 * @author David Bisset
7 * @copyright Copyright (c) 2023, WP Charitable LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.6.5
10 * @version 1.6.5
11 */
12
13 // Exit if accessed directly.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 if ( ! class_exists( 'Charitable_Customize_Select_Sections_Control' ) ) :
19
20 /**
21 * Select Sections customizer control class.
22 *
23 * @since 1.6.5
24 */
25 class Charitable_Customize_Select_Sections_Control extends WP_Customize_Control {
26
27 /**
28 * The control type.
29 *
30 * @since 1.6.5
31 *
32 * @var string
33 */
34 public $type = 'select_sections';
35
36 /**
37 * Render the control's content.
38 *
39 * @since 1.6.5
40 *
41 * @return void
42 */
43 public function render_content() {
44 if ( empty( $this->choices ) ) {
45 return;
46 }
47
48 $input_id = '_customize-input-' . $this->id;
49 $description_id = '_customize-description-' . $this->id;
50 $describedby_attr = ( ! empty( $this->description ) ) ? ' aria-describedby="' . esc_attr( $description_id ) . '" ' : '';
51 $output = '';
52
53 if ( ! empty( $this->label ) ) {
54 $output .= '<label for="' . esc_attr( $input_id ) . '" class="customize-control-title">' . esc_html( $this->label ) . '</label>';
55 }
56
57 if ( ! empty( $this->description ) ) {
58 $output .= '<span id="' . esc_attr( $description_id ) . '" class="description customize-control-description">' . $this->description . '</span>';
59 }
60
61 $output .= '<select id="' . esc_attr( $input_id ) . '" ' . $describedby_attr . ' ' . $this->get_link() . '>';
62
63 foreach ( $this->choices as $section => $option ) {
64 if ( ! is_array( $option ) ) {
65 $output .= '<option value="' . esc_attr( $section ) . '"' . selected( $this->value(), $section, false ) . '>' . $option . '</option>';
66 } else {
67 $label = array_key_exists( 'label', $option ) ? $option['label'] : '';
68 $output .= '<optgroup label="' . $label . '">';
69
70 foreach ( $option['options'] as $key => $opt ) {
71 $output .= '<option value="' . esc_attr( $key ) . '" ' . selected( $this->value(), $key ) . '>' . $opt . '</option>';
72 }
73
74 $output .= '</optgroup>';
75 }
76 }
77
78 $output .= '</select>';
79
80 echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
81 }
82 }
83
84 endif;
85