PluginProbe
Elementor Website Builder – more than just a page builder / 3.5.6
Elementor Website Builder – more than just a page builder v3.5.6
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 +80 -275 4.2.0-dev23.5.6 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 }
@@ -226,26 +225,12 @@
226 225 public function get_id_int() {
227 226 /** We ignore possible notices, in order to support elements created prior to v1.8.0 and might include
228 227 * non-base 16 characters as part of their ID.
229 228 */
230 - return @hexdec( (string) $this->id );
229 + return @hexdec( $this->id );
231 230 }
232 231
233 232 /**
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 233 * Get the type.
249 234 *
250 235 * Retrieve the type, e.g. 'stack', 'section', 'widget' etc.
251 236 *
@@ -311,26 +296,9 @@
311 296 *
312 297 * @return mixed Controls list.
313 298 */
314 299 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 );
300 + return self::get_items( $this->get_stack()['controls'], $control_id );
333 301 }
334 302
335 303 /**
336 304 * Get active controls.
@@ -349,10 +317,10 @@
349 317 * @param array $settings Optional. Controls settings. Default is null.
350 318 *
351 319 * @return array Active controls.
352 320 */
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' );
321 + public function get_active_controls( array $controls = null, array $settings = null ) {
322 + // _deprecated_function( __METHOD__, '3.0.0' );
355 323
356 324 if ( ! $controls ) {
357 325 $controls = $this->get_controls();
358 326 }
@@ -364,9 +332,9 @@
364 332 $active_controls = array_reduce(
365 333 array_keys( $controls ), function( $active_controls, $control_key ) use ( $controls, $settings ) {
366 334 $control = $controls[ $control_key ];
367 335
368 - if ( $this->is_control_visible( $control, $settings, $controls ) ) {
336 + if ( $this->is_control_visible( $control, $settings ) ) {
369 337 $active_controls[ $control_key ] = $control;
370 338 }
371 339
372 340 return $active_controls;
@@ -439,58 +407,14 @@
439 407 }
440 408
441 409 unset( $options['position'] );
442 410
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,
411 + if ( $this->current_popover && ! $this->current_popover['initialized'] ) {
412 + $args['popover'] = [
413 + 'start' => true,
462 414 ];
463 415
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 - );
416 + $this->current_popover['initialized'] = true;
493 417 }
494 418
495 419 return Plugin::$instance->controls_manager->add_control_to_stack( $this, $id, $args, $options );
496 420 }
@@ -612,10 +536,10 @@
612 536
613 537 $position = array_merge( $default_position, $position );
614 538
615 539 if (
616 - ( 'control' === $position['type'] && in_array( $position['at'], [ 'start', 'end' ], true ) ) ||
617 - ( 'section' === $position['type'] && in_array( $position['at'], [ 'before', 'after' ], true ) )
540 + 'control' === $position['type'] && in_array( $position['at'], [ 'start', 'end' ], true ) ||
541 + 'section' === $position['type'] && in_array( $position['at'], [ 'before', 'after' ], true )
618 542 ) {
619 543 _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 544
621 545 return false;
@@ -637,13 +561,13 @@
637 561
638 562 $controls_keys = array_keys( $registered_controls );
639 563
640 564 while ( Controls_Manager::SECTION !== $registered_controls[ $controls_keys[ $target_section_index ] ]['type'] ) {
641 - --$target_section_index;
565 + $target_section_index--;
642 566 }
643 567
644 568 if ( 'section' === $position['type'] ) {
645 - ++$target_control_index;
569 + $target_control_index++;
646 570
647 571 if ( 'end' === $position['at'] ) {
648 572 while ( Controls_Manager::SECTION !== $registered_controls[ $controls_keys[ $target_control_index ] ]['type'] ) {
649 573 if ( ++$target_control_index >= count( $registered_controls ) ) {
@@ -655,9 +579,9 @@
655 579
656 580 $target_control = $registered_controls[ $controls_keys[ $target_control_index ] ];
657 581
658 582 if ( 'after' === $position['at'] ) {
659 - ++$target_control_index;
583 + $target_control_index++;
660 584 }
661 585
662 586 $section_id = $registered_controls[ $controls_keys[ $target_section_index ] ]['name'];
663 587
@@ -737,9 +661,9 @@
737 661
738 662 $controls_keys = array_keys( $registered_controls );
739 663
740 664 while ( true ) {
741 - ++$section_index;
665 + $section_index++;
742 666
743 667 if ( ! isset( $controls_keys[ $section_index ] ) ) {
744 668 break;
745 669 }
@@ -750,9 +674,9 @@
750 674 break;
751 675 }
752 676
753 677 $section_controls[ $control_key ] = $registered_controls[ $control_key ];
754 - }
678 + };
755 679
756 680 return $section_controls;
757 681 }
758 682
@@ -781,8 +705,30 @@
781 705 $group->add_controls( $this, $args, $options );
782 706 }
783 707
784 708 /**
709 + * Get scheme controls.
710 + *
711 + * Retrieve all the controls that use schemes.
712 + *
713 + * @since 1.4.0
714 + * @access public
715 + * @deprecated 3.0.0
716 + *
717 + * @return array Scheme controls.
718 + */
719 + final public function get_scheme_controls() {
720 + // _deprecated_function( __METHOD__, '3.0.0' );
721 + $enabled_schemes = Schemes_Manager::get_enabled_schemes();
722 +
723 + return array_filter(
724 + $this->get_controls(), function( $control ) use ( $enabled_schemes ) {
725 + return ( ! empty( $control['scheme'] ) && in_array( $control['scheme']['type'], $enabled_schemes ) );
726 + }
727 + );
728 + }
729 +
730 + /**
785 731 * Get style controls.
786 732 *
787 733 * Retrieve style controls for all active controls or, when requested, from
788 734 * a specific set of controls.
@@ -796,10 +742,10 @@
796 742 * @param array $settings Optional. Controls settings. Default is null.
797 743 *
798 744 * @return array Style controls.
799 745 */
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' );
746 + final public function get_style_controls( array $controls = null, array $settings = null ) {
747 + // _deprecated_function( __METHOD__, '3.0.0' );
802 748
803 749 $controls = $this->get_active_controls( $controls, $settings );
804 750
805 751 $style_controls = [];
@@ -869,12 +815,9 @@
869 815 $args['responsive'] = [];
870 816
871 817 $active_breakpoints = Plugin::$instance->breakpoints->get_active_breakpoints();
872 818
873 - $devices = Plugin::$instance->breakpoints->get_active_devices_list( [
874 - 'reverse' => true,
875 - 'desktop_first' => true,
876 - ] );
819 + $devices = Plugin::$instance->breakpoints->get_active_devices_list( [ 'reverse' => true ] );
877 820
878 821 if ( isset( $args['devices'] ) ) {
879 822 $devices = array_intersect( $devices, $args['devices'] );
880 823
@@ -930,14 +873,9 @@
930 873 foreach ( $devices as $device_name ) {
931 874 $control_args = $args;
932 875
933 876 // 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 - }
877 + $control_args['parent'] = isset( $control_name ) ? $control_name : null;
940 878
941 879 if ( isset( $control_args['device_args'] ) ) {
942 880 if ( ! empty( $control_args['device_args'][ $device_name ] ) ) {
943 881 $control_args = array_merge( $control_args, $control_args['device_args'][ $device_name ] );
@@ -979,11 +917,9 @@
979 917 $id_suffix = Breakpoints_Manager::BREAKPOINT_KEY_DESKTOP === $device_name ? '' : '_' . $device_name;
980 918 $control_name = $id . $id_suffix;
981 919
982 920 // 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 - }
921 + $this->update_control( $control_args['parent'], [ 'inheritors' => [ $control_name ] ] );
986 922
987 923 if ( ! empty( $options['overwrite'] ) ) {
988 924 $this->update_control( $control_name, $control_args, [
989 925 'recursive' => ! empty( $options['recursive'] ),
@@ -1060,10 +996,10 @@
1060 996 * @return array|null The config.
1061 997 */
1062 998 final public function get_config() {
1063 999 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.
1000 + // TODO: This is for backwards compatibility starting from 2.9.0
1001 + // This if statement should be removed when the method is hard-deprecated
1066 1002 if ( $this->has_own_method( '_get_initial_config', self::class ) ) {
1067 1003 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_get_initial_config', '2.9.0', __CLASS__ . '::get_initial_config()' );
1068 1004
1069 1005 $this->config = $this->_get_initial_config();
@@ -1087,10 +1023,8 @@
1087 1023 * Set a config property.
1088 1024 *
1089 1025 * Set a specific property of the config list for this controls-stack.
1090 1026 *
1091 - * @param string $key
1092 - * @param string $value
1093 1027 * @since 3.5.0
1094 1028 * @access public
1095 1029 */
1096 1030 public function set_config( $key, $value ) {
@@ -1166,11 +1100,8 @@
1166 1100 return self::get_items( $this->data, $item );
1167 1101 }
1168 1102
1169 1103 /**
1170 - * @param null $setting
1171 - * @param null $settings
1172 - * @return array|mixed|null
1173 1104 * @since 2.0.14
1174 1105 * @access public
1175 1106 */
1176 1107 public function get_parsed_dynamic_settings( $setting = null, $settings = null ) {
@@ -1184,28 +1115,21 @@
1184 1115
1185 1116 return self::get_items( $this->parsed_dynamic_settings, $setting );
1186 1117 }
1187 1118
1188 - public function reset_render_state(): void {
1189 - $this->active_settings = null;
1190 - $this->parsed_active_settings = null;
1191 - $this->parsed_dynamic_settings = null;
1192 - $this->render_attributes = [];
1193 - }
1194 -
1195 1119 /**
1196 1120 * Get active settings.
1197 1121 *
1198 1122 * Retrieve the settings from all the active controls.
1199 1123 *
1200 - * @param array|null $settings Optional. Controls settings. Default is null.
1201 - * @param array|null $controls Optional. An array of controls. Default is null.
1202 - *
1203 - * @return array Active settings.
1124 + * @since 1.4.0
1204 1125 * @since 2.1.0 Added the `controls` and the `settings` parameters.
1205 1126 * @access public
1206 1127 *
1207 - * @since 1.4.0
1128 + * @param array $controls Optional. An array of controls. Default is null.
1129 + * @param array $settings Optional. Controls settings. Default is null.
1130 + *
1131 + * @return array Active settings.
1208 1132 */
1209 1133 public function get_active_settings( $settings = null, $controls = null ) {
1210 1134 $is_first_request = ! $settings && ! $this->active_settings;
1211 1135
@@ -1220,10 +1144,8 @@
1220 1144 }
1221 1145
1222 1146 $active_settings = [];
1223 1147
1224 - $controls_objs = Plugin::$instance->controls_manager->get_controls();
1225 -
1226 1148 foreach ( $settings as $setting_key => $setting ) {
1227 1149 if ( ! isset( $controls[ $setting_key ] ) ) {
1228 1150 $active_settings[ $setting_key ] = $setting;
1229 1151
@@ -1231,10 +1153,10 @@
1231 1153 }
1232 1154
1233 1155 $control = $controls[ $setting_key ];
1234 1156
1235 - if ( $this->is_control_visible( $control, $settings, $controls ) ) {
1236 - $control_obj = $controls_objs[ $control['type'] ] ?? null;
1157 + if ( $this->is_control_visible( $control, $settings ) ) {
1158 + $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] );
1237 1159
1238 1160 if ( $control_obj instanceof Control_Repeater ) {
1239 1161 foreach ( $setting as & $item ) {
1240 1162 $item = $this->get_active_settings( $item, $control['fields'] );
@@ -1301,13 +1223,11 @@
1301 1223 if ( null === $controls ) {
1302 1224 $controls = $this->get_controls();
1303 1225 }
1304 1226
1305 - $controls_objs = Plugin::$instance->controls_manager->get_controls();
1306 -
1307 1227 foreach ( $controls as $control ) {
1308 1228 $control_name = $control['name'];
1309 - $control_obj = $controls_objs[ $control['type'] ] ?? null;
1229 + $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] );
1310 1230
1311 1231 if ( ! $control_obj instanceof Base_Data_Control ) {
1312 1232 continue;
1313 1233 }
@@ -1417,33 +1337,21 @@
1417 1337 );
1418 1338 }
1419 1339
1420 1340 /**
1421 - * Get Responsive Control Device Suffix
1422 - *
1423 - * @deprecated 3.7.6 Use `Elementor\Controls_Manager::get_responsive_control_device_suffix()` instead.
1424 - * @param array $control
1425 - * @return string $device suffix
1426 - */
1427 - protected function get_responsive_control_device_suffix( $control ) {
1428 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.7.6', 'Elementor\Controls_Manager::get_responsive_control_device_suffix()' );
1429 -
1430 - return Controls_Manager::get_responsive_control_device_suffix( $control );
1431 - }
1432 -
1433 - /**
1434 1341 * Whether the control is visible or not.
1435 1342 *
1436 1343 * Used to determine whether the control is visible or not.
1437 1344 *
1345 + * @since 1.4.0
1346 + * @access public
1347 + *
1438 1348 * @param array $control The control.
1439 - * @param null $values Optional. Condition values. Default is null.
1440 - * @param null $controls
1349 + * @param array $values Optional. Condition values. Default is null.
1350 + *
1441 1351 * @return bool Whether the control is visible.
1442 - * @since 1.4.0
1443 - * @access public
1444 1352 */
1445 - public function is_control_visible( $control, $values = null, $controls = null ) {
1353 + public function is_control_visible( $control, $values = null ) {
1446 1354 if ( null === $values ) {
1447 1355 $values = $this->get_settings();
1448 1356 }
1449 1357
@@ -1454,37 +1362,21 @@
1454 1362 if ( empty( $control['condition'] ) ) {
1455 1363 return true;
1456 1364 }
1457 1365
1458 - if ( ! $controls ) {
1459 - $controls = $this->get_controls();
1460 - }
1461 -
1462 1366 foreach ( $control['condition'] as $condition_key => $condition_value ) {
1463 1367 preg_match( '/([a-z_\-0-9]+)(?:\[([a-z_]+)])?(!?)$/i', $condition_key, $condition_key_parts );
1464 1368
1465 1369 $pure_condition_key = $condition_key_parts[1];
1466 1370 $condition_sub_key = $condition_key_parts[2];
1467 - $is_negative_condition = (bool) $condition_key_parts[3];
1371 + $is_negative_condition = ! ! $condition_key_parts[3];
1468 1372
1469 1373 if ( ! isset( $values[ $pure_condition_key ] ) || null === $values[ $pure_condition_key ] ) {
1470 1374 return false;
1471 1375 }
1472 1376
1473 - $are_control_and_condition_responsive = isset( $control['responsive'] ) && ! empty( $controls[ $pure_condition_key ]['responsive'] );
1474 - $condition_name_to_check = $pure_condition_key;
1377 + $instance_value = $values[ $pure_condition_key ];
1475 1378
1476 - if ( $are_control_and_condition_responsive ) {
1477 - $device_suffix = Controls_Manager::get_responsive_control_device_suffix( $control );
1478 -
1479 - $condition_name_to_check = $pure_condition_key . $device_suffix;
1480 -
1481 - // If the control is not desktop, and a conditioning control for the corresponding device exists, use it.
1482 - $instance_value = $values[ $pure_condition_key . $device_suffix ] ?? $values[ $pure_condition_key ];
1483 - } else {
1484 - $instance_value = $values[ $pure_condition_key ];
1485 - }
1486 -
1487 1379 if ( $condition_sub_key && is_array( $instance_value ) ) {
1488 1380 if ( ! isset( $instance_value[ $condition_sub_key ] ) ) {
1489 1381 return false;
1490 1382 }
@@ -1491,32 +1383,8 @@
1491 1383
1492 1384 $instance_value = $instance_value[ $condition_sub_key ];
1493 1385 }
1494 1386
1495 - if ( ! $instance_value ) {
1496 - $parent = isset( $controls[ $condition_name_to_check ]['parent'] ) ? $controls[ $condition_name_to_check ]['parent'] : false;
1497 -
1498 - while ( $parent ) {
1499 - $instance_value = $values[ $parent ];
1500 -
1501 - if ( $instance_value ) {
1502 - if ( ! is_array( $instance_value ) ) {
1503 - break;
1504 - }
1505 -
1506 - if ( $condition_sub_key && isset( $instance_value[ $condition_sub_key ] ) ) {
1507 - $instance_value = $instance_value[ $condition_sub_key ];
1508 -
1509 - if ( '' !== $instance_value ) {
1510 - break;
1511 - }
1512 - }
1513 - }
1514 -
1515 - $parent = isset( $controls[ $parent ]['parent'] ) ? $controls[ $parent ]['parent'] : false;
1516 - }
1517 - }
1518 -
1519 1387 /**
1520 1388 * If the $condition_value is a non empty array - check if the $condition_value contains the $instance_value,
1521 1389 * If the $instance_value is a non empty array - check if the $instance_value contains the $condition_value
1522 1390 * otherwise check if they are equal. ( and give the ability to check if the value is an empty array )
@@ -1528,12 +1396,9 @@
1528 1396 } else {
1529 1397 $is_contains = $instance_value === $condition_value;
1530 1398 }
1531 1399
1532 - if (
1533 - ( $is_negative_condition && $is_contains ) ||
1534 - ( ! $is_negative_condition && ! $is_contains )
1535 - ) {
1400 + if ( $is_negative_condition && $is_contains || ! $is_negative_condition && ! $is_contains ) {
1536 1401 return false;
1537 1402 }
1538 1403 }
1539 1404
@@ -1584,12 +1449,8 @@
1584 1449 * @param array $args Section arguments.
1585 1450 */
1586 1451 do_action( "elementor/element/{$stack_name}/{$section_id}/before_section_start", $this, $args );
1587 1452
1588 - if ( $this->should_manually_trigger_common_action( $stack_name ) ) {
1589 - do_action( "elementor/element/common/{$section_id}/before_section_start", $this, $args );
1590 - }
1591 -
1592 1453 $args['type'] = Controls_Manager::SECTION;
1593 1454
1594 1455 $this->add_control( $section_id, $args );
1595 1456
@@ -1628,12 +1489,8 @@
1628 1489 * @param Controls_Stack $this The control.
1629 1490 * @param array $args Section arguments.
1630 1491 */
1631 1492 do_action( "elementor/element/{$stack_name}/{$section_id}/after_section_start", $this, $args );
1632 -
1633 - if ( $this->should_manually_trigger_common_action( $stack_name ) ) {
1634 - do_action( "elementor/element/common/{$section_id}/after_section_start", $this, $args );
1635 - }
1636 1493 }
1637 1494
1638 1495 /**
1639 1496 * End controls section.
@@ -1682,12 +1539,8 @@
1682 1539 * @param array $args Section arguments.
1683 1540 */
1684 1541 do_action( "elementor/element/{$stack_name}/{$section_id}/before_section_end", $this, $args );
1685 1542
1686 - if ( $this->should_manually_trigger_common_action( $stack_name ) ) {
1687 - do_action( "elementor/element/common/{$section_id}/before_section_end", $this, $args );
1688 - }
1689 -
1690 1543 $this->current_section = null;
1691 1544
1692 1545 /**
1693 1546 * After section end.
@@ -1714,40 +1567,11 @@
1714 1567 * @param Controls_Stack $this The control.
1715 1568 * @param array $args Section arguments.
1716 1569 */
1717 1570 do_action( "elementor/element/{$stack_name}/{$section_id}/after_section_end", $this, $args );
1718 -
1719 - if ( $this->should_manually_trigger_common_action( $stack_name ) ) {
1720 - do_action( "elementor/element/common/{$section_id}/after_section_end", $this, $args );
1721 - }
1722 1571 }
1723 1572
1724 1573 /**
1725 - * Should manually trigger common action.
1726 - *
1727 - * With the Optimized Markup experiment, the Advanced Tab has been split to maintain backward compatibility:
1728 - * - 'common' refers to the existing Advanced Tab.
1729 - * - 'common-optimized' refers to the new Advanced Tab for optimized widgets.
1730 - *
1731 - * Third-party developers may have used hooks like 'elementor/element/common/_section_background/before_section_end'
1732 - * to add controls to the Advanced Tab. However, this hook will now only work on widgets that are not optimized.
1733 - *
1734 - * This method checks whether the 'elementor/element/common/...' hooks should be manually executed
1735 - * to prevent third parties from needing to add equivalent hooks for 'elementor/element/common-optimized/...'.
1736 - *
1737 - * @todo Remove this method and the manual execution of 'common' hooks when the feature is merged.
1738 - *
1739 - * @access private
1740 - *
1741 - * @param string $stack_name Stack name.
1742 - *
1743 - * @return bool
1744 - */
1745 - private function should_manually_trigger_common_action( $stack_name ): bool {
1746 - return 'common-optimized' === $stack_name && Plugin::$instance->experiments->is_feature_active( 'e_optimized_markup' );
1747 - }
1748 -
1749 - /**
1750 1574 * Start controls tabs.
1751 1575 *
1752 1576 * Used to add a new set of tabs inside a section. You should use this
1753 1577 * method before adding new individual tabs using `start_controls_tab()`.
@@ -2020,10 +1844,10 @@
2020 1844 *
2021 1845 * @since 2.7.0
2022 1846 * @access public
2023 1847 *
2024 - * @param string $element The HTML element.
2025 - * @param string $key Optional. Attribute key. Default is null.
1848 + * @param string $element The HTML element.
1849 + * @param string $key Optional. Attribute key. Default is null.
2026 1850 * @param array|string $values Optional. Attribute value/s. Default is null.
2027 1851 */
2028 1852 public function remove_render_attribute( $element, $key = null, $values = null ) {
2029 1853 if ( $key && ! isset( $this->render_attributes[ $element ][ $key ] ) ) {
@@ -2080,9 +1904,9 @@
2080 1904 *
2081 1905 * @param array|string $element The element.
2082 1906 */
2083 1907 public function print_render_attribute_string( $element ) {
2084 - Utils::print_unescaped_internal_string( $this->get_render_attribute_string( $element ) );
1908 + echo $this->get_render_attribute_string( $element ); // XSS ok.
2085 1909 }
2086 1910
2087 1911 /**
2088 1912 * Print element template.
@@ -2095,9 +1919,9 @@
2095 1919 public function print_template() {
2096 1920 ob_start();
2097 1921
2098 1922 // TODO: This is for backwards compatibility starting from 2.9.0
2099 - // This `if` statement should be removed when the method is removed.
1923 + // This `if` statement should be removed when the method is removed
2100 1924 if ( $this->has_own_method( '_content_template', self::class ) ) {
2101 1925 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_content_template', '2.9.0', __CLASS__ . '::content_template()' );
2102 1926
2103 1927 $this->_content_template();
@@ -2133,23 +1957,8 @@
2133 1957 <?php
2134 1958 }
2135 1959
2136 1960 /**
2137 - * On import update dynamic content (e.g. post and term IDs).
2138 - *
2139 - * @since 3.8.0
2140 - *
2141 - * @param array $config The config of the passed element.
2142 - * @param array $data The data that requires updating/replacement when imported.
2143 - * @param array|null $controls The available controls.
2144 - *
2145 - * @return array Element data.
2146 - */
2147 - public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ): array {
2148 - return $config;
2149 - }
2150 -
2151 - /**
2152 1961 * Start injection.
2153 1962 *
2154 1963 * Used to inject controls and sections to a specific position in the stack.
2155 1964 *
@@ -2224,12 +2033,12 @@
2224 2033 * `start_controls_tab()`.
2225 2034 *
2226 2035 * @since 1.4.0
2227 2036 * @access protected
2228 - * @deprecated 3.1.0 Use `register_controls()` method instead.
2037 + * @deprecated 3.1.0 Use `Controls_Stack::register_controls()` instead
2229 2038 */
2230 2039 protected function _register_controls() {
2231 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0', 'register_controls()' );
2040 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0', __CLASS__ . '::register_controls()' );
2232 2041
2233 2042 $this->register_controls();
2234 2043 }
2235 2044
@@ -2272,12 +2081,10 @@
2272 2081 */
2273 2082 protected function get_init_settings() {
2274 2083 $settings = $this->get_data( 'settings' );
2275 2084
2276 - $controls_objs = Plugin::$instance->controls_manager->get_controls();
2277 -
2278 2085 foreach ( $this->get_controls() as $control ) {
2279 - $control_obj = $controls_objs[ $control['type'] ] ?? null;
2086 + $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] );
2280 2087
2281 2088 if ( ! $control_obj instanceof Base_Data_Control ) {
2282 2089 continue;
2283 2090 }
@@ -2313,15 +2120,15 @@
2313 2120 * Retrieve the current element initial configuration - controls list and
2314 2121 * the tabs assigned to the control.
2315 2122 *
2316 2123 * @since 1.4.0
2317 - * @deprecated 2.9.0 Use `get_initial_config()` method instead.
2124 + * @deprecated 2.9.0 use `get_initial_config()` instead
2318 2125 * @access protected
2319 2126 *
2320 2127 * @return array The initial config.
2321 2128 */
2322 2129 protected function _get_initial_config() {
2323 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', 'get_initial_config()' );
2130 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', __CLASS__ . '::get_initial_config()' );
2324 2131
2325 2132 return $this->get_initial_config();
2326 2133 }
2327 2134
@@ -2392,9 +2199,9 @@
2392 2199 *
2393 2200 * @param string $template_content Template content.
2394 2201 */
2395 2202 protected function print_template_content( $template_content ) {
2396 - Utils::print_unescaped_internal_string( $template_content );
2203 + echo $template_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2397 2204 }
2398 2205
2399 2206 /**
2400 2207 * Render element output in the editor.
@@ -2411,13 +2218,13 @@
2411 2218 *
2412 2219 * Used to generate the live preview, using a Backbone JavaScript template.
2413 2220 *
2414 2221 * @since 2.0.0
2415 - * @deprecated 2.9.0 Use `content_template()` method instead.
2222 + * @deprecated 2.9.0 use `content_template()` instead
2416 2223 * @access protected
2417 2224 */
2418 2225 protected function _content_template() {
2419 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', 'content_template()' );
2226 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', __CLASS__ . '::content_template()' );
2420 2227
2421 2228 $this->content_template();
2422 2229 }
2423 2230
@@ -2432,9 +2239,9 @@
2432 2239 protected function init_controls() {
2433 2240 Plugin::$instance->controls_manager->open_stack( $this );
2434 2241
2435 2242 // TODO: This is for backwards compatibility starting from 2.9.0
2436 - // This `if` statement should be removed when the method is removed.
2243 + // This `if` statement should be removed when the method is removed
2437 2244 if ( $this->has_own_method( '_register_controls', self::class ) ) {
2438 2245 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_register_controls', '3.1.0', __CLASS__ . '::register_controls()' );
2439 2246
2440 2247 $this->_register_controls();
@@ -2470,11 +2277,9 @@
2470 2277 if ( null !== $target_tab ) {
2471 2278 $args = array_replace_recursive( $target_tab, $args );
2472 2279 }
2473 2280 } elseif ( empty( $args['section'] ) && ( ! $overwrite || is_wp_error( Plugin::$instance->controls_manager->get_control_from_stack( $this->get_unique_name(), $control_id ) ) ) ) {
2474 - if ( ! Performance::should_optimize_controls() ) {
2475 - 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
2476 - }
2281 + 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
2477 2282 }
2478 2283
2479 2284 return $args;
2480 2285 }
@@ -2500,15 +2305,15 @@
2500 2305 *
2501 2306 * Set the raw data, the ID and the parsed settings.
2502 2307 *
2503 2308 * @since 1.4.0
2504 - * @deprecated 2.9.0 Use `init()` method instead.
2309 + * @deprecated 2.9.0 use `init()` instead
2505 2310 * @access protected
2506 2311 *
2507 2312 * @param array $data Initial data.
2508 2313 */
2509 2314 protected function _init( $data ) {
2510 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', 'init()' );
2315 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', __CLASS__ . '::init()' );
2511 2316
2512 2317 $this->init( $data );
2513 2318 }
2514 2319
@@ -2579,9 +2384,9 @@
2579 2384 */
2580 2385 public function __construct( array $data = [] ) {
2581 2386 if ( $data ) {
2582 2387 // TODO: This is for backwards compatibility starting from 2.9.0
2583 - // This if statement should be removed when the method is hard-deprecated.
2388 + // This if statement should be removed when the method is hard-deprecated
2584 2389 if ( $this->has_own_method( '_init', self::class ) ) {
2585 2390 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_init', '2.9.0', __CLASS__ . '::init()' );
2586 2391
2587 2392 $this->_init( $data );