/var/www/html/wp-content/plugins/elementor/includes/elements/repeater.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
namespace Elementor;

if ( ! 
defined'ABSPATH' ) ) {
    exit; 
// Exit if accessed directly.
}

/**
 * Elementor repeater element.
 *
 * Elementor repeater handler class is responsible for initializing the repeater.
 *
 * @since 1.0.0
 */
class Repeater extends Element_Base {

    
/**
     * Repeater counter.
     *
     * Holds the Repeater counter data. Default is `0`.
     *
     * @since 1.0.0
     * @access private
     * @static
     *
     * @var int Repeater counter.
     */
    
private static $counter 0;

    
/**
     * Holds the count of the CURRENT instance
     *
     * @var int
     */
    
private $id;

    
/**
     * Repeater constructor.
     *
     * Initializing Elementor repeater element.
     *
     * @since 1.0.7
     * @access public
     *
     * @param array      $data Optional. Element data. Default is an empty array.
     * @param array|null $args Optional. Element default arguments. Default is null.
     *
     */
    
public function __construct( array $data = [], array $args null ) {
        
self::$counter++;

        
$this->id self::$counter;

        
parent::__construct$data$args );

        
$this->add_control(
            
'_id',
            [
                
'type' => Controls_Manager::HIDDEN,
            ]
        );
    }

    
/**
     * Get repeater name.
     *
     * Retrieve the repeater name.
     *
     * @since 1.0.7
     * @access public
     *
     * @return string Repeater name.
     */
    
public function get_name() {
        return 
'repeater-' $this->id;
    }

    
/**
     * Get repeater type.
     *
     * Retrieve the repeater type.
     *
     * @since 1.0.0
     * @access public
     * @static
     *
     * @return string Repeater type.
     */
    
public static function get_type() {
        return 
'repeater';
    }

    
/**
     * Add new repeater control to stack.
     *
     * Register a repeater control to allow the user to set/update data.
     *
     * This method should be used inside `register_controls()`.
     *
     * @since 1.0.0
     * @access public
     *
     * @param string $id      Repeater control ID.
     * @param array  $args    Repeater control arguments.
     * @param array  $options Optional. Repeater control options. Default is an
     *                        empty array.
     *
     * @return bool True if repeater control added, False otherwise.
     */
    
public function add_control$id, array $args$options = [] ) {
        
$current_tab $this->get_current_tab();

        if ( 
null !== $current_tab ) {
            
$args array_merge$args$current_tab );
        }

        return 
parent::add_control$id$args$options );
    }

    
/**
     * Get repeater fields.
     *
     * Retrieve the fields from the current repeater control.
     *
     * @since 1.5.0
     * @deprecated 2.1.0 Use `get_controls()` method instead.
     * @access public
     *
     * @return array Repeater fields.
     */
    
public function get_fields() {
        
_deprecated_function__METHOD__'2.1.0''get_controls()' );

        return 
array_values$this->get_controls() );
    }

    
/**
     * Get default child type.
     *
     * Retrieve the repeater child type based on element data.
     *
     * Note that repeater does not support children, therefore it returns false.
     *
     * @since 1.0.0
     * @access protected
     *
     * @param array $element_data Element ID.
     *
     * @return false Repeater default child type or False if type not found.
     */
    
protected function _get_default_child_type( array $element_data ) {
        return 
false;
    }

    protected function 
handle_control_position( array $args$control_id$overwrite ) {
        return 
$args;
    }
}