PluginProbe ʕ •ᴥ•ʔ
SureForms – Drag & Drop Contact Form & Form Builder, Payment Form, Survey, Quiz & Calculator / 2.12.1
SureForms – Drag & Drop Contact Form & Form Builder, Payment Form, Survey, Quiz & Calculator v2.12.1
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 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 0.0.8 0.0.9 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.0 1.1.1 1.1.2 1.10.0 1.10.1 1.11.0 1.12.0 1.12.1 1.12.2 1.12.3 1.13.0 1.13.1 1.13.2 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.8.0 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.2 2.6.0
sureforms / inc / fields / number-markup.php
sureforms / inc / fields Last commit date
address-markup.php 1 month ago base.php 2 months ago checkbox-markup.php 1 year ago countries.json 1 year ago dropdown-markup.php 1 month ago email-markup.php 2 months ago gdpr-markup.php 4 months ago inlinebutton-markup.php 4 weeks ago input-markup.php 4 months ago multichoice-markup.php 1 month ago number-markup.php 4 months ago payment-markup.php 2 months ago phone-markup.php 1 month ago textarea-markup.php 1 month ago url-markup.php 4 months ago
number-markup.php
156 lines
1 <?php
2 /**
3 * Sureforms Number Markup Class file.
4 *
5 * @package sureforms.
6 * @since 0.0.1
7 */
8
9 namespace SRFM\Inc\Fields;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 /**
16 * Sureforms Number Field Markup Class.
17 *
18 * @since 0.0.1
19 */
20 class Number_Markup extends Base {
21 /**
22 * Minimum value allowed for the input field.
23 *
24 * @var string
25 * @since 0.0.2
26 */
27 protected $min_value;
28
29 /**
30 * Maximum value allowed for the input field.
31 *
32 * @var string
33 * @since 0.0.2
34 */
35 protected $max_value;
36
37 /**
38 * Format type for the input field.
39 *
40 * @var string
41 * @since 0.0.2
42 */
43 protected $format_type;
44
45 /**
46 * HTML attribute string for the format type.
47 *
48 * @var string
49 * @since 0.0.2
50 */
51 protected $format_attr;
52
53 /**
54 * HTML attribute string for the minimum value.
55 *
56 * @var string
57 * @since 0.0.2
58 */
59 protected $min_value_attr;
60
61 /**
62 * HTML attribute string for the maximum value.
63 *
64 * @var string
65 * @since 0.0.2
66 */
67 protected $max_value_attr;
68
69 /**
70 * Prefix for the input field.
71 *
72 * @var string
73 * @since 1.5.0
74 */
75 protected $prefix;
76
77 /**
78 * Suffix for the input field.
79 *
80 * @var string
81 * @since 1.5.0
82 */
83 protected $suffix;
84
85 /**
86 * Read-only attribute for the number field.
87 *
88 * @var bool
89 * @since 1.7.2
90 */
91 protected $read_only;
92
93 /**
94 * Initialize the properties based on block attributes.
95 *
96 * @param array<mixed> $attributes Block attributes.
97 * @since 0.0.2
98 */
99 public function __construct( $attributes ) {
100 $this->slug = 'number';
101 $this->set_properties( $attributes );
102 $this->min_value = $attributes['minValue'] ?? '';
103 $this->max_value = $attributes['maxValue'] ?? '';
104 $this->format_type = $attributes['formatType'] ?? '';
105 $this->format_attr = $this->format_type ? ' format-type="' . esc_attr( $this->format_type ) . '" ' : '';
106 $this->min_value_attr = $this->min_value ? ' min="' . esc_attr( $this->min_value ) . '" ' : '';
107 $this->max_value_attr = $this->max_value ? ' max="' . esc_attr( $this->max_value ) . '" ' : '';
108 $this->prefix = $attributes['prefix'] ?? '';
109 $this->suffix = $attributes['suffix'] ?? '';
110 $this->read_only = ! empty( trim( $this->default ) ) && $attributes['readOnly'];
111 $this->set_input_label( __( 'Number', 'sureforms' ) );
112 $this->set_error_msg( $attributes, 'srfm_number_block_required_text' );
113 $this->set_unique_slug();
114 $this->set_field_name( $this->unique_slug );
115 $this->set_markup_properties( $this->input_label );
116 $this->set_aria_described_by();
117 $this->set_label_as_placeholder( $this->input_label );
118 }
119
120 /**
121 * Render the sureforms number classic styling
122 *
123 * @since 0.0.2
124 * @return string|bool
125 */
126 public function markup() {
127 $data_config = $this->field_config;
128 $this->class_name = $this->get_field_classes( $this->read_only ? [ 'srfm-read-only' ] : [] );
129
130 ob_start(); ?>
131 <div data-block-id="<?php echo esc_attr( $this->block_id ); ?>" class="<?php echo esc_attr( $this->class_name ); ?>" <?php echo $data_config ? "data-field-config='" . esc_attr( $data_config ) . "'" : ''; ?>>
132 <?php echo wp_kses_post( $this->label_markup ); ?>
133 <?php echo wp_kses_post( $this->help_markup ); ?>
134 <div class="srfm-block-wrap">
135 <div class="srfm-input-content">
136 <?php if ( ! empty( $this->prefix ) ) { ?>
137 <span class="srfm-number-prefix" aria-hidden="true"><?php echo esc_html( $this->prefix ); ?></span>
138 <?php } ?>
139 <input class="srfm-input-common srfm-input-<?php echo esc_attr( $this->slug ); ?>" type="text" name="<?php echo esc_attr( $this->field_name ); ?>" id="<?php echo esc_attr( $this->unique_slug ); ?>"
140 <?php echo ! empty( $this->aria_described_by ) ? "aria-describedby='" . esc_attr( trim( $this->aria_described_by ) ) . "'" : ''; ?>
141 data-required="<?php echo esc_attr( $this->data_require_attr ); ?>" aria-required="<?php echo esc_attr( $this->data_require_attr ); ?>" <?php echo wp_kses_post( $this->placeholder_attr . '' . $this->default_value_attr . '' . $this->format_attr . '' . $this->min_value_attr . '' . $this->max_value_attr ); ?> <?php echo $this->read_only ? 'readonly' : ''; ?> />
142 <?php if ( ! empty( $this->suffix ) ) { ?>
143 <span class="srfm-number-suffix" aria-hidden="true"><?php echo esc_html( $this->suffix ); ?></span>
144 <?php } ?>
145 </div>
146 </div>
147 <div class="srfm-error-wrap">
148 <?php echo wp_kses_post( $this->error_msg_markup ); ?>
149 </div>
150 </div>
151 <?php
152 return ob_get_clean();
153 }
154
155 }
156