PluginProbe
Elementor Website Builder – more than just a page builder / 3.17.2
Elementor Website Builder – more than just a page builder v3.17.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
← All changes | includes/managers/controls.php +30 -213 4.2.33.17.2 View file →
@@ -1,9 +1,7 @@
1 1 <?php
2 2 namespace Elementor;
3 3
4 -use Elementor\Core\Frontend\Performance;
5 -
6 4 if ( ! defined( 'ABSPATH' ) ) {
7 5 exit; // Exit if accessed directly.
8 6 }
9 7
@@ -93,23 +91,13 @@
93 91 */
94 92 const RAW_HTML = 'raw_html';
95 93
96 94 /**
97 - * Notice control.
98 - */
99 - const NOTICE = 'notice';
100 -
101 - /**
102 95 * Deprecated Notice control.
103 96 */
104 97 const DEPRECATED_NOTICE = 'deprecated_notice';
105 98
106 99 /**
107 - * Alert control.
108 - */
109 - const ALERT = 'alert';
110 -
111 - /**
112 100 * Popover Toggle control.
113 101 */
114 102 const POPOVER_TOGGLE = 'popover_toggle';
115 103
@@ -158,13 +146,8 @@
158 146 */
159 147 const CHOOSE = 'choose';
160 148
161 149 /**
162 - * Visual_Choice control.
163 - */
164 - const VISUAL_CHOICE = 'visual_choice';
165 -
166 - /**
167 150 * WYSIWYG control.
168 151 */
169 152 const WYSIWYG = 'wysiwyg';
170 153
@@ -417,10 +400,8 @@
417 400 self::TAB,
418 401 self::TABS,
419 402 self::DIVIDER,
420 403 self::DEPRECATED_NOTICE,
421 - self::ALERT,
422 - self::NOTICE,
423 404
424 405 self::COLOR,
425 406 self::MEDIA,
426 407 self::SLIDER,
@@ -425,9 +406,8 @@
425 406 self::MEDIA,
426 407 self::SLIDER,
427 408 self::DIMENSIONS,
428 409 self::CHOOSE,
429 - self::VISUAL_CHOICE,
430 410 self::WYSIWYG,
431 411 self::CODE,
432 412 self::FONT,
433 413 self::IMAGE_DIMENSIONS,
@@ -494,14 +474,14 @@
494 474 *
495 475 * @param Controls_Manager $this The controls manager.
496 476 */
497 477 // TODO: Uncomment when Pro uses the new hook.
498 - // Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->do_deprecated_action(
499 - // 'elementor/controls/controls_registered',
500 - // [ $this ],
501 - // '3.5.0',
502 - // 'elementor/controls/register'
503 - // );
478 + //Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->do_deprecated_action(
479 + // 'elementor/controls/controls_registered',
480 + // [ $this ],
481 + // '3.5.0',
482 + // 'elementor/controls/register'
483 + //);
504 484
505 485 do_action( 'elementor/controls/controls_registered', $this );
506 486
507 487 /**
@@ -531,13 +511,13 @@
531 511 * current instance.
532 512 */
533 513 public function register_control( $control_id, Base_Control $control_instance ) {
534 514 // TODO: Uncomment when Pro uses the new hook.
535 - // Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function(
536 - // __METHOD__,
537 - // '3.5.0',
538 - // 'register()'
539 - // );
515 + //Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function(
516 + // __METHOD__,
517 + // '3.5.0',
518 + // 'register()'
519 + //);
540 520
541 521 $this->register( $control_instance, $control_id );
542 522 }
543 523
@@ -765,9 +745,8 @@
765 745
766 746 $this->stacks[ $stack_id ] = [
767 747 'tabs' => [],
768 748 'controls' => [],
769 - 'style_controls' => [],
770 749 'responsive_control_duplication_mode' => Plugin::$instance->breakpoints->get_responsive_control_duplication_mode(),
771 750 ];
772 751 }
773 752
@@ -806,13 +785,8 @@
806 785 'overwrite' => false,
807 786 'index' => null,
808 787 ];
809 788
810 - $control_type = 'controls';
811 - if ( Performance::should_optimize_controls() && $this->is_style_control( $control_data ) ) {
812 - $control_type = 'style_controls';
813 - }
814 -
815 789 $options = array_merge( $default_options, $options );
816 790
817 791 $default_args = [
818 792 'type' => self::TEXT,
@@ -829,17 +803,8 @@
829 803 _doing_it_wrong( sprintf( '%1$s::%2$s', __CLASS__, __FUNCTION__ ), sprintf( 'Control type "%s" not found.', esc_html( $control_data['type'] ) ), '1.0.0' );
830 804 return false;
831 805 }
832 806
833 - if ( $control_type_instance instanceof Has_Validation ) {
834 - try {
835 - $control_type_instance->validate( $control_data );
836 - } catch ( \Exception $e ) {
837 - _doing_it_wrong( sprintf( '%1$s::%2$s', __CLASS__, __FUNCTION__ ), esc_html( $e->getMessage() ), '3.23.0' );
838 - return false;
839 - }
840 - }
841 -
842 807 if ( $control_type_instance instanceof Base_Data_Control ) {
843 808 $control_default_value = $control_type_instance->get_default_value();
844 809
845 810 if ( is_array( $control_default_value ) ) {
@@ -850,9 +815,9 @@
850 815 }
851 816
852 817 $stack_id = $element->get_unique_name();
853 818
854 - if ( ! $options['overwrite'] && isset( $this->stacks[ $stack_id ][ $control_type ][ $control_id ] ) ) {
819 + if ( ! $options['overwrite'] && isset( $this->stacks[ $stack_id ]['controls'][ $control_id ] ) ) {
855 820 _doing_it_wrong( sprintf( '%1$s::%2$s', __CLASS__, __FUNCTION__ ), sprintf( 'Cannot redeclare control with same name "%s".', esc_html( $control_id ) ), '1.0.0' );
856 821
857 822 return false;
858 823 }
@@ -864,18 +829,18 @@
864 829 }
865 830
866 831 $this->stacks[ $stack_id ]['tabs'][ $control_data['tab'] ] = $tabs[ $control_data['tab'] ];
867 832
868 - $this->stacks[ $stack_id ][ $control_type ][ $control_id ] = $control_data;
833 + $this->stacks[ $stack_id ]['controls'][ $control_id ] = $control_data;
869 834
870 835 if ( null !== $options['index'] ) {
871 - $controls = $this->stacks[ $stack_id ][ $control_type ];
836 + $controls = $this->stacks[ $stack_id ]['controls'];
872 837
873 838 $controls_keys = array_keys( $controls );
874 839
875 840 array_splice( $controls_keys, $options['index'], 0, $control_id );
876 841
877 - $this->stacks[ $stack_id ][ $control_type ] = array_merge( array_flip( $controls_keys ), $controls );
842 + $this->stacks[ $stack_id ]['controls'] = array_merge( array_flip( $controls_keys ), $controls );
878 843 }
879 844
880 845 return true;
881 846 }
@@ -887,9 +852,9 @@
887 852 *
888 853 * @since 1.0.0
889 854 * @access public
890 855 *
891 - * @param string $stack_id Stack ID.
856 + * @param string $stack_id Stack ID.
892 857 * @param array|string $control_id The ID of the control to remove.
893 858 *
894 859 * @return bool|\WP_Error True if the stack was removed, False otherwise.
895 860 */
@@ -912,9 +877,8 @@
912 877 }
913 878
914 879 /**
915 880 * Has Stacks Cache Been Cleared.
916 - *
917 881 * @since 3.13.0
918 882 * @access public
919 883 * @return bool True if the CSS requires to clear the controls stack cache, False otherwise.
920 884 */
@@ -924,9 +888,8 @@
924 888
925 889 /**
926 890 * Clear stack.
927 891 * This method clears the stack.
928 - *
929 892 * @since 3.13.0
930 893 * @access public
931 894 */
932 895 public function clear_stack_cache() {
@@ -951,19 +914,13 @@
951 914 *
952 915 * @return array|\WP_Error The control, or an error.
953 916 */
954 917 public function get_control_from_stack( $stack_id, $control_id ) {
955 - $stack_data = $this->get_stacks( $stack_id );
956 -
957 - if ( ! empty( $stack_data['controls'][ $control_id ] ) ) {
958 - return $stack_data['controls'][ $control_id ];
918 + if ( empty( $this->stacks[ $stack_id ]['controls'][ $control_id ] ) ) {
919 + return new \WP_Error( 'Cannot get a not-exists control.' );
959 920 }
960 921
961 - if ( ! empty( $stack_data['style_controls'][ $control_id ] ) ) {
962 - return $stack_data['style_controls'][ $control_id ];
963 - }
964 -
965 - return new \WP_Error( 'Cannot get a not-exists control.' );
922 + return $this->stacks[ $stack_id ]['controls'][ $control_id ];
966 923 }
967 924
968 925 /**
969 926 * Update control in stack.
@@ -1064,10 +1021,11 @@
1064 1021 * @since 1.0.0
1065 1022 * @access public
1066 1023 *
1067 1024 * @param Controls_Stack $controls_stack .
1068 - * @param string $tab
1069 - * @param array $additional_messages
1025 + * @param string $tab
1026 + * @param array $additional_messages
1027 + *
1070 1028 */
1071 1029 public function add_custom_css_controls( Controls_Stack $controls_stack, $tab = self::TAB_ADVANCED, $additional_messages = [] ) {
1072 1030 $controls_stack->start_controls_section(
1073 1031 'section_custom_css_pro',
@@ -1107,10 +1065,10 @@
1107 1065 * version of elementor uses this method to display an upgrade message to
1108 1066 * Elementor Pro.
1109 1067 *
1110 1068 * @param Controls_Stack $controls_stack .
1111 - * @param string $tab
1112 - * @param array $additional_messages
1069 + * @param string $tab
1070 + * @param array $additional_messages
1113 1071 *
1114 1072 * @return void
1115 1073 */
1116 1074 public function add_page_transitions_controls( Controls_Stack $controls_stack, $tab = self::TAB_ADVANCED, $additional_messages = [] ) {
@@ -1148,9 +1106,9 @@
1148 1106 public function get_teaser_template( $texts ) {
1149 1107 ob_start();
1150 1108 ?>
1151 1109 <div class="elementor-nerd-box">
1152 - <img class="elementor-nerd-box-icon" src="<?php echo esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ); ?>" loading="lazy" alt="<?php echo esc_attr__( 'Upgrade', 'elementor' ); ?>" />
1110 + <img class="elementor-nerd-box-icon" src="<?php echo esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ); ?>" loading="lazy" />
1153 1111 <div class="elementor-nerd-box-title"><?php Utils::print_unescaped_internal_string( $texts['title'] ); ?></div>
1154 1112 <?php foreach ( $texts['messages'] as $message ) { ?>
1155 1113 <div class="elementor-nerd-box-message"><?php Utils::print_unescaped_internal_string( $message ); ?></div>
1156 1114 <?php }
@@ -1191,19 +1149,19 @@
1191 1149 * This method adds a new control for the "Custom Attributes" feature. The free
1192 1150 * version of elementor uses this method to display an upgrade message to
1193 1151 * Elementor Pro.
1194 1152 *
1195 - * @param Controls_Stack $controls_stack .
1196 - * @param string $tab
1197 1153 * @since 2.8.3
1198 1154 * @access public
1155 + *
1156 + * @param Controls_Stack $controls_stack.
1199 1157 */
1200 - public function add_custom_attributes_controls( Controls_Stack $controls_stack, string $tab = self::TAB_ADVANCED ) {
1158 + public function add_custom_attributes_controls( Controls_Stack $controls_stack ) {
1201 1159 $controls_stack->start_controls_section(
1202 1160 'section_custom_attributes_pro',
1203 1161 [
1204 1162 'label' => esc_html__( 'Attributes', 'elementor' ),
1205 - 'tab' => $tab,
1163 + 'tab' => self::TAB_ADVANCED,
1206 1164 ]
1207 1165 );
1208 1166
1209 1167 $controls_stack->add_control(
@@ -1225,9 +1183,9 @@
1225 1183
1226 1184 /**
1227 1185 * Check if a stack should be cleaned by the current responsive control duplication mode.
1228 1186 *
1229 - * @param array $stack
1187 + * @param $stack
1230 1188 * @return bool
1231 1189 */
1232 1190 private function should_clean_stack( $stack ): bool {
1233 1191 if ( ! isset( $stack['responsive_control_duplication_mode'] ) ) {
@@ -1254,147 +1212,6 @@
1254 1212 return false;
1255 1213 }
1256 1214
1257 1215 return true;
1258 - }
1259 -
1260 - public function add_display_conditions_controls( Controls_Stack $controls_stack ) {
1261 - if ( Utils::has_pro() ) {
1262 - return;
1263 - }
1264 -
1265 - ob_start();
1266 - ?>
1267 - <div class="e-control-display-conditions-promotion__wrapper">
1268 - <div class="e-control-display-conditions-promotion__description">
1269 - <span class="e-control-display-conditions-promotion__text">
1270 - <?php echo esc_html__( 'Display Conditions', 'elementor' ); ?>
1271 - </span>
1272 - <span class="e-control-display-conditions-promotion__lock-wrapper">
1273 - <i class="eicon-upgrade-crown-full e-control-display-conditions-promotion"></i>
1274 - </span>
1275 - </div>
1276 - <i class="eicon-flow e-control-display-conditions-promotion"></i>
1277 - </div>
1278 - <?php
1279 - $control_template = ob_get_clean();
1280 -
1281 - $controls_stack->add_control(
1282 - 'display_conditions_pro',
1283 - [
1284 - 'type' => self::RAW_HTML,
1285 - 'separator' => 'before',
1286 - 'raw' => $control_template,
1287 - ]
1288 - );
1289 - }
1290 -
1291 - public function add_motion_effects_promotion_control( Controls_Stack $controls_stack ) {
1292 - if ( Utils::has_pro() ) {
1293 - return;
1294 - }
1295 -
1296 - $controls_stack->add_control(
1297 - 'scrolling_effects_pro',
1298 - [
1299 - 'type' => self::RAW_HTML,
1300 - 'separator' => 'before',
1301 - 'raw' => $this->promotion_switcher_control( esc_html__( 'Scrolling Effects', 'elementor' ), 'scrolling-effects' ),
1302 - ]
1303 - );
1304 -
1305 - $controls_stack->add_control(
1306 - 'mouse_effects_pro',
1307 - [
1308 - 'type' => self::RAW_HTML,
1309 - 'separator' => 'before',
1310 - 'raw' => $this->promotion_switcher_control( esc_html__( 'Mouse Effects', 'elementor' ), 'mouse-effects' ),
1311 - ]
1312 - );
1313 -
1314 - $controls_stack->add_control(
1315 - 'sticky_pro',
1316 - [
1317 - 'type' => self::RAW_HTML,
1318 - 'separator' => 'before',
1319 - 'raw' => $this->promotion_select_control( esc_html__( 'Sticky', 'elementor' ), 'sticky-effects' ),
1320 - ]
1321 - );
1322 -
1323 - $controls_stack->add_control(
1324 - 'motion_effects_promotion_divider',
1325 - [
1326 - 'type' => self::DIVIDER,
1327 - ]
1328 - );
1329 - }
1330 -
1331 - private function promotion_switcher_control( $title, $id ): string {
1332 - return '<div class="elementor-control-type-switcher elementor-label-inline e-control-motion-effects-promotion__wrapper">
1333 - <div class="elementor-control-content">
1334 - <div class="elementor-control-field">
1335 - <label>
1336 - ' . $title . '
1337 - </label>
1338 - <span class="e-control-motion-effects-promotion__lock-wrapper">
1339 - <i class="eicon-upgrade-crown-full"></i>
1340 - </span>
1341 - <div class="elementor-control-input-wrapper">
1342 - <label class="elementor-switch elementor-control-unit-2 e-control-' . $id . '-promotion">
1343 - <input type="checkbox" class="elementor-switch-input" disabled>
1344 - <span class="elementor-switch-label" data-off="Off"></span>
1345 - <span class="elementor-switch-handle"></span>
1346 - </label>
1347 - </div>
1348 - </div>
1349 - </div>
1350 - </div>';
1351 - }
1352 -
1353 - private function promotion_select_control( $title, $id ): string {
1354 - return '<div class="elementor-control-type-select elementor-label-inline e-control-motion-effects-promotion__wrapper">
1355 - <div class="elementor-control-content">
1356 - <div class="elementor-control-field ">
1357 - <label for="sticky-motion-effect-pro">
1358 - ' . $title . '
1359 - </label>
1360 - <span class="e-control-motion-effects-promotion__lock-wrapper">
1361 - <i class="eicon-upgrade-crown-full"></i>
1362 - </span>
1363 - <div class="elementor-control-input-wrapper elementor-control-unit-5 e-control-' . $id . '-promotion">
1364 - <div class="select-promotion elementor-control-unit-5">' . esc_html__( 'None', 'elementor' ) . '</div>
1365 - </div>
1366 - </div>
1367 - </div>
1368 - </div>';
1369 - }
1370 -
1371 - private function is_style_control( $control_data ): bool {
1372 - $frontend_available = $control_data['frontend_available'] ?? false;
1373 - if ( $frontend_available ) {
1374 - return false;
1375 - }
1376 -
1377 - if ( ! empty( $control_data['control_type'] ) && 'content' === $control_data['control_type'] ) {
1378 - return false;
1379 - }
1380 -
1381 - if ( ! empty( $control_data['prefix_class'] ) ) {
1382 - return false;
1383 - }
1384 -
1385 - $render_type = $control_data['render_type'] ?? '';
1386 - if ( 'template' === $render_type ) {
1387 - return false;
1388 - }
1389 -
1390 - if ( 'ui' === $render_type ) {
1391 - return true;
1392 - }
1393 -
1394 - if ( ! empty( $control_data['selectors'] ) ) {
1395 - return true;
1396 - }
1397 -
1398 - return false;
1399 1216 }
1400 1217 }