PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.0
Elementor Website Builder – more than just a page builder v4.0.0
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
elementor / includes / elements / repeater.php

repeater.php in Elementor Website Builder – more than just a page builder 4.0.0, at includes/elements/repeater.php

158 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly.
6 }
7
8 /**
9 * Elementor repeater element.
10 *
11 * Elementor repeater handler class is responsible for initializing the repeater.
12 *
13 * @since 1.0.0
14 */
15 class Repeater extends Element_Base {
16
17 /**
18 * Repeater counter.
19 *
20 * Holds the Repeater counter data. Default is `0`.
21 *
22 * @since 1.0.0
23 * @access private
24 * @static
25 *
26 * @var int Repeater counter.
27 */
28 private static $counter = 0;
29
30 /**
31 * Holds the count of the CURRENT instance
32 *
33 * @var int
34 */
35 private $id;
36
37 /**
38 * Repeater constructor.
39 *
40 * Initializing Elementor repeater element.
41 *
42 * @since 1.0.7
43 * @access public
44 *
45 * @param array $data Optional. Element data. Default is an empty array.
46 * @param array|null $args Optional. Element default arguments. Default is null.
47 */
48 public function __construct( array $data = [], ?array $args = null ) {
49 ++self::$counter;
50
51 $this->id = self::$counter;
52
53 parent::__construct( $data, $args );
54
55 $this->add_control(
56 '_id',
57 [
58 'type' => Controls_Manager::HIDDEN,
59 ]
60 );
61 }
62
63 /**
64 * Get repeater name.
65 *
66 * Retrieve the repeater name.
67 *
68 * @since 1.0.7
69 * @access public
70 *
71 * @return string Repeater name.
72 */
73 public function get_name() {
74 return 'repeater-' . $this->id;
75 }
76
77 /**
78 * Get repeater type.
79 *
80 * Retrieve the repeater type.
81 *
82 * @since 1.0.0
83 * @access public
84 * @static
85 *
86 * @return string Repeater type.
87 */
88 public static function get_type() {
89 return 'repeater';
90 }
91
92 /**
93 * Add new repeater control to stack.
94 *
95 * Register a repeater control to allow the user to set/update data.
96 *
97 * This method should be used inside `register_controls()`.
98 *
99 * @since 1.0.0
100 * @access public
101 *
102 * @param string $id Repeater control ID.
103 * @param array $args Repeater control arguments.
104 * @param array $options Optional. Repeater control options. Default is an
105 * empty array.
106 *
107 * @return bool True if repeater control added, False otherwise.
108 */
109 public function add_control( $id, array $args, $options = [] ) {
110 $current_tab = $this->get_current_tab();
111
112 if ( null !== $current_tab ) {
113 $args = array_merge( $args, $current_tab );
114 }
115
116 return parent::add_control( $id, $args, $options );
117 }
118
119 /**
120 * Get repeater fields.
121 *
122 * Retrieve the fields from the current repeater control.
123 *
124 * @since 1.5.0
125 * @deprecated 2.1.0 Use `get_controls()` method instead.
126 * @access public
127 *
128 * @return array Repeater fields.
129 */
130 public function get_fields() {
131 _deprecated_function( __METHOD__, '2.1.0', 'get_controls()' );
132
133 return array_values( $this->get_controls() );
134 }
135
136 /**
137 * Get default child type.
138 *
139 * Retrieve the repeater child type based on element data.
140 *
141 * Note that repeater does not support children, therefore it returns false.
142 *
143 * @since 1.0.0
144 * @access protected
145 *
146 * @param array $element_data Element ID.
147 *
148 * @return false Repeater default child type or False if type not found.
149 */
150 protected function _get_default_child_type( array $element_data ) {
151 return false;
152 }
153
154 protected function handle_control_position( array $args, $control_id, $overwrite ) {
155 return $args;
156 }
157 }
158