/
jet-engine-repeater-dynamic-tag-image.php
115 lines (103 loc) · 2.33 KB
/
jet-engine-repeater-dynamic-tag-image.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
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor Dynamic Tag - Server Variable
*
* Elementor dynamic tag that returns a server variable.
*
* @since 1.1.0
*/
Class Elementor_Dynamic_Tag_Jet_Engine_Repeater_Image extends \Elementor\Core\DynamicTags\Data_Tag {
/**
* Get dynamic tag name.
*
* Retrieve the name of the tag.
*
* @since 1.1.0
* @access public
* @return string Dynamic tag name.
*/
public function get_name() {
return 'runthings-jetengine-repeater-value-image';
}
/**
* Get dynamic tag title.
*
* Returns the title of the tag.
*
* @since 1.1.0
* @access public
* @return string Dynamic tag title.
*/
public function get_title() {
return esc_html__( 'JetEngine Repeater Field (Image, Media)', 'jet-engine-repeater-values' );
}
/**
* Get dynamic tag groups.
*
* Retrieve the list of groups the tag belongs to.
*
* @since 1.1.0
* @access public
* @return array Dynamic tag groups.
*/
public function get_group() {
return [ 'runthings' ];
}
/**
* Get dynamic tag categories.
*
* Retrieve the list of categories the tag belongs to.
*
* @since 1.1.0
* @access public
* @return array Dynamic tag categories.
*/
public function get_categories() {
return [
\Elementor\Modules\DynamicTags\Module::IMAGE_CATEGORY,
\Elementor\Modules\DynamicTags\Module::MEDIA_CATEGORY,
];
}
/**
* Register dynamic tag controls.
*
* Add input fields to allow the user to customize the tag settings.
*
* @since 1.1.0
* @access protected
* @return void
*/
protected function register_controls() {
$this->add_control(
'repeater_key',
[
'type' => \Elementor\Controls_Manager::TEXT,
'label' => esc_html__( 'Repeater Key', 'jet-engine-repeater-values' ),
]
);
}
/**
* Return the value
*
* @since 1.1.0
* @access public
* @return void
*/
public function get_value( array $options = [] ) {
$field = $this->get_settings( 'repeater_key' );
if ( ! $field ) {
return;
}
if ( $field ) {
$value = jet_engine()->listings->data->get_meta($field);
}
if ( empty( $value ) ) {
return;
}
// wp_die("<pre>" . print_r(Jet_Engine_Tools::get_attachment_image_data_array( $value ),true) . "</pre>");
return Jet_Engine_Tools::get_attachment_image_data_array( $value );
}
}