PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 0.0.12
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v0.0.12
2.12.8 2.12.7 2.12.6 2.12.5 2.12.4 2.12.3 2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 All 98 releases
sureforms / inc / fields / dropdown-markup.php

dropdown-markup.php in SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz 0.0.12, at inc/fields/dropdown-markup.php

106 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Sureforms Dropdown Markup Class file.
4 *
5 * @package sureforms.
6 * @since 0.0.1
7 */
8
9 namespace SRFM\Inc\Fields;
10
11 require SRFM_DIR . 'modules/gutenberg/classes/class-spec-gb-helper.php';
12 use Spec_Gb_Helper;
13 use SRFM\Inc\Helper;
14
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit; // Exit if accessed directly.
17 }
18
19 /**
20 * Sureforms Dropdown Markup Class.
21 *
22 * @since 0.0.1
23 */
24 class Dropdown_Markup extends Base {
25
26 /**
27 * Stores the multi select attribute value.
28 *
29 * @var string
30 * @since 0.0.7
31 */
32 protected $multi_select_attr;
33
34 /**
35 * Stores the search attribute value.
36 *
37 * @var string
38 * @since 0.0.7
39 */
40 protected $search_attr;
41
42 /**
43 * Initialize the properties based on block attributes.
44 *
45 * @param array<mixed> $attributes Block attributes.
46 * @since 0.0.2
47 */
48 public function __construct( $attributes ) {
49 $this->set_properties( $attributes );
50 $this->set_input_label( __( 'Dropdown', 'sureforms' ) );
51 $this->set_error_msg( $attributes, 'srfm_dropdown_block_required_text' );
52 $this->slug = 'dropdown';
53 $this->multi_select_attr = ! empty( $attributes['multiSelect'] ) ? 'true' : 'false';
54 $this->search_attr = ! empty( $attributes['searchable'] ) ? 'true' : 'false';
55 $this->set_markup_properties();
56 $this->set_aria_described_by();
57 $this->set_label_as_placeholder( $this->input_label );
58 $this->placeholder = ! empty( $this->placeholder_attr ) ? $this->label : __( 'Select an option', 'sureforms' );
59
60 }
61
62 /**
63 * Render the sureforms dropdown classic styling
64 *
65 * @since 0.0.2
66 * @return string|boolean
67 */
68 public function markup() {
69 ob_start(); ?>
70 <div data-block-id="<?php echo esc_attr( $this->block_id ); ?>" class="srfm-block-single srfm-block srfm-<?php echo esc_attr( $this->slug ); ?>-block srf-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?>-block<?php echo esc_attr( $this->block_width ); ?><?php echo esc_attr( $this->class_name ); ?> <?php echo esc_attr( $this->conditional_class ); ?>">
71 <fieldset>
72 <input class="srfm-input-<?php echo esc_attr( $this->slug ); ?>-hidden" aria-required="<?php echo esc_attr( $this->aria_require_attr ); ?>" name="srfm-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?><?php echo esc_attr( $this->field_name ); ?>" type="hidden" value=""/>
73 <legend>
74 <?php echo wp_kses_post( $this->label_markup ); ?>
75 <?php echo wp_kses_post( $this->help_markup ); ?>
76 </legend>
77 <div class="srfm-block-wrap srfm-dropdown-common-wrap">
78 <?php
79 if ( is_array( $this->options ) ) {
80 ?>
81 <select class="srfm-dropdown-common srfm-<?php echo esc_attr( $this->slug ); ?>-input"
82 <?php echo ! empty( $this->aria_described_by ) ? "aria-describedby='" . esc_attr( trim( $this->aria_described_by ) ) . "'" : ''; ?>
83 aria-required="<?php echo esc_attr( $this->aria_require_attr ); ?>" name="srfm-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?><?php echo esc_attr( $this->field_name ); ?>" data-multiple="<?php echo esc_attr( $this->multi_select_attr ); ?>" data-searchable="<?php echo esc_attr( $this->search_attr ); ?>" tabindex="0" aria-hidden="true">
84 <option class="srfm-dropdown-placeholder" value="" disabled selected><?php echo esc_html( $this->placeholder ); ?></option>
85 <?php foreach ( $this->options as $option ) { ?>
86 <?php
87 $icon_svg = Spec_Gb_Helper::render_svg_html( isset( $option['icon'] ) ? $option['icon'] : '', true );
88 $escaped_icon_svg = htmlspecialchars( Helper::get_string_value( $icon_svg ), ENT_QUOTES, 'UTF-8' );
89 ?>
90 <option value="<?php echo isset( $option['label'] ) ? esc_html( $option['label'] ) : ''; ?>" data-icon="<?php echo ! empty( $escaped_icon_svg ) ? esc_attr( $escaped_icon_svg ) : ''; ?>"><?php echo isset( $option['label'] ) ? esc_html( $option['label'] ) : ''; ?></option>
91 <?php
92 }
93 ?>
94 </select>
95 <?php } ?>
96 </div>
97 <div class="srfm-error-wrap">
98 <?php echo wp_kses_post( $this->error_msg_markup ); ?>
99 </div>
100 </fieldset>
101 </div>
102 <?php
103 return ob_get_clean();
104 }
105 }
106