PluginProbe
Elementor Website Builder – more than just a page builder / 3.18.2
Elementor Website Builder – more than just a page builder v3.18.2
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 3.18.2, at includes/elements/repeater.php

159 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 */
49 public function __construct( array $data = [], array $args = null ) {
50 self::$counter++;
51
52 $this->id = self::$counter;
53
54 parent::__construct( $data, $args );
55
56 $this->add_control(
57 '_id',
58 [
59 'type' => Controls_Manager::HIDDEN,
60 ]
61 );
62 }
63
64 /**
65 * Get repeater name.
66 *
67 * Retrieve the repeater name.
68 *
69 * @since 1.0.7
70 * @access public
71 *
72 * @return string Repeater name.
73 */
74 public function get_name() {
75 return 'repeater-' . $this->id;
76 }
77
78 /**
79 * Get repeater type.
80 *
81 * Retrieve the repeater type.
82 *
83 * @since 1.0.0
84 * @access public
85 * @static
86 *
87 * @return string Repeater type.
88 */
89 public static function get_type() {
90 return 'repeater';
91 }
92
93 /**
94 * Add new repeater control to stack.
95 *
96 * Register a repeater control to allow the user to set/update data.
97 *
98 * This method should be used inside `register_controls()`.
99 *
100 * @since 1.0.0
101 * @access public
102 *
103 * @param string $id Repeater control ID.
104 * @param array $args Repeater control arguments.
105 * @param array $options Optional. Repeater control options. Default is an
106 * empty array.
107 *
108 * @return bool True if repeater control added, False otherwise.
109 */
110 public function add_control( $id, array $args, $options = [] ) {
111 $current_tab = $this->get_current_tab();
112
113 if ( null !== $current_tab ) {
114 $args = array_merge( $args, $current_tab );
115 }
116
117 return parent::add_control( $id, $args, $options );
118 }
119
120 /**
121 * Get repeater fields.
122 *
123 * Retrieve the fields from the current repeater control.
124 *
125 * @since 1.5.0
126 * @deprecated 2.1.0 Use `get_controls()` method instead.
127 * @access public
128 *
129 * @return array Repeater fields.
130 */
131 public function get_fields() {
132 _deprecated_function( __METHOD__, '2.1.0', 'get_controls()' );
133
134 return array_values( $this->get_controls() );
135 }
136
137 /**
138 * Get default child type.
139 *
140 * Retrieve the repeater child type based on element data.
141 *
142 * Note that repeater does not support children, therefore it returns false.
143 *
144 * @since 1.0.0
145 * @access protected
146 *
147 * @param array $element_data Element ID.
148 *
149 * @return false Repeater default child type or False if type not found.
150 */
151 protected function _get_default_child_type( array $element_data ) {
152 return false;
153 }
154
155 protected function handle_control_position( array $args, $control_id, $overwrite ) {
156 return $args;
157 }
158 }
159