PluginProbe ʕ •ᴥ•ʔ
Royal Addons for Elementor – Addons and Templates Kit for Elementor / 1.7.1060
Royal Addons for Elementor – Addons and Templates Kit for Elementor v1.7.1060
1.7.1062 1.7.1061 1.7.1060 1.7.1059 1.7.1058 trunk 1.0.0 1.1.0 1.2 1.3 1.3.1 1.3.2 1.3.21 1.3.22 1.3.23 1.3.24 1.3.25 1.3.26 1.3.27 1.3.28 1.3.29 1.3.30 1.3.31 1.3.32 1.3.33 1.3.34 1.3.35 1.3.36 1.3.37 1.3.38 1.3.39 1.3.40 1.3.41 1.3.42 1.3.43 1.3.44 1.3.45 1.3.46 1.3.47 1.3.48 1.3.49 1.3.50 1.3.51 1.3.52 1.3.53 1.3.54 1.3.55 1.3.56 1.3.57 1.3.58 1.3.59 1.3.60 1.3.61 1.3.62 1.3.63 1.3.64 1.3.65 1.3.66 1.3.67 1.3.68 1.3.69 1.3.70 1.3.71 1.3.72 1.3.73 1.3.74 1.3.75 1.3.76 1.3.77 1.3.78 1.3.79 1.3.80 1.3.81 1.3.82 1.3.83 1.3.84 1.3.85 1.3.86 1.3.87 1.3.88 1.3.89 1.3.90 1.3.91 1.3.92 1.3.93 1.3.94 1.3.95 1.3.96 1.3.97 1.3.971 1.3.972 1.3.973 1.3.974 1.3.975 1.3.976 1.3.977 1.3.978 1.3.979 1.3.980 1.3.981 1.3.982 1.3.983 1.3.984 1.3.985 1.3.986 1.3.987 1.7.1 1.7.1001 1.7.1002 1.7.1003 1.7.1004 1.7.1005 1.7.1006 1.7.1007 1.7.1008 1.7.1009 1.7.1010 1.7.1011 1.7.1012 1.7.1013 1.7.1014 1.7.1015 1.7.1016 1.7.1017 1.7.1018 1.7.1019 1.7.1020 1.7.1021 1.7.1022 1.7.1023 1.7.1024 1.7.1025 1.7.1026 1.7.1027 1.7.1028 1.7.1029 1.7.1030 1.7.1031 1.7.1032 1.7.1033 1.7.1034 1.7.1035 1.7.1036 1.7.1037 1.7.1038 1.7.1039 1.7.1040 1.7.1041 1.7.1042 1.7.1043 1.7.1044 1.7.1045 1.7.1046 1.7.1047 1.7.1048 1.7.1049 1.7.1050 1.7.1051 1.7.1052 1.7.1053 1.7.1054 1.7.1055 1.7.1056 1.7.1057
royal-elementor-addons / extensions / wpr-equal-height.php
royal-elementor-addons / extensions Last commit date
wpr-column-slider.php 3 weeks ago wpr-custom-css.php 3 weeks ago wpr-display-conditions.php 3 weeks ago wpr-equal-height.php 3 weeks ago wpr-extensions-base.php 3 weeks ago wpr-parallax.php 3 weeks ago wpr-particles.php 3 weeks ago wpr-sticky-section.php 3 weeks ago
wpr-equal-height.php
216 lines
1 <?php
2 use Elementor\Controls_Manager;
3 use WprAddons\Classes\Utilities;
4
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly.
8 }
9
10 class Wpr_Equal_Height {
11 public function __construct() {
12 add_action( 'elementor/element/section/section_advanced/after_section_end', [ $this, 'register_controls' ], 10 );
13 add_action( 'elementor/section/print_template', array( $this, '_print_template' ), 10, 2 );
14 add_action( 'elementor/frontend/section/before_render', array( $this, '_before_render' ), 10, 1 );
15
16 // FLEXBOX CONTAINER
17 add_action( 'elementor/element/container/section_layout/after_section_end', [ $this, 'register_controls' ], 10 );
18 add_action( 'elementor/container/print_template', array( $this, '_print_template' ), 10, 2 );
19 add_action( 'elementor/frontend/container/before_render', array( $this, '_before_render' ), 10, 1 );
20
21 }
22
23 public function register_controls( $element ) {
24
25 $element->start_controls_section(
26 'wpr_section_equal_height',
27 [
28 'tab' => Controls_Manager::TAB_ADVANCED,
29 'label' => sprintf(esc_html__('Equal Height - %s', 'wpr-addons'), esc_html('RA')),
30 ]
31 );
32
33 $element->add_control(
34 'wpr_section_equal_height_update',
35 [
36 'type' => Controls_Manager::RAW_HTML,
37 'raw' => '<div class="elementor-update-preview editor-wpr-preview-update"><span>Update changes to Preview</span><button class="elementor-button elementor-button-success" onclick="elementor.reloadPreview();">Apply</button>',
38 'separator' => 'after'
39 ]
40 );
41
42 $element->add_control (
43 'wpr_enable_equal_height',
44 [
45 'type' => Controls_Manager::SWITCHER,
46 'label' => esc_html__( 'Enable Equal Height', 'wpr-addons' ),
47 'description' => esc_html__( 'Makes all selected child elements the same height within this section/container. Useful for aligning columns, cards, or widgets in a row so they match regardless of content length. Click "Apply" above after enabling.', 'wpr-addons' ),
48 'default' => 'no',
49 'return_value' => 'yes',
50 'prefix_class' => 'wpr-equal-height-',
51 'render_type' => 'template',
52 ]
53 );
54
55 $element->add_control(
56 'wpr_equal_height_target_type',
57 [
58 'label' => esc_html__( 'Equalize', 'wpr-addons' ),
59 'description' => esc_html__( 'Choose what to equalize: "Widgets" lets you pick specific widget types from a list, "Custom Selector" lets you target elements by CSS class name.', 'wpr-addons' ),
60 'type' => Controls_Manager::SELECT,
61 'default' => 'widget',
62 'options' => [
63 'widget' => esc_html__( 'Widgets', 'wpr-addons' ),
64 'custom' => esc_html__( 'Custom Selector', 'wpr-addons' ),
65 ],
66 'condition' => [
67 'wpr_enable_equal_height' => 'yes',
68 ],
69 ]
70 );
71
72 $element->add_control(
73 'wpr_equal_height_target',
74 [
75 'label' => esc_html__( 'Widgets', 'wpr-addons' ),
76 'description' => esc_html__( 'Select which widget types should have equal height within this section.', 'wpr-addons' ),
77 'type' => 'wpr-select2',
78 'render_type' => 'template',
79 'label_block' => true,
80 'multiple' => true,
81 'frontend_available' => true,
82 'condition' => [
83 'wpr_enable_equal_height' => 'yes',
84 'wpr_equal_height_target_type' => 'widget',
85 ],
86 ]
87 );
88
89 $element->add_control(
90 'wpr_equal_height_custom_target',
91 array(
92 'label' => esc_html__( 'Selectors', 'wpr-addons' ),
93 'type' => Controls_Manager::TEXT,
94 'label_block' => true,
95 'placeholder' => esc_html__( '.class-name, .class-name2 .my-custom-class', 'wpr-addons' ),
96 'description' => esc_html__( 'Enter CSS selectors separated by commas. All matching elements within this section will be set to equal height.', 'wpr-addons' ),
97 'render_type' => 'none',
98 'condition' => [
99 'wpr_enable_equal_height' => 'yes',
100 'wpr_equal_height_target_type' => 'custom',
101 ],
102 )
103 );
104
105 $element->add_control(
106 'wpr_enable_equal_height_on',
107 array(
108 'label' => esc_html__( 'Enable Equal Height on', 'wpr-addons' ),
109 'description' => esc_html__( 'Choose which screen sizes should apply equal height. Deselect smaller breakpoints if you want columns to stack naturally on mobile.', 'wpr-addons' ),
110 'type' => Controls_Manager::SELECT2,
111 'multiple' => true,
112 'options' => Utilities::get_all_breakpoints(),
113 'label_block' => true,
114 'default' => Utilities::get_all_breakpoints( 'keys' ),
115 'condition' => [
116 'wpr_enable_equal_height' => 'yes',
117 ],
118 )
119 );
120
121 $element->end_controls_section();
122
123 }
124
125 public function enqueue_scripts() {
126
127 // if ( ! wp_script_is( 'pa-eq-height', 'enqueued' ) ) {
128 // wp_enqueue_script( 'pa-eq-height' );
129 // }
130
131 }
132
133 public function _before_render( $element ) {
134 if ( $element->get_name() !== 'section' && $element->get_name() !== 'container' ) {
135 return;
136 }
137
138 $settings = $element->get_settings_for_display();
139
140 if ( 'yes' === $settings['wpr_enable_equal_height'] ) {
141
142 $target_type = $settings['wpr_equal_height_target_type'];
143
144 if ( 'custom' === $target_type ) {
145 $target = array_map( 'trim', explode( ',', (string) $settings['wpr_equal_height_custom_target'] ) );
146 $target = array_values( array_filter( $target ) );
147 } else {
148 $target = $settings['wpr_equal_height_target'] ?? [];
149 if ( is_array( $target ) ) {
150 $target = array_values( $target );
151 } elseif ( is_string( $target ) && '' !== $target ) {
152 $target = [ $target ];
153 } else {
154 $target = [];
155 }
156 }
157
158 $enable_on = $settings['wpr_enable_equal_height_on'] ?? [];
159 if ( ! is_array( $enable_on ) ) {
160 $enable_on = '' !== (string) $enable_on ? [ $enable_on ] : [];
161 } else {
162 $enable_on = array_values( $enable_on );
163 }
164
165 $equal_height_settings = array(
166 'wpr_eh_target-type' => $target_type,
167 'wpr_eh_target' => $target,
168 'enable_on' => $enable_on,
169 );
170
171 $element->add_render_attribute( '_wrapper', 'data-wpr-equal-height', wp_json_encode( $equal_height_settings ) );
172 }
173 }
174
175 public function _print_template( $template, $widget ) {
176 if ( $widget->get_name() !== 'section' && $widget->get_name() !== 'container' ) {
177 return $template;
178 }
179
180 ob_start();
181
182 ?>
183 <# if( 'yes' === settings.wpr_enable_equal_height ) {
184
185 view.addRenderAttribute( 'wpr_equal_height', 'id', 'wpr-equal-height-' + view.getID() );
186 var targetType = settings.wpr_equal_height_target_type,
187
188 target = 'custom' === targetType ? settings.wpr_equal_height_custom_target.split(',').map(function(s){ return s.trim(); }).filter(function(s){ return s; }) : settings.wpr_equal_height_target,
189
190 addonSettings = {
191 'wpr_eh_target-type': targetType,
192 'wpr_eh_target': target,
193 'enable_on':settings.wpr_enable_equal_height_on
194 };
195
196 view.addRenderAttribute( 'equal_height', {
197 'id' : 'wpr-equal-height-' + view.getID(),
198 'data-wpr-equal-height': JSON.stringify( addonSettings )
199 });
200
201 #>
202 <div {{{ view.getRenderAttributeString( 'equal_height' ) }}}></div>
203 <# } #>
204 <?php
205
206 // how to render attributes without creating new div using view.addRenderAttributes
207 $equal_height_content = ob_get_contents();
208
209 ob_end_clean();
210
211 return $template . $equal_height_content;
212 }
213
214 }
215
216 new Wpr_Equal_Height();