PluginProbe
Elementor Website Builder – more than just a page builder / 3.7.8
Elementor Website Builder – more than just a page builder v3.7.8
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 +88 -222 4.2.13.7.8 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,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 ) {
@@ -1184,28 +1127,21 @@
1184 1127
1185 1128 return self::get_items( $this->parsed_dynamic_settings, $setting );
1186 1129 }
1187 1130
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 1131 /**
1196 1132 * Get active settings.
1197 1133 *
1198 1134 * Retrieve the settings from all the active controls.
1199 1135 *
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.
1136 + * @since 1.4.0
1204 1137 * @since 2.1.0 Added the `controls` and the `settings` parameters.
1205 1138 * @access public
1206 1139 *
1207 - * @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.
1208 1144 */
1209 1145 public function get_active_settings( $settings = null, $controls = null ) {
1210 1146 $is_first_request = ! $settings && ! $this->active_settings;
1211 1147
@@ -1220,10 +1156,8 @@
1220 1156 }
1221 1157
1222 1158 $active_settings = [];
1223 1159
1224 - $controls_objs = Plugin::$instance->controls_manager->get_controls();
1225 -
1226 1160 foreach ( $settings as $setting_key => $setting ) {
1227 1161 if ( ! isset( $controls[ $setting_key ] ) ) {
1228 1162 $active_settings[ $setting_key ] = $setting;
1229 1163
@@ -1231,10 +1165,10 @@
1231 1165 }
1232 1166
1233 1167 $control = $controls[ $setting_key ];
1234 1168
1235 - if ( $this->is_control_visible( $control, $settings, $controls ) ) {
1236 - $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'] );
1237 1171
1238 1172 if ( $control_obj instanceof Control_Repeater ) {
1239 1173 foreach ( $setting as & $item ) {
1240 1174 $item = $this->get_active_settings( $item, $control['fields'] );
@@ -1301,13 +1235,11 @@
1301 1235 if ( null === $controls ) {
1302 1236 $controls = $this->get_controls();
1303 1237 }
1304 1238
1305 - $controls_objs = Plugin::$instance->controls_manager->get_controls();
1306 -
1307 1239 foreach ( $controls as $control ) {
1308 1240 $control_name = $control['name'];
1309 - $control_obj = $controls_objs[ $control['type'] ] ?? null;
1241 + $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] );
1310 1242
1311 1243 if ( ! $control_obj instanceof Base_Data_Control ) {
1312 1244 continue;
1313 1245 }
@@ -1419,9 +1351,9 @@
1419 1351
1420 1352 /**
1421 1353 * Get Responsive Control Device Suffix
1422 1354 *
1423 - * @deprecated 3.7.6 Use `Elementor\Controls_Manager::get_responsive_control_device_suffix()` instead.
1355 + * @deprecated 3.7.6
1424 1356 * @param array $control
1425 1357 * @return string $device suffix
1426 1358 */
1427 1359 protected function get_responsive_control_device_suffix( $control ) {
@@ -1434,16 +1366,17 @@
1434 1366 * Whether the control is visible or not.
1435 1367 *
1436 1368 * Used to determine whether the control is visible or not.
1437 1369 *
1370 + * @since 1.4.0
1371 + * @access public
1372 + *
1438 1373 * @param array $control The control.
1439 - * @param null $values Optional. Condition values. Default is null.
1440 - * @param null $controls
1374 + * @param array $values Optional. Condition values. Default is null.
1375 + *
1441 1376 * @return bool Whether the control is visible.
1442 - * @since 1.4.0
1443 - * @access public
1444 1377 */
1445 - public function is_control_visible( $control, $values = null, $controls = null ) {
1378 + public function is_control_visible( $control, $values = null ) {
1446 1379 if ( null === $values ) {
1447 1380 $values = $this->get_settings();
1448 1381 }
1449 1382
@@ -1454,11 +1387,9 @@
1454 1387 if ( empty( $control['condition'] ) ) {
1455 1388 return true;
1456 1389 }
1457 1390
1458 - if ( ! $controls ) {
1459 - $controls = $this->get_controls();
1460 - }
1391 + $controls = $this->get_controls();
1461 1392
1462 1393 foreach ( $control['condition'] as $condition_key => $condition_value ) {
1463 1394 preg_match( '/([a-z_\-0-9]+)(?:\[([a-z_]+)])?(!?)$/i', $condition_key, $condition_key_parts );
1464 1395
@@ -1463,9 +1394,9 @@
1463 1394 preg_match( '/([a-z_\-0-9]+)(?:\[([a-z_]+)])?(!?)$/i', $condition_key, $condition_key_parts );
1464 1395
1465 1396 $pure_condition_key = $condition_key_parts[1];
1466 1397 $condition_sub_key = $condition_key_parts[2];
1467 - $is_negative_condition = (bool) $condition_key_parts[3];
1398 + $is_negative_condition = ! ! $condition_key_parts[3];
1468 1399
1469 1400 if ( ! isset( $values[ $pure_condition_key ] ) || null === $values[ $pure_condition_key ] ) {
1470 1401 return false;
1471 1402 }
@@ -1483,16 +1414,8 @@
1483 1414 } else {
1484 1415 $instance_value = $values[ $pure_condition_key ];
1485 1416 }
1486 1417
1487 - if ( $condition_sub_key && is_array( $instance_value ) ) {
1488 - if ( ! isset( $instance_value[ $condition_sub_key ] ) ) {
1489 - return false;
1490 - }
1491 -
1492 - $instance_value = $instance_value[ $condition_sub_key ];
1493 - }
1494 -
1495 1418 if ( ! $instance_value ) {
1496 1419 $parent = isset( $controls[ $condition_name_to_check ]['parent'] ) ? $controls[ $condition_name_to_check ]['parent'] : false;
1497 1420
1498 1421 while ( $parent ) {
@@ -1498,23 +1421,20 @@
1498 1421 while ( $parent ) {
1499 1422 $instance_value = $values[ $parent ];
1500 1423
1501 1424 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 - }
1425 + break;
1513 1426 }
1427 + $parent = isset( $controls[ $parent ]['parent'] ) ? $controls[ $parent ]['parent'] : false;
1428 + }
1429 + }
1514 1430
1515 - $parent = isset( $controls[ $parent ]['parent'] ) ? $controls[ $parent ]['parent'] : false;
1431 + if ( $condition_sub_key && is_array( $instance_value ) ) {
1432 + if ( ! isset( $instance_value[ $condition_sub_key ] ) ) {
1433 + return false;
1516 1434 }
1435 +
1436 + $instance_value = $instance_value[ $condition_sub_key ];
1517 1437 }
1518 1438
1519 1439 /**
1520 1440 * If the $condition_value is a non empty array - check if the $condition_value contains the $instance_value,
@@ -1528,12 +1448,9 @@
1528 1448 } else {
1529 1449 $is_contains = $instance_value === $condition_value;
1530 1450 }
1531 1451
1532 - if (
1533 - ( $is_negative_condition && $is_contains ) ||
1534 - ( ! $is_negative_condition && ! $is_contains )
1535 - ) {
1452 + if ( $is_negative_condition && $is_contains || ! $is_negative_condition && ! $is_contains ) {
1536 1453 return false;
1537 1454 }
1538 1455 }
1539 1456
@@ -1584,12 +1501,8 @@
1584 1501 * @param array $args Section arguments.
1585 1502 */
1586 1503 do_action( "elementor/element/{$stack_name}/{$section_id}/before_section_start", $this, $args );
1587 1504
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 1505 $args['type'] = Controls_Manager::SECTION;
1593 1506
1594 1507 $this->add_control( $section_id, $args );
1595 1508
@@ -1628,12 +1541,8 @@
1628 1541 * @param Controls_Stack $this The control.
1629 1542 * @param array $args Section arguments.
1630 1543 */
1631 1544 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 1545 }
1637 1546
1638 1547 /**
1639 1548 * End controls section.
@@ -1682,12 +1591,8 @@
1682 1591 * @param array $args Section arguments.
1683 1592 */
1684 1593 do_action( "elementor/element/{$stack_name}/{$section_id}/before_section_end", $this, $args );
1685 1594
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 1595 $this->current_section = null;
1691 1596
1692 1597 /**
1693 1598 * After section end.
@@ -1714,40 +1619,11 @@
1714 1619 * @param Controls_Stack $this The control.
1715 1620 * @param array $args Section arguments.
1716 1621 */
1717 1622 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 1623 }
1723 1624
1724 1625 /**
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 1626 * Start controls tabs.
1751 1627 *
1752 1628 * Used to add a new set of tabs inside a section. You should use this
1753 1629 * method before adding new individual tabs using `start_controls_tab()`.
@@ -2020,10 +1896,10 @@
2020 1896 *
2021 1897 * @since 2.7.0
2022 1898 * @access public
2023 1899 *
2024 - * @param string $element The HTML element.
2025 - * @param string $key Optional. Attribute key. Default is null.
1900 + * @param string $element The HTML element.
1901 + * @param string $key Optional. Attribute key. Default is null.
2026 1902 * @param array|string $values Optional. Attribute value/s. Default is null.
2027 1903 */
2028 1904 public function remove_render_attribute( $element, $key = null, $values = null ) {
2029 1905 if ( $key && ! isset( $this->render_attributes[ $element ][ $key ] ) ) {
@@ -2080,9 +1956,9 @@
2080 1956 *
2081 1957 * @param array|string $element The element.
2082 1958 */
2083 1959 public function print_render_attribute_string( $element ) {
2084 - Utils::print_unescaped_internal_string( $this->get_render_attribute_string( $element ) );
1960 + echo $this->get_render_attribute_string( $element ); // XSS ok.
2085 1961 }
2086 1962
2087 1963 /**
2088 1964 * Print element template.
@@ -2095,9 +1971,9 @@
2095 1971 public function print_template() {
2096 1972 ob_start();
2097 1973
2098 1974 // TODO: This is for backwards compatibility starting from 2.9.0
2099 - // This `if` statement should be removed when the method is removed.
1975 + // This `if` statement should be removed when the method is removed
2100 1976 if ( $this->has_own_method( '_content_template', self::class ) ) {
2101 1977 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_content_template', '2.9.0', __CLASS__ . '::content_template()' );
2102 1978
2103 1979 $this->_content_template();
@@ -2133,19 +2009,13 @@
2133 2009 <?php
2134 2010 }
2135 2011
2136 2012 /**
2137 - * On import update dynamic content (e.g. post and term IDs).
2138 2013 *
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.
2014 + * @since 3.6.0
2015 + * @access public
2146 2016 */
2147 - public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ): array {
2017 + public static function on_import_replace_dynamic_content( $config, $map_old_new_post_ids ) {
2148 2018 return $config;
2149 2019 }
2150 2020
2151 2021 /**
@@ -2224,12 +2094,12 @@
2224 2094 * `start_controls_tab()`.
2225 2095 *
2226 2096 * @since 1.4.0
2227 2097 * @access protected
2228 - * @deprecated 3.1.0 Use `register_controls()` method instead.
2098 + * @deprecated 3.1.0 Use `Controls_Stack::register_controls()` instead
2229 2099 */
2230 2100 protected function _register_controls() {
2231 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0', 'register_controls()' );
2101 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0', __CLASS__ . '::register_controls()' );
2232 2102
2233 2103 $this->register_controls();
2234 2104 }
2235 2105
@@ -2272,12 +2142,10 @@
2272 2142 */
2273 2143 protected function get_init_settings() {
2274 2144 $settings = $this->get_data( 'settings' );
2275 2145
2276 - $controls_objs = Plugin::$instance->controls_manager->get_controls();
2277 -
2278 2146 foreach ( $this->get_controls() as $control ) {
2279 - $control_obj = $controls_objs[ $control['type'] ] ?? null;
2147 + $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] );
2280 2148
2281 2149 if ( ! $control_obj instanceof Base_Data_Control ) {
2282 2150 continue;
2283 2151 }
@@ -2313,15 +2181,15 @@
2313 2181 * Retrieve the current element initial configuration - controls list and
2314 2182 * the tabs assigned to the control.
2315 2183 *
2316 2184 * @since 1.4.0
2317 - * @deprecated 2.9.0 Use `get_initial_config()` method instead.
2185 + * @deprecated 2.9.0 use `get_initial_config()` instead
2318 2186 * @access protected
2319 2187 *
2320 2188 * @return array The initial config.
2321 2189 */
2322 2190 protected function _get_initial_config() {
2323 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', 'get_initial_config()' );
2191 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', __CLASS__ . '::get_initial_config()' );
2324 2192
2325 2193 return $this->get_initial_config();
2326 2194 }
2327 2195
@@ -2392,9 +2260,9 @@
2392 2260 *
2393 2261 * @param string $template_content Template content.
2394 2262 */
2395 2263 protected function print_template_content( $template_content ) {
2396 - Utils::print_unescaped_internal_string( $template_content );
2264 + echo $template_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2397 2265 }
2398 2266
2399 2267 /**
2400 2268 * Render element output in the editor.
@@ -2411,13 +2279,13 @@
2411 2279 *
2412 2280 * Used to generate the live preview, using a Backbone JavaScript template.
2413 2281 *
2414 2282 * @since 2.0.0
2415 - * @deprecated 2.9.0 Use `content_template()` method instead.
2283 + * @deprecated 2.9.0 use `content_template()` instead
2416 2284 * @access protected
2417 2285 */
2418 2286 protected function _content_template() {
2419 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', 'content_template()' );
2287 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', __CLASS__ . '::content_template()' );
2420 2288
2421 2289 $this->content_template();
2422 2290 }
2423 2291
@@ -2432,9 +2300,9 @@
2432 2300 protected function init_controls() {
2433 2301 Plugin::$instance->controls_manager->open_stack( $this );
2434 2302
2435 2303 // TODO: This is for backwards compatibility starting from 2.9.0
2436 - // This `if` statement should be removed when the method is removed.
2304 + // This `if` statement should be removed when the method is removed
2437 2305 if ( $this->has_own_method( '_register_controls', self::class ) ) {
2438 2306 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_register_controls', '3.1.0', __CLASS__ . '::register_controls()' );
2439 2307
2440 2308 $this->_register_controls();
@@ -2470,11 +2338,9 @@
2470 2338 if ( null !== $target_tab ) {
2471 2339 $args = array_replace_recursive( $target_tab, $args );
2472 2340 }
2473 2341 } 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 - }
2342 + 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 2343 }
2478 2344
2479 2345 return $args;
2480 2346 }
@@ -2500,15 +2366,15 @@
2500 2366 *
2501 2367 * Set the raw data, the ID and the parsed settings.
2502 2368 *
2503 2369 * @since 1.4.0
2504 - * @deprecated 2.9.0 Use `init()` method instead.
2370 + * @deprecated 2.9.0 use `init()` instead
2505 2371 * @access protected
2506 2372 *
2507 2373 * @param array $data Initial data.
2508 2374 */
2509 2375 protected function _init( $data ) {
2510 - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', 'init()' );
2376 + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', __CLASS__ . '::init()' );
2511 2377
2512 2378 $this->init( $data );
2513 2379 }
2514 2380
@@ -2579,9 +2445,9 @@
2579 2445 */
2580 2446 public function __construct( array $data = [] ) {
2581 2447 if ( $data ) {
2582 2448 // TODO: This is for backwards compatibility starting from 2.9.0
2583 - // This if statement should be removed when the method is hard-deprecated.
2449 + // This if statement should be removed when the method is hard-deprecated
2584 2450 if ( $this->has_own_method( '_init', self::class ) ) {
2585 2451 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_init', '2.9.0', __CLASS__ . '::init()' );
2586 2452
2587 2453 $this->_init( $data );