PluginProbe
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits / 3.1.9
Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits v3.1.9
3.2.2 3.2.3 3.2.1 3.2.0 3.1.9 3.1.8 3.1.7 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.9 trunk 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.3 1.1.4 1.1.5 All 174 releases
master-addons / inc / admin / widget-builder / controls / number.php

number.php in Master Addons for Elementor – Elementor Addons, Widgets, Mega Menu Builder, Popup Builder, Widget Builder & Template Kits 3.1.9, at inc/admin/widget-builder/controls/number.php

91 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace MasterAddons\Inc\Admin\WidgetBuilder\Controls;
3
4 use MasterAddons\Inc\Admin\WidgetBuilder\Controls\Control_Base;
5
6 defined('ABSPATH') || exit;
7
8 /**
9 * NUMBER Control
10 * Handles Elementor NUMBER control type
11 *
12 * Supported properties:
13 * - label: Control label
14 * - type: NUMBER
15 * - default: Default value
16 * - placeholder: Placeholder text
17 * - min: Minimum value
18 * - max: Maximum value
19 * - step: Step increment
20 * - description: Description below field
21 * - show_label: Show/hide label
22 * - label_block: Display label on separate line
23 * - separator: Control separator position
24 */
25 class Number extends Control_Base {
26
27 public function get_type() {
28 return 'NUMBER';
29 }
30
31 public function build($control_key, $field) {
32 $label = !empty($field['label']) ? $field['label'] : 'Number';
33
34 // Check if responsive control
35 $is_responsive = isset($field['responsive']) && $field['responsive'];
36
37 $content = $this->build_control_header($control_key, $label, 'NUMBER', $is_responsive);
38
39 // Add NUMBER-specific properties first
40 $content .= $this->build_number_properties($field);
41
42 // Add common properties
43 $content .= $this->build_common_properties($field);
44
45 $content .= $this->build_control_footer();
46
47 return $content;
48 }
49
50 /**
51 * Build NUMBER-specific properties
52 *
53 * @param array $field Field configuration
54 * @return string
55 */
56 protected function build_number_properties($field) {
57 $content = '';
58
59 // Min value - only add if not empty and not null
60 if (isset($field['min']) && $field['min'] !== '' && $field['min'] !== null) {
61 $content .= $this->format_number_property('min', $field['min']);
62 }
63
64 // Max value - only add if not empty and not null
65 if (isset($field['max']) && $field['max'] !== '' && $field['max'] !== null) {
66 $content .= $this->format_number_property('max', $field['max']);
67 }
68
69 // Step value - only add if not empty and not null
70 if (isset($field['step']) && $field['step'] !== '' && $field['step'] !== null) {
71 $content .= $this->format_number_property('step', $field['step']);
72 }
73
74 return $content;
75 }
76
77 protected function default_label() {
78 return 'Number';
79 }
80
81 protected function get_type_specific_config($field) {
82 $config = [];
83 foreach (['min', 'max', 'step'] as $prop) {
84 if (isset($field[$prop]) && $field[$prop] !== '' && $field[$prop] !== null) {
85 $config[$prop] = is_numeric($field[$prop]) ? $field[$prop] + 0 : $field[$prop];
86 }
87 }
88 return $config;
89 }
90 }
91