PluginProbe
Elementor Website Builder – more than just a page builder / 3.4.7
Elementor Website Builder – more than just a page builder v3.4.7
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/base/controls-stack.php +90 -312 4.0.73.4.7 View file →
@@ -2,11 +2,10 @@
2 2 namespace Elementor;
3 3
4 4 use Elementor\Core\Base\Base_Object;
5 5 use Elementor\Core\DynamicTags\Manager;
6 +use Elementor\Core\Schemes\Manager as Schemes_Manager;
6 7 use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
7 -use Elementor\Core\Frontend\Performance;
8 -use Elementor\Utils;
9 8
10 9 if ( ! defined( 'ABSPATH' ) ) {
11 10 exit; // Exit if accessed directly.
12 11 }
@@ -91,22 +90,8 @@
91 90 */
92 91 private $config;
93 92
94 93 /**
95 - * The additional configuration.
96 - *
97 - * Holds additional configuration that has been set using `set_config` method.
98 - * The `config` property is not modified directly while using the method because
99 - * it's used to check whether the initial config already loaded (in `get_config`).
100 - * After the initial config loaded, the additional config is merged into it.
101 - *
102 - * @access private
103 - *
104 - * @var null|array
105 - */
106 - private $additional_config = [];
107 -
108 - /**
109 94 * Current section.
110 95 *
111 96 * Holds the current section while inserting a set of controls sections.
112 97 *
@@ -230,22 +215,8 @@
230 215 return @hexdec( $this->id );
231 216 }
232 217
233 218 /**
234 - * Get widget number.
235 - *
236 - * Get the first three numbers of the element converted ID.
237 - *
238 - * @since 3.16
239 - * @access public
240 - *
241 - * @return string The widget number.
242 - */
243 - public function get_widget_number(): string {
244 - return substr( $this->get_id_int(), 0, 3 );
245 - }
246 -
247 - /**
248 219 * Get the type.
249 220 *
250 221 * Retrieve the type, e.g. 'stack', 'section', 'widget' etc.
251 222 *
@@ -311,26 +282,9 @@
311 282 *
312 283 * @return mixed Controls list.
313 284 */
314 285 public function get_controls( $control_id = null ) {
315 - $stack = $this->get_stack();
316 -
317 - if ( null !== $control_id ) {
318 - $control_data = self::get_items( $stack['controls'], $control_id );
319 - if ( null === $control_data && ! empty( $stack['style_controls'] ) ) {
320 - $control_data = self::get_items( $stack['style_controls'], $control_id );
321 - }
322 -
323 - return $control_data;
324 - }
325 -
326 - $controls = $stack['controls'];
327 -
328 - if ( Performance::is_use_style_controls() && ! empty( $stack['style_controls'] ) ) {
329 - $controls += $stack['style_controls'];
330 - }
331 -
332 - return self::get_items( $controls, $control_id );
286 + return self::get_items( $this->get_stack()['controls'], $control_id );
333 287 }
334 288
335 289 /**
336 290 * Get active controls.
@@ -349,10 +303,10 @@
349 303 * @param array $settings Optional. Controls settings. Default is null.
350 304 *
351 305 * @return array Active controls.
352 306 */
353 - public function get_active_controls( ?array $controls = null, ?array $settings = null ) {
354 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.0.0' );
307 + public function get_active_controls( array $controls = null, array $settings = null ) {
308 + // _deprecated_function( __METHOD__, '3.0.0' );
355 309
356 310 if ( ! $controls ) {
357 311 $controls = $this->get_controls();
358 312 }
@@ -364,9 +318,9 @@
364 318 $active_controls = array_reduce(
365 319 array_keys( $controls ), function( $active_controls, $control_key ) use ( $controls, $settings ) {
366 320 $control = $controls[ $control_key ];
367 321
368 - if ( $this->is_control_visible( $control, $settings, $controls ) ) {
322 + if ( $this->is_control_visible( $control, $settings ) ) {
369 323 $active_controls[ $control_key ] = $control;
370 324 }
371 325
372 326 return $active_controls;
@@ -439,58 +393,14 @@
439 393 }
440 394
441 395 unset( $options['position'] );
442 396
443 - if ( $this->current_popover ) {
444 - $args['popover'] = [];
445 -
446 - if ( ! $this->current_popover['initialized'] ) {
447 - $args['popover']['start'] = true;
448 -
449 - $this->current_popover['initialized'] = true;
450 - }
451 - }
452 -
453 - if ( Performance::should_optimize_controls() ) {
454 - $ui_controls = [
455 - Controls_Manager::RAW_HTML,
456 - Controls_Manager::DIVIDER,
457 - Controls_Manager::HEADING,
458 - Controls_Manager::BUTTON,
459 - Controls_Manager::ALERT,
460 - Controls_Manager::NOTICE,
461 - Controls_Manager::DEPRECATED_NOTICE,
397 + if ( $this->current_popover && ! $this->current_popover['initialized'] ) {
398 + $args['popover'] = [
399 + 'start' => true,
462 400 ];
463 401
464 - if ( ! empty( $args['type'] ) && ! empty( $args['section'] ) && in_array( $args['type'], $ui_controls ) ) {
465 - $args = [
466 - 'type' => $args['type'],
467 - 'section' => $args['section'],
468 - ];
469 - }
470 -
471 - unset(
472 - $args['label_block'],
473 - $args['label'],
474 - $args['title'],
475 - $args['tab'],
476 - $args['options'],
477 - $args['placeholder'],
478 - $args['separator'],
479 - $args['size_units'],
480 - $args['range'],
481 - $args['toggle'],
482 - $args['ai'],
483 - $args['classes'],
484 - $args['style_transfer'],
485 - $args['show_label'],
486 - $args['description'],
487 - $args['label_on'],
488 - $args['label_off'],
489 - $args['labels'],
490 - $args['handles'],
491 - $args['editor_available'],
492 - );
402 + $this->current_popover['initialized'] = true;
493 403 }
494 404
495 405 return Plugin::$instance->controls_manager->add_control_to_stack( $this, $id, $args, $options );
496 406 }
@@ -612,10 +522,10 @@
612 522
613 523 $position = array_merge( $default_position, $position );
614 524
615 525 if (
616 - ( 'control' === $position['type'] && in_array( $position['at'], [ 'start', 'end' ], true ) ) ||
617 - ( 'section' === $position['type'] && in_array( $position['at'], [ 'before', 'after' ], true ) )
526 + 'control' === $position['type'] && in_array( $position['at'], [ 'start', 'end' ], true ) ||
527 + 'section' === $position['type'] && in_array( $position['at'], [ 'before', 'after' ], true )
618 528 ) {
619 529 _doing_it_wrong( sprintf( '%s::%s', get_called_class(), __FUNCTION__ ), 'Invalid position arguments. Use `before` / `after` for control or `start` / `end` for section.', '1.7.0' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
620 530
621 531 return false;
@@ -637,13 +547,13 @@
637 547
638 548 $controls_keys = array_keys( $registered_controls );
639 549
640 550 while ( Controls_Manager::SECTION !== $registered_controls[ $controls_keys[ $target_section_index ] ]['type'] ) {
641 - --$target_section_index;
551 + $target_section_index--;
642 552 }
643 553
644 554 if ( 'section' === $position['type'] ) {
645 - ++$target_control_index;
555 + $target_control_index++;
646 556
647 557 if ( 'end' === $position['at'] ) {
648 558 while ( Controls_Manager::SECTION !== $registered_controls[ $controls_keys[ $target_control_index ] ]['type'] ) {
649 559 if ( ++$target_control_index >= count( $registered_controls ) ) {
@@ -655,9 +565,9 @@
655 565
656 566 $target_control = $registered_controls[ $controls_keys[ $target_control_index ] ];
657 567
658 568 if ( 'after' === $position['at'] ) {
659 - ++$target_control_index;
569 + $target_control_index++;
660 570 }
661 571
662 572 $section_id = $registered_controls[ $controls_keys[ $target_section_index ] ]['name'];
663 573
@@ -737,9 +647,9 @@
737 647
738 648 $controls_keys = array_keys( $registered_controls );
739 649
740 650 while ( true ) {
741 - ++$section_index;
651 + $section_index++;
742 652
743 653 if ( ! isset( $controls_keys[ $section_index ] ) ) {
744 654 break;
745 655 }
@@ -750,9 +660,9 @@
750 660 break;
751 661 }
752 662
753 663 $section_controls[ $control_key ] = $registered_controls[ $control_key ];
754 - }
664 + };
755 665
756 666 return $section_controls;
757 667 }
758 668
@@ -781,8 +691,30 @@
781 691 $group->add_controls( $this, $args, $options );
782 692 }
783 693
784 694 /**
695 + * Get scheme controls.
696 + *
697 + * Retrieve all the controls that use schemes.
698 + *
699 + * @since 1.4.0
700 + * @access public
701 + * @deprecated 3.0.0
702 + *
703 + * @return array Scheme controls.
704 + */
705 + final public function get_scheme_controls() {
706 + // _deprecated_function( __METHOD__, '3.0.0' );
707 + $enabled_schemes = Schemes_Manager::get_enabled_schemes();
708 +
709 + return array_filter(
710 + $this->get_controls(), function( $control ) use ( $enabled_schemes ) {
711 + return ( ! empty( $control['scheme'] ) && in_array( $control['scheme']['type'], $enabled_schemes ) );
712 + }
713 + );
714 + }
715 +
716 + /**
785 717 * Get style controls.
786 718 *
787 719 * Retrieve style controls for all active controls or, when requested, from
788 720 * a specific set of controls.
@@ -796,10 +728,10 @@
796 728 * @param array $settings Optional. Controls settings. Default is null.
797 729 *
798 730 * @return array Style controls.
799 731 */
800 - final public function get_style_controls( ?array $controls = null, ?array $settings = null ) {
801 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.0.0' );
732 + final public function get_style_controls( array $controls = null, array $settings = null ) {
733 + // _deprecated_function( __METHOD__, '3.0.0' );
802 734
803 735 $controls = $this->get_active_controls( $controls, $settings );
804 736
805 737 $style_controls = [];
@@ -869,12 +801,9 @@
869 801 $args['responsive'] = [];
870 802
871 803 $active_breakpoints = Plugin::$instance->breakpoints->get_active_breakpoints();
872 804
873 - $devices = Plugin::$instance->breakpoints->get_active_devices_list( [
874 - 'reverse' => true,
875 - 'desktop_first' => true,
876 - ] );
805 + $devices = Plugin::$instance->breakpoints->get_active_devices_list( [ 'reverse' => true ] );
877 806
878 807 if ( isset( $args['devices'] ) ) {
879 808 $devices = array_intersect( $devices, $args['devices'] );
880 809
@@ -930,14 +859,9 @@
930 859 foreach ( $devices as $device_name ) {
931 860 $control_args = $args;
932 861
933 862 // Set parent using the name from previous iteration.
934 - if ( isset( $control_name ) ) {
935 - // If $control_name end with _widescreen use desktop name instead.
936 - $control_args['parent'] = '_widescreen' === substr( $control_name, -strlen( '_widescreen' ) ) ? $id : $control_name;
937 - } else {
938 - $control_args['parent'] = null;
939 - }
863 + $control_args['parent'] = isset( $control_name ) ? $control_name : null;
940 864
941 865 if ( isset( $control_args['device_args'] ) ) {
942 866 if ( ! empty( $control_args['device_args'][ $device_name ] ) ) {
943 867 $control_args = array_merge( $control_args, $control_args['device_args'][ $device_name ] );
@@ -979,11 +903,9 @@
979 903 $id_suffix = Breakpoints_Manager::BREAKPOINT_KEY_DESKTOP === $device_name ? '' : '_' . $device_name;
980 904 $control_name = $id . $id_suffix;
981 905
982 906 // Set this control as child of previous iteration control.
983 - if ( ! empty( $control_args['parent'] ) ) {
984 - $this->update_control( $control_args['parent'], [ 'inheritors' => [ $control_name ] ] );
985 - }
907 + $this->update_control( $control_args['parent'], [ 'inheritors' => [ $control_name ] ] );
986 908
987 909 if ( ! empty( $options['overwrite'] ) ) {
988 910 $this->update_control( $control_name, $control_args, [
989 911 'recursive' => ! empty( $options['recursive'] ),
@@ -1025,9 +947,13 @@
1025 947 *
1026 948 * @param string $id Responsive control ID.
1027 949 */
1028 950 final public function remove_responsive_control( $id ) {
1029 - $devices = Plugin::$instance->breakpoints->get_active_devices_list( [ 'reverse' => true ] );
951 + $devices = [
952 + Breakpoints_Manager::BREAKPOINT_KEY_DESKTOP,
953 + Breakpoints_Manager::BREAKPOINT_KEY_TABLET,
954 + Breakpoints_Manager::BREAKPOINT_KEY_MOBILE,
955 + ];
1030 956
1031 957 foreach ( $devices as $device_name ) {
1032 958 $id_suffix = Breakpoints_Manager::BREAKPOINT_KEY_DESKTOP === $device_name ? '' : '_' . $device_name;
1033 959
@@ -1060,10 +986,10 @@
1060 986 * @return array|null The config.
1061 987 */
1062 988 final public function get_config() {
1063 989 if ( null === $this->config ) {
1064 - // TODO: This is for backwards compatibility starting from 2.9.0.
1065 - // This if statement should be removed when the method is hard-deprecated.
990 + // TODO: This is for backwards compatibility starting from 2.9.0
991 + // This if statement should be removed when the method is hard-deprecated
1066 992 if ( $this->has_own_method( '_get_initial_config', self::class ) ) {
1067 993 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_get_initial_config', '2.9.0', __CLASS__ . '::get_initial_config()' );
1068 994
1069 995 $this->config = $this->_get_initial_config();
@@ -1069,16 +995,8 @@
1069 995 $this->config = $this->_get_initial_config();
1070 996 } else {
1071 997 $this->config = $this->get_initial_config();
1072 998 }
1073 -
1074 - foreach ( $this->additional_config as $key => $value ) {
1075 - if ( isset( $this->config[ $key ] ) ) {
1076 - $this->config[ $key ] = wp_parse_args( $value, $this->config[ $key ] );
1077 - } else {
1078 - $this->config[ $key ] = $value;
1079 - }
1080 - }
1081 999 }
1082 1000
1083 1001 return $this->config;
1084 1002 }
@@ -1083,26 +1001,8 @@
1083 1001 return $this->config;
1084 1002 }
1085 1003
1086 1004 /**
1087 - * Set a config property.
1088 - *
1089 - * Set a specific property of the config list for this controls-stack.
1090 - *
1091 - * @param string $key
1092 - * @param string $value
1093 - * @since 3.5.0
1094 - * @access public
1095 - */
1096 - public function set_config( $key, $value ) {
1097 - if ( isset( $this->additional_config[ $key ] ) ) {
1098 - $this->additional_config[ $key ] = wp_parse_args( $value, $this->additional_config[ $key ] );
1099 - } else {
1100 - $this->additional_config[ $key ] = $value;
1101 - }
1102 - }
1103 -
1104 - /**
1105 1005 * Get frontend settings keys.
1106 1006 *
1107 1007 * Retrieve settings keys for all frontend controls.
1108 1008 *
@@ -1166,11 +1066,8 @@
1166 1066 return self::get_items( $this->data, $item );
1167 1067 }
1168 1068
1169 1069 /**
1170 - * @param null $setting
1171 - * @param null $settings
1172 - * @return array|mixed|null
1173 1070 * @since 2.0.14
1174 1071 * @access public
1175 1072 */
1176 1073 public function get_parsed_dynamic_settings( $setting = null, $settings = null ) {
@@ -1189,16 +1086,16 @@
1189 1086 * Get active settings.
1190 1087 *
1191 1088 * Retrieve the settings from all the active controls.
1192 1089 *
1193 - * @param array|null $settings Optional. Controls settings. Default is null.
1194 - * @param array|null $controls Optional. An array of controls. Default is null.
1195 - *
1196 - * @return array Active settings.
1090 + * @since 1.4.0
1197 1091 * @since 2.1.0 Added the `controls` and the `settings` parameters.
1198 1092 * @access public
1199 1093 *
1200 - * @since 1.4.0
1094 + * @param array $controls Optional. An array of controls. Default is null.
1095 + * @param array $settings Optional. Controls settings. Default is null.
1096 + *
1097 + * @return array Active settings.
1201 1098 */
1202 1099 public function get_active_settings( $settings = null, $controls = null ) {
1203 1100 $is_first_request = ! $settings && ! $this->active_settings;
1204 1101
@@ -1213,10 +1110,8 @@
1213 1110 }
1214 1111
1215 1112 $active_settings = [];
1216 1113
1217 - $controls_objs = Plugin::$instance->controls_manager->get_controls();
1218 -
1219 1114 foreach ( $settings as $setting_key => $setting ) {
1220 1115 if ( ! isset( $controls[ $setting_key ] ) ) {
1221 1116 $active_settings[ $setting_key ] = $setting;
1222 1117
@@ -1224,10 +1119,10 @@
1224 1119 }
1225 1120
1226 1121 $control = $controls[ $setting_key ];
1227 1122
1228 - if ( $this->is_control_visible( $control, $settings, $controls ) ) {
1229 - $control_obj = $controls_objs[ $control['type'] ] ?? null;
1123 + if ( $this->is_control_visible( $control, $settings ) ) {
1124 + $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] );
1230 1125
1231 1126 if ( $control_obj instanceof Control_Repeater ) {
1232 1127 foreach ( $setting as & $item ) {
1233 1128 $item = $this->get_active_settings( $item, $control['fields'] );
@@ -1294,13 +1189,11 @@
1294 1189 if ( null === $controls ) {
1295 1190 $controls = $this->get_controls();
1296 1191 }
1297 1192
1298 - $controls_objs = Plugin::$instance->controls_manager->get_controls();
1299 -
1300 1193 foreach ( $controls as $control ) {
1301 1194 $control_name = $control['name'];
1302 - $control_obj = $controls_objs[ $control['type'] ] ?? null;
1195 + $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] );
1303 1196
1304 1197 if ( ! $control_obj instanceof Base_Data_Control ) {
1305 1198 continue;
1306 1199 }
@@ -1410,33 +1303,21 @@
1410 1303 );
1411 1304 }
1412 1305
1413 1306 /**
1414 - * Get Responsive Control Device Suffix
1415 - *
1416 - * @deprecated 3.7.6 Use `Elementor\Controls_Manager::get_responsive_control_device_suffix()` instead.
1417 - * @param array $control
1418 - * @return string $device suffix
1419 - */
1420 - protected function get_responsive_control_device_suffix( $control ) {
1421 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.7.6', 'Elementor\Controls_Manager::get_responsive_control_device_suffix()' );
1422 -
1423 - return Controls_Manager::get_responsive_control_device_suffix( $control );
1424 - }
1425 -
1426 - /**
1427 1307 * Whether the control is visible or not.
1428 1308 *
1429 1309 * Used to determine whether the control is visible or not.
1430 1310 *
1311 + * @since 1.4.0
1312 + * @access public
1313 + *
1431 1314 * @param array $control The control.
1432 - * @param null $values Optional. Condition values. Default is null.
1433 - * @param null $controls
1315 + * @param array $values Optional. Condition values. Default is null.
1316 + *
1434 1317 * @return bool Whether the control is visible.
1435 - * @since 1.4.0
1436 - * @access public
1437 1318 */
1438 - public function is_control_visible( $control, $values = null, $controls = null ) {
1319 + public function is_control_visible( $control, $values = null ) {
1439 1320 if ( null === $values ) {
1440 1321 $values = $this->get_settings();
1441 1322 }
1442 1323
@@ -1447,37 +1328,21 @@
1447 1328 if ( empty( $control['condition'] ) ) {
1448 1329 return true;
1449 1330 }
1450 1331
1451 - if ( ! $controls ) {
1452 - $controls = $this->get_controls();
1453 - }
1454 -
1455 1332 foreach ( $control['condition'] as $condition_key => $condition_value ) {
1456 1333 preg_match( '/([a-z_\-0-9]+)(?:\[([a-z_]+)])?(!?)$/i', $condition_key, $condition_key_parts );
1457 1334
1458 1335 $pure_condition_key = $condition_key_parts[1];
1459 1336 $condition_sub_key = $condition_key_parts[2];
1460 - $is_negative_condition = (bool) $condition_key_parts[3];
1337 + $is_negative_condition = ! ! $condition_key_parts[3];
1461 1338
1462 1339 if ( ! isset( $values[ $pure_condition_key ] ) || null === $values[ $pure_condition_key ] ) {
1463 1340 return false;
1464 1341 }
1465 1342
1466 - $are_control_and_condition_responsive = isset( $control['responsive'] ) && ! empty( $controls[ $pure_condition_key ]['responsive'] );
1467 - $condition_name_to_check = $pure_condition_key;
1343 + $instance_value = $values[ $pure_condition_key ];
1468 1344
1469 - if ( $are_control_and_condition_responsive ) {
1470 - $device_suffix = Controls_Manager::get_responsive_control_device_suffix( $control );
1471 -
1472 - $condition_name_to_check = $pure_condition_key . $device_suffix;
1473 -
1474 - // If the control is not desktop, and a conditioning control for the corresponding device exists, use it.
1475 - $instance_value = $values[ $pure_condition_key . $device_suffix ] ?? $values[ $pure_condition_key ];
1476 - } else {
1477 - $instance_value = $values[ $pure_condition_key ];
1478 - }
1479 -
1480 1345 if ( $condition_sub_key && is_array( $instance_value ) ) {
1481 1346 if ( ! isset( $instance_value[ $condition_sub_key ] ) ) {
1482 1347 return false;
1483 1348 }
@@ -1484,32 +1349,8 @@
1484 1349
1485 1350 $instance_value = $instance_value[ $condition_sub_key ];
1486 1351 }
1487 1352
1488 - if ( ! $instance_value ) {
1489 - $parent = isset( $controls[ $condition_name_to_check ]['parent'] ) ? $controls[ $condition_name_to_check ]['parent'] : false;
1490 -
1491 - while ( $parent ) {
1492 - $instance_value = $values[ $parent ];
1493 -
1494 - if ( $instance_value ) {
1495 - if ( ! is_array( $instance_value ) ) {
1496 - break;
1497 - }
1498 -
1499 - if ( $condition_sub_key && isset( $instance_value[ $condition_sub_key ] ) ) {
1500 - $instance_value = $instance_value[ $condition_sub_key ];
1501 -
1502 - if ( '' !== $instance_value ) {
1503 - break;
1504 - }
1505 - }
1506 - }
1507 -
1508 - $parent = isset( $controls[ $parent ]['parent'] ) ? $controls[ $parent ]['parent'] : false;
1509 - }
1510 - }
1511 -
1512 1353 /**
1513 1354 * If the $condition_value is a non empty array - check if the $condition_value contains the $instance_value,
1514 1355 * If the $instance_value is a non empty array - check if the $instance_value contains the $condition_value
1515 1356 * otherwise check if they are equal. ( and give the ability to check if the value is an empty array )
@@ -1521,12 +1362,9 @@
1521 1362 } else {
1522 1363 $is_contains = $instance_value === $condition_value;
1523 1364 }
1524 1365
1525 - if (
1526 - ( $is_negative_condition && $is_contains ) ||
1527 - ( ! $is_negative_condition && ! $is_contains )
1528 - ) {
1366 + if ( $is_negative_condition && $is_contains || ! $is_negative_condition && ! $is_contains ) {
1529 1367 return false;
1530 1368 }
1531 1369 }
1532 1370
@@ -1548,9 +1386,9 @@
1548 1386 * @param string $section_id Section ID.
1549 1387 * @param array $args Section arguments Optional.
1550 1388 */
1551 1389 public function start_controls_section( $section_id, array $args = [] ) {
1552 - $stack_name = $this->get_name();
1390 + $section_name = $this->get_name();
1553 1391
1554 1392 /**
1555 1393 * Before section start.
1556 1394 *
@@ -1568,9 +1406,9 @@
1568 1406 * Before section start.
1569 1407 *
1570 1408 * Fires before Elementor section starts in the editor panel.
1571 1409 *
1572 - * The dynamic portions of the hook name, `$stack_name` and `$section_id`, refers to the stack name and section ID, respectively.
1410 + * The dynamic portions of the hook name, `$section_name` and `$section_id`, refers to the section name and section ID, respectively.
1573 1411 *
1574 1412 * @since 1.4.0
1575 1413 *
1576 1414 * @param Controls_Stack $this The control.
@@ -1575,14 +1413,10 @@
1575 1413 *
1576 1414 * @param Controls_Stack $this The control.
1577 1415 * @param array $args Section arguments.
1578 1416 */
1579 - do_action( "elementor/element/{$stack_name}/{$section_id}/before_section_start", $this, $args );
1417 + do_action( "elementor/element/{$section_name}/{$section_id}/before_section_start", $this, $args );
1580 1418
1581 - if ( $this->should_manually_trigger_common_action( $stack_name ) ) {
1582 - do_action( "elementor/element/common/{$section_id}/before_section_start", $this, $args );
1583 - }
1584 -
1585 1419 $args['type'] = Controls_Manager::SECTION;
1586 1420
1587 1421 $this->add_control( $section_id, $args );
1588 1422
@@ -1613,9 +1447,9 @@
1613 1447 * After section start.
1614 1448 *
1615 1449 * Fires after Elementor section starts in the editor panel.
1616 1450 *
1617 - * The dynamic portions of the hook name, `$stack_name` and `$section_id`, refers to the stack name and section ID, respectively.
1451 + * The dynamic portions of the hook name, `$section_name` and `$section_id`, refers to the section name and section ID, respectively.
1618 1452 *
1619 1453 * @since 1.4.0
1620 1454 *
1621 1455 * @param Controls_Stack $this The control.
@@ -1620,13 +1454,9 @@
1620 1454 *
1621 1455 * @param Controls_Stack $this The control.
1622 1456 * @param array $args Section arguments.
1623 1457 */
1624 - do_action( "elementor/element/{$stack_name}/{$section_id}/after_section_start", $this, $args );
1625 -
1626 - if ( $this->should_manually_trigger_common_action( $stack_name ) ) {
1627 - do_action( "elementor/element/common/{$section_id}/after_section_start", $this, $args );
1628 - }
1458 + do_action( "elementor/element/{$section_name}/{$section_id}/after_section_start", $this, $args );
1629 1459 }
1630 1460
1631 1461 /**
1632 1462 * End controls section.
@@ -1675,12 +1505,8 @@
1675 1505 * @param array $args Section arguments.
1676 1506 */
1677 1507 do_action( "elementor/element/{$stack_name}/{$section_id}/before_section_end", $this, $args );
1678 1508
1679 - if ( $this->should_manually_trigger_common_action( $stack_name ) ) {
1680 - do_action( "elementor/element/common/{$section_id}/before_section_end", $this, $args );
1681 - }
1682 -
1683 1509 $this->current_section = null;
1684 1510
1685 1511 /**
1686 1512 * After section end.
@@ -1699,9 +1525,9 @@
1699 1525 * After section end.
1700 1526 *
1701 1527 * Fires after Elementor section ends in the editor panel.
1702 1528 *
1703 - * The dynamic portions of the hook name, `$stack_name` and `$section_id`, refers to the stack name and section ID, respectively.
1529 + * The dynamic portions of the hook name, `$stack_name` and `$section_id`, refers to the section name and section ID, respectively.
1704 1530 *
1705 1531 * @since 1.4.0
1706 1532 *
1707 1533 * @param Controls_Stack $this The control.
@@ -1707,40 +1533,11 @@
1707 1533 * @param Controls_Stack $this The control.
1708 1534 * @param array $args Section arguments.
1709 1535 */
1710 1536 do_action( "elementor/element/{$stack_name}/{$section_id}/after_section_end", $this, $args );
1711 -
1712 - if ( $this->should_manually_trigger_common_action( $stack_name ) ) {
1713 - do_action( "elementor/element/common/{$section_id}/after_section_end", $this, $args );
1714 - }
1715 1537 }
1716 1538
1717 1539 /**
1718 - * Should manually trigger common action.
1719 - *
1720 - * With the Optimized Markup experiment, the Advanced Tab has been split to maintain backward compatibility:
1721 - * - 'common' refers to the existing Advanced Tab.
1722 - * - 'common-optimized' refers to the new Advanced Tab for optimized widgets.
1723 - *
1724 - * Third-party developers may have used hooks like 'elementor/element/common/_section_background/before_section_end'
1725 - * to add controls to the Advanced Tab. However, this hook will now only work on widgets that are not optimized.
1726 - *
1727 - * This method checks whether the 'elementor/element/common/...' hooks should be manually executed
1728 - * to prevent third parties from needing to add equivalent hooks for 'elementor/element/common-optimized/...'.
1729 - *
1730 - * @todo Remove this method and the manual execution of 'common' hooks when the feature is merged.
1731 - *
1732 - * @access private
1733 - *
1734 - * @param string $stack_name Stack name.
1735 - *
1736 - * @return bool
1737 - */
1738 - private function should_manually_trigger_common_action( $stack_name ): bool {
1739 - return 'common-optimized' === $stack_name && Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
1740 - }
1741 -
1742 - /**
1743 1540 * Start controls tabs.
1744 1541 *
1745 1542 * Used to add a new set of tabs inside a section. You should use this
1746 1543 * method before adding new individual tabs using `start_controls_tab()`.
@@ -2013,10 +1810,10 @@
2013 1810 *
2014 1811 * @since 2.7.0
2015 1812 * @access public
2016 1813 *
2017 - * @param string $element The HTML element.
2018 - * @param string $key Optional. Attribute key. Default is null.
1814 + * @param string $element The HTML element.
1815 + * @param string $key Optional. Attribute key. Default is null.
2019 1816 * @param array|string $values Optional. Attribute value/s. Default is null.
2020 1817 */
2021 1818 public function remove_render_attribute( $element, $key = null, $values = null ) {
2022 1819 if ( $key && ! isset( $this->render_attributes[ $element ][ $key ] ) ) {
@@ -2073,9 +1870,9 @@
2073 1870 *
2074 1871 * @param array|string $element The element.
2075 1872 */
2076 1873 public function print_render_attribute_string( $element ) {
2077 - Utils::print_unescaped_internal_string( $this->get_render_attribute_string( $element ) );
1874 + echo $this->get_render_attribute_string( $element ); // XSS ok.
2078 1875 }
2079 1876
2080 1877 /**
2081 1878 * Print element template.
@@ -2088,9 +1885,9 @@
2088 1885 public function print_template() {
2089 1886 ob_start();
2090 1887
2091 1888 // TODO: This is for backwards compatibility starting from 2.9.0
2092 - // This `if` statement should be removed when the method is removed.
1889 + // This `if` statement should be removed when the method is removed
2093 1890 if ( $this->has_own_method( '_content_template', self::class ) ) {
2094 1891 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_content_template', '2.9.0', __CLASS__ . '::content_template()' );
2095 1892
2096 1893 $this->_content_template();
@@ -2126,23 +1923,8 @@
2126 1923 <?php
2127 1924 }
2128 1925
2129 1926 /**
2130 - * On import update dynamic content (e.g. post and term IDs).
2131 - *
2132 - * @since 3.8.0
2133 - *
2134 - * @param array $config The config of the passed element.
2135 - * @param array $data The data that requires updating/replacement when imported.
2136 - * @param array|null $controls The available controls.
2137 - *
2138 - * @return array Element data.
2139 - */
2140 - public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ): array {
2141 - return $config;
2142 - }
2143 -
2144 - /**
2145 1927 * Start injection.
2146 1928 *
2147 1929 * Used to inject controls and sections to a specific position in the stack.
2148 1930 *
@@ -2217,12 +1999,12 @@
2217 1999 * `start_controls_tab()`.
2218 2000 *
2219 2001 * @since 1.4.0
2220 2002 * @access protected
2221 - * @deprecated 3.1.0 Use `register_controls()` method instead.
2003 + * @deprecated 3.1.0 Use `Controls_Stack::register_controls()` instead
2222 2004 */
2223 2005 protected function _register_controls() {
2224 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0', 'register_controls()' );
2006 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0', __CLASS__ . '::register_controls()' );
2225 2007
2226 2008 $this->register_controls();
2227 2009 }
2228 2010
@@ -2265,12 +2047,10 @@
2265 2047 */
2266 2048 protected function get_init_settings() {
2267 2049 $settings = $this->get_data( 'settings' );
2268 2050
2269 - $controls_objs = Plugin::$instance->controls_manager->get_controls();
2270 -
2271 2051 foreach ( $this->get_controls() as $control ) {
2272 - $control_obj = $controls_objs[ $control['type'] ] ?? null;
2052 + $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] );
2273 2053
2274 2054 if ( ! $control_obj instanceof Base_Data_Control ) {
2275 2055 continue;
2276 2056 }
@@ -2306,15 +2086,15 @@
2306 2086 * Retrieve the current element initial configuration - controls list and
2307 2087 * the tabs assigned to the control.
2308 2088 *
2309 2089 * @since 1.4.0
2310 - * @deprecated 2.9.0 Use `get_initial_config()` method instead.
2090 + * @deprecated 2.9.0 use `get_initial_config()` instead
2311 2091 * @access protected
2312 2092 *
2313 2093 * @return array The initial config.
2314 2094 */
2315 2095 protected function _get_initial_config() {
2316 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', 'get_initial_config()' );
2096 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', __CLASS__ . '::get_initial_config()' );
2317 2097
2318 2098 return $this->get_initial_config();
2319 2099 }
2320 2100
@@ -2385,9 +2165,9 @@
2385 2165 *
2386 2166 * @param string $template_content Template content.
2387 2167 */
2388 2168 protected function print_template_content( $template_content ) {
2389 - Utils::print_unescaped_internal_string( $template_content );
2169 + echo $template_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2390 2170 }
2391 2171
2392 2172 /**
2393 2173 * Render element output in the editor.
@@ -2404,13 +2184,13 @@
2404 2184 *
2405 2185 * Used to generate the live preview, using a Backbone JavaScript template.
2406 2186 *
2407 2187 * @since 2.0.0
2408 - * @deprecated 2.9.0 Use `content_template()` method instead.
2188 + * @deprecated 2.9.0 use `content_template()` instead
2409 2189 * @access protected
2410 2190 */
2411 2191 protected function _content_template() {
2412 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', 'content_template()' );
2192 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', __CLASS__ . '::content_template()' );
2413 2193
2414 2194 $this->content_template();
2415 2195 }
2416 2196
@@ -2425,9 +2205,9 @@
2425 2205 protected function init_controls() {
2426 2206 Plugin::$instance->controls_manager->open_stack( $this );
2427 2207
2428 2208 // TODO: This is for backwards compatibility starting from 2.9.0
2429 - // This `if` statement should be removed when the method is removed.
2209 + // This `if` statement should be removed when the method is removed
2430 2210 if ( $this->has_own_method( '_register_controls', self::class ) ) {
2431 2211 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_register_controls', '3.1.0', __CLASS__ . '::register_controls()' );
2432 2212
2433 2213 $this->_register_controls();
@@ -2463,11 +2243,9 @@
2463 2243 if ( null !== $target_tab ) {
2464 2244 $args = array_replace_recursive( $target_tab, $args );
2465 2245 }
2466 2246 } elseif ( empty( $args['section'] ) && ( ! $overwrite || is_wp_error( Plugin::$instance->controls_manager->get_control_from_stack( $this->get_unique_name(), $control_id ) ) ) ) {
2467 - if ( ! Performance::should_optimize_controls() ) {
2468 - wp_die( sprintf( '%s::%s: Cannot add a control outside of a section (use `start_controls_section`).', get_called_class(), __FUNCTION__ ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2469 - }
2247 + wp_die( sprintf( '%s::%s: Cannot add a control outside of a section (use `start_controls_section`).', get_called_class(), __FUNCTION__ ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2470 2248 }
2471 2249
2472 2250 return $args;
2473 2251 }
@@ -2493,15 +2271,15 @@
2493 2271 *
2494 2272 * Set the raw data, the ID and the parsed settings.
2495 2273 *
2496 2274 * @since 1.4.0
2497 - * @deprecated 2.9.0 Use `init()` method instead.
2275 + * @deprecated 2.9.0 use `init()` instead
2498 2276 * @access protected
2499 2277 *
2500 2278 * @param array $data Initial data.
2501 2279 */
2502 2280 protected function _init( $data ) {
2503 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', 'init()' );
2281 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', __CLASS__ . '::init()' );
2504 2282
2505 2283 $this->init( $data );
2506 2284 }
2507 2285
@@ -2572,9 +2350,9 @@
2572 2350 */
2573 2351 public function __construct( array $data = [] ) {
2574 2352 if ( $data ) {
2575 2353 // TODO: This is for backwards compatibility starting from 2.9.0
2576 - // This if statement should be removed when the method is hard-deprecated.
2354 + // This if statement should be removed when the method is hard-deprecated
2577 2355 if ( $this->has_own_method( '_init', self::class ) ) {
2578 2356 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_init', '2.9.0', __CLASS__ . '::init()' );
2579 2357
2580 2358 $this->_init( $data );