PluginProbe
Elementor Website Builder – more than just a page builder / 3.7.2
Elementor Website Builder – more than just a page builder v3.7.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/base/controls-stack.php +87 -240 4.0.73.7.2 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 }
@@ -230,22 +229,8 @@
230 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,9 +317,9 @@
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 ) {
321 + public function get_active_controls( array $controls = null, array $settings = null ) {
354 322 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.0.0' );
355 323
356 324 if ( ! $controls ) {
357 325 $controls = $this->get_controls();
@@ -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;
@@ -449,50 +417,8 @@
449 417 $this->current_popover['initialized'] = true;
450 418 }
451 419 }
452 420
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,
462 - ];
463 -
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 - );
493 - }
494 -
495 421 return Plugin::$instance->controls_manager->add_control_to_stack( $this, $id, $args, $options );
496 422 }
497 423
498 424 /**
@@ -612,10 +538,10 @@
612 538
613 539 $position = array_merge( $default_position, $position );
614 540
615 541 if (
616 - ( 'control' === $position['type'] && in_array( $position['at'], [ 'start', 'end' ], true ) ) ||
617 - ( 'section' === $position['type'] && in_array( $position['at'], [ 'before', 'after' ], true ) )
542 + 'control' === $position['type'] && in_array( $position['at'], [ 'start', 'end' ], true ) ||
543 + 'section' === $position['type'] && in_array( $position['at'], [ 'before', 'after' ], true )
618 544 ) {
619 545 _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 546
621 547 return false;
@@ -637,13 +563,13 @@
637 563
638 564 $controls_keys = array_keys( $registered_controls );
639 565
640 566 while ( Controls_Manager::SECTION !== $registered_controls[ $controls_keys[ $target_section_index ] ]['type'] ) {
641 - --$target_section_index;
567 + $target_section_index--;
642 568 }
643 569
644 570 if ( 'section' === $position['type'] ) {
645 - ++$target_control_index;
571 + $target_control_index++;
646 572
647 573 if ( 'end' === $position['at'] ) {
648 574 while ( Controls_Manager::SECTION !== $registered_controls[ $controls_keys[ $target_control_index ] ]['type'] ) {
649 575 if ( ++$target_control_index >= count( $registered_controls ) ) {
@@ -655,9 +581,9 @@
655 581
656 582 $target_control = $registered_controls[ $controls_keys[ $target_control_index ] ];
657 583
658 584 if ( 'after' === $position['at'] ) {
659 - ++$target_control_index;
585 + $target_control_index++;
660 586 }
661 587
662 588 $section_id = $registered_controls[ $controls_keys[ $target_section_index ] ]['name'];
663 589
@@ -737,9 +663,9 @@
737 663
738 664 $controls_keys = array_keys( $registered_controls );
739 665
740 666 while ( true ) {
741 - ++$section_index;
667 + $section_index++;
742 668
743 669 if ( ! isset( $controls_keys[ $section_index ] ) ) {
744 670 break;
745 671 }
@@ -750,9 +676,9 @@
750 676 break;
751 677 }
752 678
753 679 $section_controls[ $control_key ] = $registered_controls[ $control_key ];
754 - }
680 + };
755 681
756 682 return $section_controls;
757 683 }
758 684
@@ -781,8 +707,32 @@
781 707 $group->add_controls( $this, $args, $options );
782 708 }
783 709
784 710 /**
711 + * Get scheme controls.
712 + *
713 + * Retrieve all the controls that use schemes.
714 + *
715 + * @since 1.4.0
716 + * @access public
717 + * @deprecated 3.0.0
718 + *
719 + * @return array Scheme controls.
720 + */
721 + final public function get_scheme_controls() {
722 +
723 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.0.0' );
724 +
725 + $enabled_schemes = Schemes_Manager::get_enabled_schemes();
726 +
727 + return array_filter(
728 + $this->get_controls(), function ( $control ) use ( $enabled_schemes ) {
729 + return ( ! empty( $control['scheme'] ) && in_array( $control['scheme']['type'], $enabled_schemes ) );
730 + }
731 + );
732 + }
733 +
734 + /**
785 735 * Get style controls.
786 736 *
787 737 * Retrieve style controls for all active controls or, when requested, from
788 738 * a specific set of controls.
@@ -796,9 +746,9 @@
796 746 * @param array $settings Optional. Controls settings. Default is null.
797 747 *
798 748 * @return array Style controls.
799 749 */
800 - final public function get_style_controls( ?array $controls = null, ?array $settings = null ) {
750 + final public function get_style_controls( array $controls = null, array $settings = null ) {
801 751 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.0.0' );
802 752
803 753 $controls = $this->get_active_controls( $controls, $settings );
804 754
@@ -931,9 +881,9 @@
931 881 $control_args = $args;
932 882
933 883 // Set parent using the name from previous iteration.
934 884 if ( isset( $control_name ) ) {
935 - // If $control_name end with _widescreen use desktop name instead.
885 + // If $control_name end with _widescreen use desktop name instead
936 886 $control_args['parent'] = '_widescreen' === substr( $control_name, -strlen( '_widescreen' ) ) ? $id : $control_name;
937 887 } else {
938 888 $control_args['parent'] = null;
939 889 }
@@ -979,11 +929,9 @@
979 929 $id_suffix = Breakpoints_Manager::BREAKPOINT_KEY_DESKTOP === $device_name ? '' : '_' . $device_name;
980 930 $control_name = $id . $id_suffix;
981 931
982 932 // 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 - }
933 + $this->update_control( $control_args['parent'], [ 'inheritors' => [ $control_name ] ] );
986 934
987 935 if ( ! empty( $options['overwrite'] ) ) {
988 936 $this->update_control( $control_name, $control_args, [
989 937 'recursive' => ! empty( $options['recursive'] ),
@@ -1060,10 +1008,10 @@
1060 1008 * @return array|null The config.
1061 1009 */
1062 1010 final public function get_config() {
1063 1011 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.
1012 + // TODO: This is for backwards compatibility starting from 2.9.0
1013 + // This if statement should be removed when the method is hard-deprecated
1066 1014 if ( $this->has_own_method( '_get_initial_config', self::class ) ) {
1067 1015 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_get_initial_config', '2.9.0', __CLASS__ . '::get_initial_config()' );
1068 1016
1069 1017 $this->config = $this->_get_initial_config();
@@ -1087,10 +1035,8 @@
1087 1035 * Set a config property.
1088 1036 *
1089 1037 * Set a specific property of the config list for this controls-stack.
1090 1038 *
1091 - * @param string $key
1092 - * @param string $value
1093 1039 * @since 3.5.0
1094 1040 * @access public
1095 1041 */
1096 1042 public function set_config( $key, $value ) {
@@ -1166,11 +1112,8 @@
1166 1112 return self::get_items( $this->data, $item );
1167 1113 }
1168 1114
1169 1115 /**
1170 - * @param null $setting
1171 - * @param null $settings
1172 - * @return array|mixed|null
1173 1116 * @since 2.0.14
1174 1117 * @access public
1175 1118 */
1176 1119 public function get_parsed_dynamic_settings( $setting = null, $settings = null ) {
@@ -1189,16 +1132,16 @@
1189 1132 * Get active settings.
1190 1133 *
1191 1134 * Retrieve the settings from all the active controls.
1192 1135 *
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.
1136 + * @since 1.4.0
1197 1137 * @since 2.1.0 Added the `controls` and the `settings` parameters.
1198 1138 * @access public
1199 1139 *
1200 - * @since 1.4.0
1140 + * @param array $controls Optional. An array of controls. Default is null.
1141 + * @param array $settings Optional. Controls settings. Default is null.
1142 + *
1143 + * @return array Active settings.
1201 1144 */
1202 1145 public function get_active_settings( $settings = null, $controls = null ) {
1203 1146 $is_first_request = ! $settings && ! $this->active_settings;
1204 1147
@@ -1213,10 +1156,8 @@
1213 1156 }
1214 1157
1215 1158 $active_settings = [];
1216 1159
1217 - $controls_objs = Plugin::$instance->controls_manager->get_controls();
1218 -
1219 1160 foreach ( $settings as $setting_key => $setting ) {
1220 1161 if ( ! isset( $controls[ $setting_key ] ) ) {
1221 1162 $active_settings[ $setting_key ] = $setting;
1222 1163
@@ -1224,10 +1165,10 @@
1224 1165 }
1225 1166
1226 1167 $control = $controls[ $setting_key ];
1227 1168
1228 - if ( $this->is_control_visible( $control, $settings, $controls ) ) {
1229 - $control_obj = $controls_objs[ $control['type'] ] ?? null;
1169 + if ( $this->is_control_visible( $control, $settings ) ) {
1170 + $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] );
1230 1171
1231 1172 if ( $control_obj instanceof Control_Repeater ) {
1232 1173 foreach ( $setting as & $item ) {
1233 1174 $item = $this->get_active_settings( $item, $control['fields'] );
@@ -1294,13 +1235,11 @@
1294 1235 if ( null === $controls ) {
1295 1236 $controls = $this->get_controls();
1296 1237 }
1297 1238
1298 - $controls_objs = Plugin::$instance->controls_manager->get_controls();
1299 -
1300 1239 foreach ( $controls as $control ) {
1301 1240 $control_name = $control['name'];
1302 - $control_obj = $controls_objs[ $control['type'] ] ?? null;
1241 + $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] );
1303 1242
1304 1243 if ( ! $control_obj instanceof Base_Data_Control ) {
1305 1244 continue;
1306 1245 }
@@ -1410,33 +1349,21 @@
1410 1349 );
1411 1350 }
1412 1351
1413 1352 /**
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 1353 * Whether the control is visible or not.
1428 1354 *
1429 1355 * Used to determine whether the control is visible or not.
1430 1356 *
1357 + * @since 1.4.0
1358 + * @access public
1359 + *
1431 1360 * @param array $control The control.
1432 - * @param null $values Optional. Condition values. Default is null.
1433 - * @param null $controls
1361 + * @param array $values Optional. Condition values. Default is null.
1362 + *
1434 1363 * @return bool Whether the control is visible.
1435 - * @since 1.4.0
1436 - * @access public
1437 1364 */
1438 - public function is_control_visible( $control, $values = null, $controls = null ) {
1365 + public function is_control_visible( $control, $values = null ) {
1439 1366 if ( null === $values ) {
1440 1367 $values = $this->get_settings();
1441 1368 }
1442 1369
@@ -1447,35 +1374,33 @@
1447 1374 if ( empty( $control['condition'] ) ) {
1448 1375 return true;
1449 1376 }
1450 1377
1451 - if ( ! $controls ) {
1452 - $controls = $this->get_controls();
1453 - }
1454 -
1455 1378 foreach ( $control['condition'] as $condition_key => $condition_value ) {
1456 1379 preg_match( '/([a-z_\-0-9]+)(?:\[([a-z_]+)])?(!?)$/i', $condition_key, $condition_key_parts );
1457 1380
1458 1381 $pure_condition_key = $condition_key_parts[1];
1459 1382 $condition_sub_key = $condition_key_parts[2];
1460 - $is_negative_condition = (bool) $condition_key_parts[3];
1383 + $is_negative_condition = ! ! $condition_key_parts[3];
1461 1384
1462 1385 if ( ! isset( $values[ $pure_condition_key ] ) || null === $values[ $pure_condition_key ] ) {
1463 1386 return false;
1464 1387 }
1465 1388
1466 - $are_control_and_condition_responsive = isset( $control['responsive'] ) && ! empty( $controls[ $pure_condition_key ]['responsive'] );
1467 - $condition_name_to_check = $pure_condition_key;
1389 + $instance_value = $values[ $pure_condition_key ];
1468 1390
1469 - if ( $are_control_and_condition_responsive ) {
1470 - $device_suffix = Controls_Manager::get_responsive_control_device_suffix( $control );
1391 + if ( ! $instance_value ) {
1392 + $controls = $this->get_controls();
1393 + $parent = isset( $controls[ $pure_condition_key ]['parent'] ) ? $controls[ $pure_condition_key ]['parent'] : false;
1471 1394
1472 - $condition_name_to_check = $pure_condition_key . $device_suffix;
1395 + while ( $parent ) {
1396 + $instance_value = $values[ $parent ];
1473 1397
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 ];
1398 + if ( $instance_value ) {
1399 + break;
1400 + }
1401 + $parent = isset( $controls[ $parent ]['parent'] ) ? $controls[ $parent ]['parent'] : false;
1402 + }
1478 1403 }
1479 1404
1480 1405 if ( $condition_sub_key && is_array( $instance_value ) ) {
1481 1406 if ( ! isset( $instance_value[ $condition_sub_key ] ) ) {
@@ -1484,32 +1409,8 @@
1484 1409
1485 1410 $instance_value = $instance_value[ $condition_sub_key ];
1486 1411 }
1487 1412
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 1413 /**
1513 1414 * If the $condition_value is a non empty array - check if the $condition_value contains the $instance_value,
1514 1415 * If the $instance_value is a non empty array - check if the $instance_value contains the $condition_value
1515 1416 * otherwise check if they are equal. ( and give the ability to check if the value is an empty array )
@@ -1521,12 +1422,9 @@
1521 1422 } else {
1522 1423 $is_contains = $instance_value === $condition_value;
1523 1424 }
1524 1425
1525 - if (
1526 - ( $is_negative_condition && $is_contains ) ||
1527 - ( ! $is_negative_condition && ! $is_contains )
1528 - ) {
1426 + if ( $is_negative_condition && $is_contains || ! $is_negative_condition && ! $is_contains ) {
1529 1427 return false;
1530 1428 }
1531 1429 }
1532 1430
@@ -1577,12 +1475,8 @@
1577 1475 * @param array $args Section arguments.
1578 1476 */
1579 1477 do_action( "elementor/element/{$stack_name}/{$section_id}/before_section_start", $this, $args );
1580 1478
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 1479 $args['type'] = Controls_Manager::SECTION;
1586 1480
1587 1481 $this->add_control( $section_id, $args );
1588 1482
@@ -1621,12 +1515,8 @@
1621 1515 * @param Controls_Stack $this The control.
1622 1516 * @param array $args Section arguments.
1623 1517 */
1624 1518 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 - }
1629 1519 }
1630 1520
1631 1521 /**
1632 1522 * End controls section.
@@ -1675,12 +1565,8 @@
1675 1565 * @param array $args Section arguments.
1676 1566 */
1677 1567 do_action( "elementor/element/{$stack_name}/{$section_id}/before_section_end", $this, $args );
1678 1568
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 1569 $this->current_section = null;
1684 1570
1685 1571 /**
1686 1572 * After section end.
@@ -1707,40 +1593,11 @@
1707 1593 * @param Controls_Stack $this The control.
1708 1594 * @param array $args Section arguments.
1709 1595 */
1710 1596 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 1597 }
1716 1598
1717 1599 /**
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 1600 * Start controls tabs.
1744 1601 *
1745 1602 * Used to add a new set of tabs inside a section. You should use this
1746 1603 * method before adding new individual tabs using `start_controls_tab()`.
@@ -2013,10 +1870,10 @@
2013 1870 *
2014 1871 * @since 2.7.0
2015 1872 * @access public
2016 1873 *
2017 - * @param string $element The HTML element.
2018 - * @param string $key Optional. Attribute key. Default is null.
1874 + * @param string $element The HTML element.
1875 + * @param string $key Optional. Attribute key. Default is null.
2019 1876 * @param array|string $values Optional. Attribute value/s. Default is null.
2020 1877 */
2021 1878 public function remove_render_attribute( $element, $key = null, $values = null ) {
2022 1879 if ( $key && ! isset( $this->render_attributes[ $element ][ $key ] ) ) {
@@ -2073,9 +1930,9 @@
2073 1930 *
2074 1931 * @param array|string $element The element.
2075 1932 */
2076 1933 public function print_render_attribute_string( $element ) {
2077 - Utils::print_unescaped_internal_string( $this->get_render_attribute_string( $element ) );
1934 + echo $this->get_render_attribute_string( $element ); // XSS ok.
2078 1935 }
2079 1936
2080 1937 /**
2081 1938 * Print element template.
@@ -2088,9 +1945,9 @@
2088 1945 public function print_template() {
2089 1946 ob_start();
2090 1947
2091 1948 // TODO: This is for backwards compatibility starting from 2.9.0
2092 - // This `if` statement should be removed when the method is removed.
1949 + // This `if` statement should be removed when the method is removed
2093 1950 if ( $this->has_own_method( '_content_template', self::class ) ) {
2094 1951 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_content_template', '2.9.0', __CLASS__ . '::content_template()' );
2095 1952
2096 1953 $this->_content_template();
@@ -2126,19 +1983,13 @@
2126 1983 <?php
2127 1984 }
2128 1985
2129 1986 /**
2130 - * On import update dynamic content (e.g. post and term IDs).
2131 1987 *
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.
1988 + * @since 3.6.0
1989 + * @access public
2139 1990 */
2140 - public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ): array {
1991 + public static function on_import_replace_dynamic_content( $config, $map_old_new_post_ids ) {
2141 1992 return $config;
2142 1993 }
2143 1994
2144 1995 /**
@@ -2217,12 +2068,12 @@
2217 2068 * `start_controls_tab()`.
2218 2069 *
2219 2070 * @since 1.4.0
2220 2071 * @access protected
2221 - * @deprecated 3.1.0 Use `register_controls()` method instead.
2072 + * @deprecated 3.1.0 Use `Controls_Stack::register_controls()` instead
2222 2073 */
2223 2074 protected function _register_controls() {
2224 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0', 'register_controls()' );
2075 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0', __CLASS__ . '::register_controls()' );
2225 2076
2226 2077 $this->register_controls();
2227 2078 }
2228 2079
@@ -2265,12 +2116,10 @@
2265 2116 */
2266 2117 protected function get_init_settings() {
2267 2118 $settings = $this->get_data( 'settings' );
2268 2119
2269 - $controls_objs = Plugin::$instance->controls_manager->get_controls();
2270 -
2271 2120 foreach ( $this->get_controls() as $control ) {
2272 - $control_obj = $controls_objs[ $control['type'] ] ?? null;
2121 + $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] );
2273 2122
2274 2123 if ( ! $control_obj instanceof Base_Data_Control ) {
2275 2124 continue;
2276 2125 }
@@ -2306,15 +2155,15 @@
2306 2155 * Retrieve the current element initial configuration - controls list and
2307 2156 * the tabs assigned to the control.
2308 2157 *
2309 2158 * @since 1.4.0
2310 - * @deprecated 2.9.0 Use `get_initial_config()` method instead.
2159 + * @deprecated 2.9.0 use `get_initial_config()` instead
2311 2160 * @access protected
2312 2161 *
2313 2162 * @return array The initial config.
2314 2163 */
2315 2164 protected function _get_initial_config() {
2316 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', 'get_initial_config()' );
2165 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', __CLASS__ . '::get_initial_config()' );
2317 2166
2318 2167 return $this->get_initial_config();
2319 2168 }
2320 2169
@@ -2385,9 +2234,9 @@
2385 2234 *
2386 2235 * @param string $template_content Template content.
2387 2236 */
2388 2237 protected function print_template_content( $template_content ) {
2389 - Utils::print_unescaped_internal_string( $template_content );
2238 + echo $template_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2390 2239 }
2391 2240
2392 2241 /**
2393 2242 * Render element output in the editor.
@@ -2404,13 +2253,13 @@
2404 2253 *
2405 2254 * Used to generate the live preview, using a Backbone JavaScript template.
2406 2255 *
2407 2256 * @since 2.0.0
2408 - * @deprecated 2.9.0 Use `content_template()` method instead.
2257 + * @deprecated 2.9.0 use `content_template()` instead
2409 2258 * @access protected
2410 2259 */
2411 2260 protected function _content_template() {
2412 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', 'content_template()' );
2261 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', __CLASS__ . '::content_template()' );
2413 2262
2414 2263 $this->content_template();
2415 2264 }
2416 2265
@@ -2425,9 +2274,9 @@
2425 2274 protected function init_controls() {
2426 2275 Plugin::$instance->controls_manager->open_stack( $this );
2427 2276
2428 2277 // TODO: This is for backwards compatibility starting from 2.9.0
2429 - // This `if` statement should be removed when the method is removed.
2278 + // This `if` statement should be removed when the method is removed
2430 2279 if ( $this->has_own_method( '_register_controls', self::class ) ) {
2431 2280 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_register_controls', '3.1.0', __CLASS__ . '::register_controls()' );
2432 2281
2433 2282 $this->_register_controls();
@@ -2463,11 +2312,9 @@
2463 2312 if ( null !== $target_tab ) {
2464 2313 $args = array_replace_recursive( $target_tab, $args );
2465 2314 }
2466 2315 } 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 - }
2316 + 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 2317 }
2471 2318
2472 2319 return $args;
2473 2320 }
@@ -2493,15 +2340,15 @@
2493 2340 *
2494 2341 * Set the raw data, the ID and the parsed settings.
2495 2342 *
2496 2343 * @since 1.4.0
2497 - * @deprecated 2.9.0 Use `init()` method instead.
2344 + * @deprecated 2.9.0 use `init()` instead
2498 2345 * @access protected
2499 2346 *
2500 2347 * @param array $data Initial data.
2501 2348 */
2502 2349 protected function _init( $data ) {
2503 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', 'init()' );
2350 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', __CLASS__ . '::init()' );
2504 2351
2505 2352 $this->init( $data );
2506 2353 }
2507 2354
@@ -2572,9 +2419,9 @@
2572 2419 */
2573 2420 public function __construct( array $data = [] ) {
2574 2421 if ( $data ) {
2575 2422 // TODO: This is for backwards compatibility starting from 2.9.0
2576 - // This if statement should be removed when the method is hard-deprecated.
2423 + // This if statement should be removed when the method is hard-deprecated
2577 2424 if ( $this->has_own_method( '_init', self::class ) ) {
2578 2425 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_init', '2.9.0', __CLASS__ . '::init()' );
2579 2426
2580 2427 $this->_init( $data );