| @@ -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 | } |
| @@ -349,9 +348,9 @@ | ||
| 349 | 348 | * @param array $settings Optional. Controls settings. Default is null. |
| 350 | 349 | * |
| 351 | 350 | * @return array Active controls. |
| 352 | 351 | */ |
| 353 | - public function get_active_controls( ?array $controls = null, ?array $settings = null ) { | |
| 352 | + public function get_active_controls( array $controls = null, array $settings = null ) { | |
| 354 | 353 | Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.0.0' ); |
| 355 | 354 | |
| 356 | 355 | if ( ! $controls ) { |
| 357 | 356 | $controls = $this->get_controls(); |
| @@ -612,10 +611,10 @@ | ||
| 612 | 611 | |
| 613 | 612 | $position = array_merge( $default_position, $position ); |
| 614 | 613 | |
| 615 | 614 | if ( |
| 616 | - ( 'control' === $position['type'] && in_array( $position['at'], [ 'start', 'end' ], true ) ) || | |
| 617 | - ( 'section' === $position['type'] && in_array( $position['at'], [ 'before', 'after' ], true ) ) | |
| 615 | + 'control' === $position['type'] && in_array( $position['at'], [ 'start', 'end' ], true ) || | |
| 616 | + 'section' === $position['type'] && in_array( $position['at'], [ 'before', 'after' ], true ) | |
| 618 | 617 | ) { |
| 619 | 618 | _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 | 619 | |
| 621 | 620 | return false; |
| @@ -637,13 +636,13 @@ | ||
| 637 | 636 | |
| 638 | 637 | $controls_keys = array_keys( $registered_controls ); |
| 639 | 638 | |
| 640 | 639 | while ( Controls_Manager::SECTION !== $registered_controls[ $controls_keys[ $target_section_index ] ]['type'] ) { |
| 641 | - --$target_section_index; | |
| 640 | + $target_section_index--; | |
| 642 | 641 | } |
| 643 | 642 | |
| 644 | 643 | if ( 'section' === $position['type'] ) { |
| 645 | - ++$target_control_index; | |
| 644 | + $target_control_index++; | |
| 646 | 645 | |
| 647 | 646 | if ( 'end' === $position['at'] ) { |
| 648 | 647 | while ( Controls_Manager::SECTION !== $registered_controls[ $controls_keys[ $target_control_index ] ]['type'] ) { |
| 649 | 648 | if ( ++$target_control_index >= count( $registered_controls ) ) { |
| @@ -655,9 +654,9 @@ | ||
| 655 | 654 | |
| 656 | 655 | $target_control = $registered_controls[ $controls_keys[ $target_control_index ] ]; |
| 657 | 656 | |
| 658 | 657 | if ( 'after' === $position['at'] ) { |
| 659 | - ++$target_control_index; | |
| 658 | + $target_control_index++; | |
| 660 | 659 | } |
| 661 | 660 | |
| 662 | 661 | $section_id = $registered_controls[ $controls_keys[ $target_section_index ] ]['name']; |
| 663 | 662 | |
| @@ -737,9 +736,9 @@ | ||
| 737 | 736 | |
| 738 | 737 | $controls_keys = array_keys( $registered_controls ); |
| 739 | 738 | |
| 740 | 739 | while ( true ) { |
| 741 | - ++$section_index; | |
| 740 | + $section_index++; | |
| 742 | 741 | |
| 743 | 742 | if ( ! isset( $controls_keys[ $section_index ] ) ) { |
| 744 | 743 | break; |
| 745 | 744 | } |
| @@ -750,9 +749,9 @@ | ||
| 750 | 749 | break; |
| 751 | 750 | } |
| 752 | 751 | |
| 753 | 752 | $section_controls[ $control_key ] = $registered_controls[ $control_key ]; |
| 754 | - } | |
| 753 | + }; | |
| 755 | 754 | |
| 756 | 755 | return $section_controls; |
| 757 | 756 | } |
| 758 | 757 | |
| @@ -796,9 +795,9 @@ | ||
| 796 | 795 | * @param array $settings Optional. Controls settings. Default is null. |
| 797 | 796 | * |
| 798 | 797 | * @return array Style controls. |
| 799 | 798 | */ |
| 800 | - final public function get_style_controls( ?array $controls = null, ?array $settings = null ) { | |
| 799 | + final public function get_style_controls( array $controls = null, array $settings = null ) { | |
| 801 | 800 | Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.0.0' ); |
| 802 | 801 | |
| 803 | 802 | $controls = $this->get_active_controls( $controls, $settings ); |
| 804 | 803 | |
| @@ -931,9 +930,9 @@ | ||
| 931 | 930 | $control_args = $args; |
| 932 | 931 | |
| 933 | 932 | // Set parent using the name from previous iteration. |
| 934 | 933 | if ( isset( $control_name ) ) { |
| 935 | - // If $control_name end with _widescreen use desktop name instead. | |
| 934 | + // If $control_name end with _widescreen use desktop name instead | |
| 936 | 935 | $control_args['parent'] = '_widescreen' === substr( $control_name, -strlen( '_widescreen' ) ) ? $id : $control_name; |
| 937 | 936 | } else { |
| 938 | 937 | $control_args['parent'] = null; |
| 939 | 938 | } |
| @@ -1060,10 +1059,10 @@ | ||
| 1060 | 1059 | * @return array|null The config. |
| 1061 | 1060 | */ |
| 1062 | 1061 | final public function get_config() { |
| 1063 | 1062 | 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. | |
| 1063 | + // TODO: This is for backwards compatibility starting from 2.9.0 | |
| 1064 | + // This if statement should be removed when the method is hard-deprecated | |
| 1066 | 1065 | if ( $this->has_own_method( '_get_initial_config', self::class ) ) { |
| 1067 | 1066 | Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_get_initial_config', '2.9.0', __CLASS__ . '::get_initial_config()' ); |
| 1068 | 1067 | |
| 1069 | 1068 | $this->config = $this->_get_initial_config(); |
| @@ -1087,10 +1086,8 @@ | ||
| 1087 | 1086 | * Set a config property. |
| 1088 | 1087 | * |
| 1089 | 1088 | * Set a specific property of the config list for this controls-stack. |
| 1090 | 1089 | * |
| 1091 | - * @param string $key | |
| 1092 | - * @param string $value | |
| 1093 | 1090 | * @since 3.5.0 |
| 1094 | 1091 | * @access public |
| 1095 | 1092 | */ |
| 1096 | 1093 | public function set_config( $key, $value ) { |
| @@ -1166,11 +1163,8 @@ | ||
| 1166 | 1163 | return self::get_items( $this->data, $item ); |
| 1167 | 1164 | } |
| 1168 | 1165 | |
| 1169 | 1166 | /** |
| 1170 | - * @param null $setting | |
| 1171 | - * @param null $settings | |
| 1172 | - * @return array|mixed|null | |
| 1173 | 1167 | * @since 2.0.14 |
| 1174 | 1168 | * @access public |
| 1175 | 1169 | */ |
| 1176 | 1170 | public function get_parsed_dynamic_settings( $setting = null, $settings = null ) { |
| @@ -1189,16 +1183,16 @@ | ||
| 1189 | 1183 | * Get active settings. |
| 1190 | 1184 | * |
| 1191 | 1185 | * Retrieve the settings from all the active controls. |
| 1192 | 1186 | * |
| 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. | |
| 1187 | + * @since 1.4.0 | |
| 1197 | 1188 | * @since 2.1.0 Added the `controls` and the `settings` parameters. |
| 1198 | 1189 | * @access public |
| 1199 | 1190 | * |
| 1200 | - * @since 1.4.0 | |
| 1191 | + * @param array $controls Optional. An array of controls. Default is null. | |
| 1192 | + * @param array $settings Optional. Controls settings. Default is null. | |
| 1193 | + * | |
| 1194 | + * @return array Active settings. | |
| 1201 | 1195 | */ |
| 1202 | 1196 | public function get_active_settings( $settings = null, $controls = null ) { |
| 1203 | 1197 | $is_first_request = ! $settings && ! $this->active_settings; |
| 1204 | 1198 | |
| @@ -1427,14 +1421,15 @@ | ||
| 1427 | 1421 | * Whether the control is visible or not. |
| 1428 | 1422 | * |
| 1429 | 1423 | * Used to determine whether the control is visible or not. |
| 1430 | 1424 | * |
| 1425 | + * @since 1.4.0 | |
| 1426 | + * @access public | |
| 1427 | + * | |
| 1431 | 1428 | * @param array $control The control. |
| 1432 | - * @param null $values Optional. Condition values. Default is null. | |
| 1433 | - * @param null $controls | |
| 1429 | + * @param array $values Optional. Condition values. Default is null. | |
| 1430 | + * | |
| 1434 | 1431 | * @return bool Whether the control is visible. |
| 1435 | - * @since 1.4.0 | |
| 1436 | - * @access public | |
| 1437 | 1432 | */ |
| 1438 | 1433 | public function is_control_visible( $control, $values = null, $controls = null ) { |
| 1439 | 1434 | if ( null === $values ) { |
| 1440 | 1435 | $values = $this->get_settings(); |
| @@ -1456,9 +1451,9 @@ | ||
| 1456 | 1451 | preg_match( '/([a-z_\-0-9]+)(?:\[([a-z_]+)])?(!?)$/i', $condition_key, $condition_key_parts ); |
| 1457 | 1452 | |
| 1458 | 1453 | $pure_condition_key = $condition_key_parts[1]; |
| 1459 | 1454 | $condition_sub_key = $condition_key_parts[2]; |
| 1460 | - $is_negative_condition = (bool) $condition_key_parts[3]; | |
| 1455 | + $is_negative_condition = ! ! $condition_key_parts[3]; | |
| 1461 | 1456 | |
| 1462 | 1457 | if ( ! isset( $values[ $pure_condition_key ] ) || null === $values[ $pure_condition_key ] ) { |
| 1463 | 1458 | return false; |
| 1464 | 1459 | } |
| @@ -1521,12 +1516,9 @@ | ||
| 1521 | 1516 | } else { |
| 1522 | 1517 | $is_contains = $instance_value === $condition_value; |
| 1523 | 1518 | } |
| 1524 | 1519 | |
| 1525 | - if ( | |
| 1526 | - ( $is_negative_condition && $is_contains ) || | |
| 1527 | - ( ! $is_negative_condition && ! $is_contains ) | |
| 1528 | - ) { | |
| 1520 | + if ( $is_negative_condition && $is_contains || ! $is_negative_condition && ! $is_contains ) { | |
| 1529 | 1521 | return false; |
| 1530 | 1522 | } |
| 1531 | 1523 | } |
| 1532 | 1524 | |
| @@ -2013,10 +2005,10 @@ | ||
| 2013 | 2005 | * |
| 2014 | 2006 | * @since 2.7.0 |
| 2015 | 2007 | * @access public |
| 2016 | 2008 | * |
| 2017 | - * @param string $element The HTML element. | |
| 2018 | - * @param string $key Optional. Attribute key. Default is null. | |
| 2009 | + * @param string $element The HTML element. | |
| 2010 | + * @param string $key Optional. Attribute key. Default is null. | |
| 2019 | 2011 | * @param array|string $values Optional. Attribute value/s. Default is null. |
| 2020 | 2012 | */ |
| 2021 | 2013 | public function remove_render_attribute( $element, $key = null, $values = null ) { |
| 2022 | 2014 | if ( $key && ! isset( $this->render_attributes[ $element ][ $key ] ) ) { |
| @@ -2073,9 +2065,9 @@ | ||
| 2073 | 2065 | * |
| 2074 | 2066 | * @param array|string $element The element. |
| 2075 | 2067 | */ |
| 2076 | 2068 | public function print_render_attribute_string( $element ) { |
| 2077 | - Utils::print_unescaped_internal_string( $this->get_render_attribute_string( $element ) ); | |
| 2069 | + echo $this->get_render_attribute_string( $element ); // XSS ok. | |
| 2078 | 2070 | } |
| 2079 | 2071 | |
| 2080 | 2072 | /** |
| 2081 | 2073 | * Print element template. |
| @@ -2088,9 +2080,9 @@ | ||
| 2088 | 2080 | public function print_template() { |
| 2089 | 2081 | ob_start(); |
| 2090 | 2082 | |
| 2091 | 2083 | // TODO: This is for backwards compatibility starting from 2.9.0 |
| 2092 | - // This `if` statement should be removed when the method is removed. | |
| 2084 | + // This `if` statement should be removed when the method is removed | |
| 2093 | 2085 | if ( $this->has_own_method( '_content_template', self::class ) ) { |
| 2094 | 2086 | Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_content_template', '2.9.0', __CLASS__ . '::content_template()' ); |
| 2095 | 2087 | |
| 2096 | 2088 | $this->_content_template(); |
| @@ -2136,9 +2128,9 @@ | ||
| 2136 | 2128 | * @param array|null $controls The available controls. |
| 2137 | 2129 | * |
| 2138 | 2130 | * @return array Element data. |
| 2139 | 2131 | */ |
| 2140 | - public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ): array { | |
| 2132 | + public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ) : array { | |
| 2141 | 2133 | return $config; |
| 2142 | 2134 | } |
| 2143 | 2135 | |
| 2144 | 2136 | /** |
| @@ -2385,9 +2377,9 @@ | ||
| 2385 | 2377 | * |
| 2386 | 2378 | * @param string $template_content Template content. |
| 2387 | 2379 | */ |
| 2388 | 2380 | protected function print_template_content( $template_content ) { |
| 2389 | - Utils::print_unescaped_internal_string( $template_content ); | |
| 2381 | + echo $template_content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 2390 | 2382 | } |
| 2391 | 2383 | |
| 2392 | 2384 | /** |
| 2393 | 2385 | * Render element output in the editor. |
| @@ -2425,9 +2417,9 @@ | ||
| 2425 | 2417 | protected function init_controls() { |
| 2426 | 2418 | Plugin::$instance->controls_manager->open_stack( $this ); |
| 2427 | 2419 | |
| 2428 | 2420 | // TODO: This is for backwards compatibility starting from 2.9.0 |
| 2429 | - // This `if` statement should be removed when the method is removed. | |
| 2421 | + // This `if` statement should be removed when the method is removed | |
| 2430 | 2422 | if ( $this->has_own_method( '_register_controls', self::class ) ) { |
| 2431 | 2423 | Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_register_controls', '3.1.0', __CLASS__ . '::register_controls()' ); |
| 2432 | 2424 | |
| 2433 | 2425 | $this->_register_controls(); |
| @@ -2572,9 +2564,9 @@ | ||
| 2572 | 2564 | */ |
| 2573 | 2565 | public function __construct( array $data = [] ) { |
| 2574 | 2566 | if ( $data ) { |
| 2575 | 2567 | // TODO: This is for backwards compatibility starting from 2.9.0 |
| 2576 | - // This if statement should be removed when the method is hard-deprecated. | |
| 2568 | + // This if statement should be removed when the method is hard-deprecated | |
| 2577 | 2569 | if ( $this->has_own_method( '_init', self::class ) ) { |
| 2578 | 2570 | Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_init', '2.9.0', __CLASS__ . '::init()' ); |
| 2579 | 2571 | |
| 2580 | 2572 | $this->_init( $data ); |