PluginProbe
Elementor Website Builder – more than just a page builder / 3.21.3
Elementor Website Builder – more than just a page builder v3.21.3
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 +33 -92 4.1.0-dev23.21.3 View file →
@@ -4,9 +4,8 @@
4 4 use Elementor\Core\Base\Base_Object;
5 5 use Elementor\Core\DynamicTags\Manager;
6 6 use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
7 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,9 +225,9 @@
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 233 * Get widget number.
@@ -312,18 +311,8 @@
312 311 * @return mixed Controls list.
313 312 */
314 313 public function get_controls( $control_id = null ) {
315 314 $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 315 $controls = $stack['controls'];
327 316
328 317 if ( Performance::is_use_style_controls() && ! empty( $stack['style_controls'] ) ) {
329 318 $controls += $stack['style_controls'];
@@ -349,9 +338,9 @@
349 338 * @param array $settings Optional. Controls settings. Default is null.
350 339 *
351 340 * @return array Active controls.
352 341 */
353 - public function get_active_controls( ?array $controls = null, ?array $settings = null ) {
342 + public function get_active_controls( array $controls = null, array $settings = null ) {
354 343 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.0.0' );
355 344
356 345 if ( ! $controls ) {
357 346 $controls = $this->get_controls();
@@ -612,10 +601,10 @@
612 601
613 602 $position = array_merge( $default_position, $position );
614 603
615 604 if (
616 - ( 'control' === $position['type'] && in_array( $position['at'], [ 'start', 'end' ], true ) ) ||
617 - ( 'section' === $position['type'] && in_array( $position['at'], [ 'before', 'after' ], true ) )
605 + 'control' === $position['type'] && in_array( $position['at'], [ 'start', 'end' ], true ) ||
606 + 'section' === $position['type'] && in_array( $position['at'], [ 'before', 'after' ], true )
618 607 ) {
619 608 _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 609
621 610 return false;
@@ -637,13 +626,13 @@
637 626
638 627 $controls_keys = array_keys( $registered_controls );
639 628
640 629 while ( Controls_Manager::SECTION !== $registered_controls[ $controls_keys[ $target_section_index ] ]['type'] ) {
641 - --$target_section_index;
630 + $target_section_index--;
642 631 }
643 632
644 633 if ( 'section' === $position['type'] ) {
645 - ++$target_control_index;
634 + $target_control_index++;
646 635
647 636 if ( 'end' === $position['at'] ) {
648 637 while ( Controls_Manager::SECTION !== $registered_controls[ $controls_keys[ $target_control_index ] ]['type'] ) {
649 638 if ( ++$target_control_index >= count( $registered_controls ) ) {
@@ -655,9 +644,9 @@
655 644
656 645 $target_control = $registered_controls[ $controls_keys[ $target_control_index ] ];
657 646
658 647 if ( 'after' === $position['at'] ) {
659 - ++$target_control_index;
648 + $target_control_index++;
660 649 }
661 650
662 651 $section_id = $registered_controls[ $controls_keys[ $target_section_index ] ]['name'];
663 652
@@ -737,9 +726,9 @@
737 726
738 727 $controls_keys = array_keys( $registered_controls );
739 728
740 729 while ( true ) {
741 - ++$section_index;
730 + $section_index++;
742 731
743 732 if ( ! isset( $controls_keys[ $section_index ] ) ) {
744 733 break;
745 734 }
@@ -750,9 +739,9 @@
750 739 break;
751 740 }
752 741
753 742 $section_controls[ $control_key ] = $registered_controls[ $control_key ];
754 - }
743 + };
755 744
756 745 return $section_controls;
757 746 }
758 747
@@ -796,9 +785,9 @@
796 785 * @param array $settings Optional. Controls settings. Default is null.
797 786 *
798 787 * @return array Style controls.
799 788 */
800 - final public function get_style_controls( ?array $controls = null, ?array $settings = null ) {
789 + final public function get_style_controls( array $controls = null, array $settings = null ) {
801 790 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.0.0' );
802 791
803 792 $controls = $this->get_active_controls( $controls, $settings );
804 793
@@ -931,9 +920,9 @@
931 920 $control_args = $args;
932 921
933 922 // Set parent using the name from previous iteration.
934 923 if ( isset( $control_name ) ) {
935 - // If $control_name end with _widescreen use desktop name instead.
924 + // If $control_name end with _widescreen use desktop name instead
936 925 $control_args['parent'] = '_widescreen' === substr( $control_name, -strlen( '_widescreen' ) ) ? $id : $control_name;
937 926 } else {
938 927 $control_args['parent'] = null;
939 928 }
@@ -1060,10 +1049,10 @@
1060 1049 * @return array|null The config.
1061 1050 */
1062 1051 final public function get_config() {
1063 1052 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.
1053 + // TODO: This is for backwards compatibility starting from 2.9.0
1054 + // This if statement should be removed when the method is hard-deprecated
1066 1055 if ( $this->has_own_method( '_get_initial_config', self::class ) ) {
1067 1056 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_get_initial_config', '2.9.0', __CLASS__ . '::get_initial_config()' );
1068 1057
1069 1058 $this->config = $this->_get_initial_config();
@@ -1087,10 +1076,8 @@
1087 1076 * Set a config property.
1088 1077 *
1089 1078 * Set a specific property of the config list for this controls-stack.
1090 1079 *
1091 - * @param string $key
1092 - * @param string $value
1093 1080 * @since 3.5.0
1094 1081 * @access public
1095 1082 */
1096 1083 public function set_config( $key, $value ) {
@@ -1166,11 +1153,8 @@
1166 1153 return self::get_items( $this->data, $item );
1167 1154 }
1168 1155
1169 1156 /**
1170 - * @param null $setting
1171 - * @param null $settings
1172 - * @return array|mixed|null
1173 1157 * @since 2.0.14
1174 1158 * @access public
1175 1159 */
1176 1160 public function get_parsed_dynamic_settings( $setting = null, $settings = null ) {
@@ -1189,16 +1173,16 @@
1189 1173 * Get active settings.
1190 1174 *
1191 1175 * Retrieve the settings from all the active controls.
1192 1176 *
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.
1177 + * @since 1.4.0
1197 1178 * @since 2.1.0 Added the `controls` and the `settings` parameters.
1198 1179 * @access public
1199 1180 *
1200 - * @since 1.4.0
1181 + * @param array $controls Optional. An array of controls. Default is null.
1182 + * @param array $settings Optional. Controls settings. Default is null.
1183 + *
1184 + * @return array Active settings.
1201 1185 */
1202 1186 public function get_active_settings( $settings = null, $controls = null ) {
1203 1187 $is_first_request = ! $settings && ! $this->active_settings;
1204 1188
@@ -1427,14 +1411,15 @@
1427 1411 * Whether the control is visible or not.
1428 1412 *
1429 1413 * Used to determine whether the control is visible or not.
1430 1414 *
1415 + * @since 1.4.0
1416 + * @access public
1417 + *
1431 1418 * @param array $control The control.
1432 - * @param null $values Optional. Condition values. Default is null.
1433 - * @param null $controls
1419 + * @param array $values Optional. Condition values. Default is null.
1420 + *
1434 1421 * @return bool Whether the control is visible.
1435 - * @since 1.4.0
1436 - * @access public
1437 1422 */
1438 1423 public function is_control_visible( $control, $values = null, $controls = null ) {
1439 1424 if ( null === $values ) {
1440 1425 $values = $this->get_settings();
@@ -1456,9 +1441,9 @@
1456 1441 preg_match( '/([a-z_\-0-9]+)(?:\[([a-z_]+)])?(!?)$/i', $condition_key, $condition_key_parts );
1457 1442
1458 1443 $pure_condition_key = $condition_key_parts[1];
1459 1444 $condition_sub_key = $condition_key_parts[2];
1460 - $is_negative_condition = (bool) $condition_key_parts[3];
1445 + $is_negative_condition = ! ! $condition_key_parts[3];
1461 1446
1462 1447 if ( ! isset( $values[ $pure_condition_key ] ) || null === $values[ $pure_condition_key ] ) {
1463 1448 return false;
1464 1449 }
@@ -1521,12 +1506,9 @@
1521 1506 } else {
1522 1507 $is_contains = $instance_value === $condition_value;
1523 1508 }
1524 1509
1525 - if (
1526 - ( $is_negative_condition && $is_contains ) ||
1527 - ( ! $is_negative_condition && ! $is_contains )
1528 - ) {
1510 + if ( $is_negative_condition && $is_contains || ! $is_negative_condition && ! $is_contains ) {
1529 1511 return false;
1530 1512 }
1531 1513 }
1532 1514
@@ -1577,12 +1559,8 @@
1577 1559 * @param array $args Section arguments.
1578 1560 */
1579 1561 do_action( "elementor/element/{$stack_name}/{$section_id}/before_section_start", $this, $args );
1580 1562
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 1563 $args['type'] = Controls_Manager::SECTION;
1586 1564
1587 1565 $this->add_control( $section_id, $args );
1588 1566
@@ -1621,12 +1599,8 @@
1621 1599 * @param Controls_Stack $this The control.
1622 1600 * @param array $args Section arguments.
1623 1601 */
1624 1602 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 1603 }
1630 1604
1631 1605 /**
1632 1606 * End controls section.
@@ -1675,12 +1649,8 @@
1675 1649 * @param array $args Section arguments.
1676 1650 */
1677 1651 do_action( "elementor/element/{$stack_name}/{$section_id}/before_section_end", $this, $args );
1678 1652
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 1653 $this->current_section = null;
1684 1654
1685 1655 /**
1686 1656 * After section end.
@@ -1707,40 +1677,11 @@
1707 1677 * @param Controls_Stack $this The control.
1708 1678 * @param array $args Section arguments.
1709 1679 */
1710 1680 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 1681 }
1716 1682
1717 1683 /**
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 1684 * Start controls tabs.
1744 1685 *
1745 1686 * Used to add a new set of tabs inside a section. You should use this
1746 1687 * method before adding new individual tabs using `start_controls_tab()`.
@@ -2013,10 +1954,10 @@
2013 1954 *
2014 1955 * @since 2.7.0
2015 1956 * @access public
2016 1957 *
2017 - * @param string $element The HTML element.
2018 - * @param string $key Optional. Attribute key. Default is null.
1958 + * @param string $element The HTML element.
1959 + * @param string $key Optional. Attribute key. Default is null.
2019 1960 * @param array|string $values Optional. Attribute value/s. Default is null.
2020 1961 */
2021 1962 public function remove_render_attribute( $element, $key = null, $values = null ) {
2022 1963 if ( $key && ! isset( $this->render_attributes[ $element ][ $key ] ) ) {
@@ -2073,9 +2014,9 @@
2073 2014 *
2074 2015 * @param array|string $element The element.
2075 2016 */
2076 2017 public function print_render_attribute_string( $element ) {
2077 - Utils::print_unescaped_internal_string( $this->get_render_attribute_string( $element ) );
2018 + echo $this->get_render_attribute_string( $element ); // XSS ok.
2078 2019 }
2079 2020
2080 2021 /**
2081 2022 * Print element template.
@@ -2088,9 +2029,9 @@
2088 2029 public function print_template() {
2089 2030 ob_start();
2090 2031
2091 2032 // TODO: This is for backwards compatibility starting from 2.9.0
2092 - // This `if` statement should be removed when the method is removed.
2033 + // This `if` statement should be removed when the method is removed
2093 2034 if ( $this->has_own_method( '_content_template', self::class ) ) {
2094 2035 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_content_template', '2.9.0', __CLASS__ . '::content_template()' );
2095 2036
2096 2037 $this->_content_template();
@@ -2136,9 +2077,9 @@
2136 2077 * @param array|null $controls The available controls.
2137 2078 *
2138 2079 * @return array Element data.
2139 2080 */
2140 - public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ): array {
2081 + public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ) : array {
2141 2082 return $config;
2142 2083 }
2143 2084
2144 2085 /**
@@ -2385,9 +2326,9 @@
2385 2326 *
2386 2327 * @param string $template_content Template content.
2387 2328 */
2388 2329 protected function print_template_content( $template_content ) {
2389 - Utils::print_unescaped_internal_string( $template_content );
2330 + echo $template_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
2390 2331 }
2391 2332
2392 2333 /**
2393 2334 * Render element output in the editor.
@@ -2425,9 +2366,9 @@
2425 2366 protected function init_controls() {
2426 2367 Plugin::$instance->controls_manager->open_stack( $this );
2427 2368
2428 2369 // TODO: This is for backwards compatibility starting from 2.9.0
2429 - // This `if` statement should be removed when the method is removed.
2370 + // This `if` statement should be removed when the method is removed
2430 2371 if ( $this->has_own_method( '_register_controls', self::class ) ) {
2431 2372 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_register_controls', '3.1.0', __CLASS__ . '::register_controls()' );
2432 2373
2433 2374 $this->_register_controls();
@@ -2572,9 +2513,9 @@
2572 2513 */
2573 2514 public function __construct( array $data = [] ) {
2574 2515 if ( $data ) {
2575 2516 // TODO: This is for backwards compatibility starting from 2.9.0
2576 - // This if statement should be removed when the method is hard-deprecated.
2517 + // This if statement should be removed when the method is hard-deprecated
2577 2518 if ( $this->has_own_method( '_init', self::class ) ) {
2578 2519 Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_init', '2.9.0', __CLASS__ . '::init()' );
2579 2520
2580 2521 $this->_init( $data );