| @@ -2,11 +2,9 @@ | ||
| 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\Breakpoints\Manager as Breakpoints_Manager; | |
| 7 | -use Elementor\Core\Frontend\Performance; | |
| 8 | -use Elementor\Utils; | |
| 6 | +use Elementor\Core\Schemes\Manager as Schemes_Manager; | |
| 9 | 7 | |
| 10 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | 9 | exit; // Exit if accessed directly. |
| 12 | 10 | } |
| @@ -23,24 +21,18 @@ | ||
| 23 | 21 | abstract class Controls_Stack extends Base_Object { |
| 24 | 22 | |
| 25 | 23 | /** |
| 26 | 24 | * Responsive 'desktop' device name. |
| 27 | - * | |
| 28 | - * @deprecated 3.4.0 | |
| 29 | 25 | */ |
| 30 | 26 | const RESPONSIVE_DESKTOP = 'desktop'; |
| 31 | 27 | |
| 32 | 28 | /** |
| 33 | 29 | * Responsive 'tablet' device name. |
| 34 | - * | |
| 35 | - * @deprecated 3.4.0 | |
| 36 | 30 | */ |
| 37 | 31 | const RESPONSIVE_TABLET = 'tablet'; |
| 38 | 32 | |
| 39 | 33 | /** |
| 40 | 34 | * Responsive 'mobile' device name. |
| 41 | - * | |
| 42 | - * @deprecated 3.4.0 | |
| 43 | 35 | */ |
| 44 | 36 | const RESPONSIVE_MOBILE = 'mobile'; |
| 45 | 37 | |
| 46 | 38 | /** |
| @@ -91,22 +83,8 @@ | ||
| 91 | 83 | */ |
| 92 | 84 | private $config; |
| 93 | 85 | |
| 94 | 86 | /** |
| 95 | - * The additional configuration. | |
| 96 | - * | |
| 97 | - * Holds additional configuration that has been set using `set_config` method. | |
| 98 | - * The `config` property is not modified directly while using the method because | |
| 99 | - * it's used to check whether the initial config already loaded (in `get_config`). | |
| 100 | - * After the initial config loaded, the additional config is merged into it. | |
| 101 | - * | |
| 102 | - * @access private | |
| 103 | - * | |
| 104 | - * @var null|array | |
| 105 | - */ | |
| 106 | - private $additional_config = []; | |
| 107 | - | |
| 108 | - /** | |
| 109 | 87 | * Current section. |
| 110 | 88 | * |
| 111 | 89 | * Holds the current section while inserting a set of controls sections. |
| 112 | 90 | * |
| @@ -159,20 +137,8 @@ | ||
| 159 | 137 | */ |
| 160 | 138 | private $settings_sanitized = false; |
| 161 | 139 | |
| 162 | 140 | /** |
| 163 | - * Element render attributes. | |
| 164 | - * | |
| 165 | - * Holds all the render attributes of the element. Used to store data like | |
| 166 | - * the HTML class name and the class value, or HTML element ID name and value. | |
| 167 | - * | |
| 168 | - * @access private | |
| 169 | - * | |
| 170 | - * @var array | |
| 171 | - */ | |
| 172 | - private $render_attributes = []; | |
| 173 | - | |
| 174 | - /** | |
| 175 | 141 | * Get element name. |
| 176 | 142 | * |
| 177 | 143 | * Retrieve the element name. |
| 178 | 144 | * |
| @@ -226,26 +192,12 @@ | ||
| 226 | 192 | public function get_id_int() { |
| 227 | 193 | /** We ignore possible notices, in order to support elements created prior to v1.8.0 and might include |
| 228 | 194 | * non-base 16 characters as part of their ID. |
| 229 | 195 | */ |
| 230 | - return @hexdec( (string) $this->id ); | |
| 196 | + return @hexdec( $this->id ); | |
| 231 | 197 | } |
| 232 | 198 | |
| 233 | 199 | /** |
| 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 | 200 | * Get the type. |
| 249 | 201 | * |
| 250 | 202 | * Retrieve the type, e.g. 'stack', 'section', 'widget' etc. |
| 251 | 203 | * |
| @@ -269,8 +221,35 @@ | ||
| 269 | 221 | return true; |
| 270 | 222 | } |
| 271 | 223 | |
| 272 | 224 | /** |
| 225 | + * Get items. | |
| 226 | + * | |
| 227 | + * Utility method that receives an array with a needle and returns all the | |
| 228 | + * items that match the needle. If needle is not defined the entire haystack | |
| 229 | + * will be returned. | |
| 230 | + * | |
| 231 | + * @since 1.4.0 | |
| 232 | + * @deprecated 2.3.0 Use `Controls_Stack::get_items()` instead | |
| 233 | + * @access protected | |
| 234 | + * @static | |
| 235 | + * | |
| 236 | + * @param array $haystack An array of items. | |
| 237 | + * @param string $needle Optional. Needle. Default is null. | |
| 238 | + * | |
| 239 | + * @return mixed The whole haystack or the needle from the haystack when requested. | |
| 240 | + */ | |
| 241 | + protected static function _get_items( array $haystack, $needle = null ) { | |
| 242 | + _deprecated_function( __METHOD__, '2.3.0', __CLASS__ . '::get_items()' ); | |
| 243 | + | |
| 244 | + if ( $needle ) { | |
| 245 | + return isset( $haystack[ $needle ] ) ? $haystack[ $needle ] : null; | |
| 246 | + } | |
| 247 | + | |
| 248 | + return $haystack; | |
| 249 | + } | |
| 250 | + | |
| 251 | + /** | |
| 273 | 252 | * Get current section. |
| 274 | 253 | * |
| 275 | 254 | * When inserting new controls, this method will retrieve the current section. |
| 276 | 255 | * |
| @@ -311,26 +290,9 @@ | ||
| 311 | 290 | * |
| 312 | 291 | * @return mixed Controls list. |
| 313 | 292 | */ |
| 314 | 293 | 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 ); | |
| 294 | + return self::get_items( $this->get_stack()['controls'], $control_id ); | |
| 333 | 295 | } |
| 334 | 296 | |
| 335 | 297 | /** |
| 336 | 298 | * Get active controls. |
| @@ -349,10 +311,10 @@ | ||
| 349 | 311 | * @param array $settings Optional. Controls settings. Default is null. |
| 350 | 312 | * |
| 351 | 313 | * @return array Active controls. |
| 352 | 314 | */ |
| 353 | - public function get_active_controls( ?array $controls = null, ?array $settings = null ) { | |
| 354 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.0.0' ); | |
| 315 | + public function get_active_controls( array $controls = null, array $settings = null ) { | |
| 316 | + // _deprecated_function( __METHOD__, '3.0.0' ); | |
| 355 | 317 | |
| 356 | 318 | if ( ! $controls ) { |
| 357 | 319 | $controls = $this->get_controls(); |
| 358 | 320 | } |
| @@ -364,9 +326,9 @@ | ||
| 364 | 326 | $active_controls = array_reduce( |
| 365 | 327 | array_keys( $controls ), function( $active_controls, $control_key ) use ( $controls, $settings ) { |
| 366 | 328 | $control = $controls[ $control_key ]; |
| 367 | 329 | |
| 368 | - if ( $this->is_control_visible( $control, $settings, $controls ) ) { | |
| 330 | + if ( $this->is_control_visible( $control, $settings ) ) { | |
| 369 | 331 | $active_controls[ $control_key ] = $control; |
| 370 | 332 | } |
| 371 | 333 | |
| 372 | 334 | return $active_controls; |
| @@ -394,9 +356,9 @@ | ||
| 394 | 356 | * Add new control to stack. |
| 395 | 357 | * |
| 396 | 358 | * Register a single control to allow the user to set/update data. |
| 397 | 359 | * |
| 398 | - * This method should be used inside `register_controls()`. | |
| 360 | + * This method should be used inside `_register_controls()`. | |
| 399 | 361 | * |
| 400 | 362 | * @since 1.4.0 |
| 401 | 363 | * @access public |
| 402 | 364 | * |
| @@ -439,58 +401,14 @@ | ||
| 439 | 401 | } |
| 440 | 402 | |
| 441 | 403 | unset( $options['position'] ); |
| 442 | 404 | |
| 443 | - if ( $this->current_popover ) { | |
| 444 | - $args['popover'] = []; | |
| 445 | - | |
| 446 | - if ( ! $this->current_popover['initialized'] ) { | |
| 447 | - $args['popover']['start'] = true; | |
| 448 | - | |
| 449 | - $this->current_popover['initialized'] = true; | |
| 450 | - } | |
| 451 | - } | |
| 452 | - | |
| 453 | - if ( Performance::should_optimize_controls() ) { | |
| 454 | - $ui_controls = [ | |
| 455 | - Controls_Manager::RAW_HTML, | |
| 456 | - Controls_Manager::DIVIDER, | |
| 457 | - Controls_Manager::HEADING, | |
| 458 | - Controls_Manager::BUTTON, | |
| 459 | - Controls_Manager::ALERT, | |
| 460 | - Controls_Manager::NOTICE, | |
| 461 | - Controls_Manager::DEPRECATED_NOTICE, | |
| 405 | + if ( $this->current_popover && ! $this->current_popover['initialized'] ) { | |
| 406 | + $args['popover'] = [ | |
| 407 | + 'start' => true, | |
| 462 | 408 | ]; |
| 463 | 409 | |
| 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 | - ); | |
| 410 | + $this->current_popover['initialized'] = true; | |
| 493 | 411 | } |
| 494 | 412 | |
| 495 | 413 | return Plugin::$instance->controls_manager->add_control_to_stack( $this, $id, $args, $options ); |
| 496 | 414 | } |
| @@ -612,12 +530,12 @@ | ||
| 612 | 530 | |
| 613 | 531 | $position = array_merge( $default_position, $position ); |
| 614 | 532 | |
| 615 | 533 | if ( |
| 616 | - ( 'control' === $position['type'] && in_array( $position['at'], [ 'start', 'end' ], true ) ) || | |
| 617 | - ( 'section' === $position['type'] && in_array( $position['at'], [ 'before', 'after' ], true ) ) | |
| 534 | + 'control' === $position['type'] && in_array( $position['at'], [ 'start', 'end' ], true ) || | |
| 535 | + 'section' === $position['type'] && in_array( $position['at'], [ 'before', 'after' ], true ) | |
| 618 | 536 | ) { |
| 619 | - _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 | |
| 537 | + _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' ); | |
| 620 | 538 | |
| 621 | 539 | return false; |
| 622 | 540 | } |
| 623 | 541 | |
| @@ -637,13 +555,13 @@ | ||
| 637 | 555 | |
| 638 | 556 | $controls_keys = array_keys( $registered_controls ); |
| 639 | 557 | |
| 640 | 558 | while ( Controls_Manager::SECTION !== $registered_controls[ $controls_keys[ $target_section_index ] ]['type'] ) { |
| 641 | - --$target_section_index; | |
| 559 | + $target_section_index--; | |
| 642 | 560 | } |
| 643 | 561 | |
| 644 | 562 | if ( 'section' === $position['type'] ) { |
| 645 | - ++$target_control_index; | |
| 563 | + $target_control_index++; | |
| 646 | 564 | |
| 647 | 565 | if ( 'end' === $position['at'] ) { |
| 648 | 566 | while ( Controls_Manager::SECTION !== $registered_controls[ $controls_keys[ $target_control_index ] ]['type'] ) { |
| 649 | 567 | if ( ++$target_control_index >= count( $registered_controls ) ) { |
| @@ -655,9 +573,9 @@ | ||
| 655 | 573 | |
| 656 | 574 | $target_control = $registered_controls[ $controls_keys[ $target_control_index ] ]; |
| 657 | 575 | |
| 658 | 576 | if ( 'after' === $position['at'] ) { |
| 659 | - ++$target_control_index; | |
| 577 | + $target_control_index++; | |
| 660 | 578 | } |
| 661 | 579 | |
| 662 | 580 | $section_id = $registered_controls[ $controls_keys[ $target_section_index ] ]['name']; |
| 663 | 581 | |
| @@ -737,9 +655,9 @@ | ||
| 737 | 655 | |
| 738 | 656 | $controls_keys = array_keys( $registered_controls ); |
| 739 | 657 | |
| 740 | 658 | while ( true ) { |
| 741 | - ++$section_index; | |
| 659 | + $section_index++; | |
| 742 | 660 | |
| 743 | 661 | if ( ! isset( $controls_keys[ $section_index ] ) ) { |
| 744 | 662 | break; |
| 745 | 663 | } |
| @@ -750,9 +668,9 @@ | ||
| 750 | 668 | break; |
| 751 | 669 | } |
| 752 | 670 | |
| 753 | 671 | $section_controls[ $control_key ] = $registered_controls[ $control_key ]; |
| 754 | - } | |
| 672 | + }; | |
| 755 | 673 | |
| 756 | 674 | return $section_controls; |
| 757 | 675 | } |
| 758 | 676 | |
| @@ -774,9 +692,9 @@ | ||
| 774 | 692 | final public function add_group_control( $group_name, array $args = [], array $options = [] ) { |
| 775 | 693 | $group = Plugin::$instance->controls_manager->get_control_groups( $group_name ); |
| 776 | 694 | |
| 777 | 695 | if ( ! $group ) { |
| 778 | - wp_die( sprintf( '%s::%s: Group "%s" not found.', get_called_class(), __FUNCTION__, $group_name ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 696 | + wp_die( sprintf( '%s::%s: Group "%s" not found.', get_called_class(), __FUNCTION__, $group_name ) ); | |
| 779 | 697 | } |
| 780 | 698 | |
| 781 | 699 | $group->add_controls( $this, $args, $options ); |
| 782 | 700 | } |
| @@ -781,8 +699,30 @@ | ||
| 781 | 699 | $group->add_controls( $this, $args, $options ); |
| 782 | 700 | } |
| 783 | 701 | |
| 784 | 702 | /** |
| 703 | + * Get scheme controls. | |
| 704 | + * | |
| 705 | + * Retrieve all the controls that use schemes. | |
| 706 | + * | |
| 707 | + * @since 1.4.0 | |
| 708 | + * @access public | |
| 709 | + * @deprecated 3.0.0 | |
| 710 | + * | |
| 711 | + * @return array Scheme controls. | |
| 712 | + */ | |
| 713 | + final public function get_scheme_controls() { | |
| 714 | + // _deprecated_function( __METHOD__, '3.0.0' ); | |
| 715 | + $enabled_schemes = Schemes_Manager::get_enabled_schemes(); | |
| 716 | + | |
| 717 | + return array_filter( | |
| 718 | + $this->get_controls(), function( $control ) use ( $enabled_schemes ) { | |
| 719 | + return ( ! empty( $control['scheme'] ) && in_array( $control['scheme']['type'], $enabled_schemes ) ); | |
| 720 | + } | |
| 721 | + ); | |
| 722 | + } | |
| 723 | + | |
| 724 | + /** | |
| 785 | 725 | * Get style controls. |
| 786 | 726 | * |
| 787 | 727 | * Retrieve style controls for all active controls or, when requested, from |
| 788 | 728 | * a specific set of controls. |
| @@ -796,10 +736,10 @@ | ||
| 796 | 736 | * @param array $settings Optional. Controls settings. Default is null. |
| 797 | 737 | * |
| 798 | 738 | * @return array Style controls. |
| 799 | 739 | */ |
| 800 | - final public function get_style_controls( ?array $controls = null, ?array $settings = null ) { | |
| 801 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.0.0' ); | |
| 740 | + final public function get_style_controls( array $controls = null, array $settings = null ) { | |
| 741 | + // _deprecated_function( __METHOD__, '3.0.0' ); | |
| 802 | 742 | |
| 803 | 743 | $controls = $this->get_active_controls( $controls, $settings ); |
| 804 | 744 | |
| 805 | 745 | $style_controls = []; |
| @@ -848,15 +788,9 @@ | ||
| 848 | 788 | /** |
| 849 | 789 | * Add new responsive control to stack. |
| 850 | 790 | * |
| 851 | 791 | * Register a set of controls to allow editing based on user screen size. |
| 852 | - * This method registers one or more controls per screen size/device, depending on the current Responsive Control | |
| 853 | - * Duplication Mode. There are 3 control duplication modes: | |
| 854 | - * * 'off' - Only a single control is generated. In the Editor, this control is duplicated in JS. | |
| 855 | - * * 'on' - Multiple controls are generated, one control per enabled device/breakpoint + a default/desktop control. | |
| 856 | - * * 'dynamic' - If the control includes the `'dynamic' => 'active' => true` property - the control is duplicated, | |
| 857 | - * once for each device/breakpoint + default/desktop. | |
| 858 | - * If the control doesn't include the `'dynamic' => 'active' => true` property - the control is not duplicated. | |
| 792 | + * This method registers three screen sizes: Desktop, Tablet and Mobile. | |
| 859 | 793 | * |
| 860 | 794 | * @since 1.4.0 |
| 861 | 795 | * @access public |
| 862 | 796 | * |
| @@ -867,15 +801,14 @@ | ||
| 867 | 801 | */ |
| 868 | 802 | final public function add_responsive_control( $id, array $args, $options = [] ) { |
| 869 | 803 | $args['responsive'] = []; |
| 870 | 804 | |
| 871 | - $active_breakpoints = Plugin::$instance->breakpoints->get_active_breakpoints(); | |
| 805 | + $devices = [ | |
| 806 | + self::RESPONSIVE_DESKTOP, | |
| 807 | + self::RESPONSIVE_TABLET, | |
| 808 | + self::RESPONSIVE_MOBILE, | |
| 809 | + ]; | |
| 872 | 810 | |
| 873 | - $devices = Plugin::$instance->breakpoints->get_active_devices_list( [ | |
| 874 | - 'reverse' => true, | |
| 875 | - 'desktop_first' => true, | |
| 876 | - ] ); | |
| 877 | - | |
| 878 | 811 | if ( isset( $args['devices'] ) ) { |
| 879 | 812 | $devices = array_intersect( $devices, $args['devices'] ); |
| 880 | 813 | |
| 881 | 814 | $args['responsive']['devices'] = $devices; |
| @@ -882,46 +815,8 @@ | ||
| 882 | 815 | |
| 883 | 816 | unset( $args['devices'] ); |
| 884 | 817 | } |
| 885 | 818 | |
| 886 | - $control_to_check = $args; | |
| 887 | - | |
| 888 | - if ( ! empty( $options['overwrite'] ) ) { | |
| 889 | - $existing_control = Plugin::$instance->controls_manager->get_control_from_stack( $this->get_unique_name(), $id ); | |
| 890 | - | |
| 891 | - if ( ! is_wp_error( $existing_control ) ) { | |
| 892 | - $control_to_check = $existing_control; | |
| 893 | - } | |
| 894 | - } | |
| 895 | - | |
| 896 | - $responsive_duplication_mode = Plugin::$instance->breakpoints->get_responsive_control_duplication_mode(); | |
| 897 | - $additional_breakpoints_active = Plugin::$instance->experiments->is_feature_active( 'additional_custom_breakpoints' ); | |
| 898 | - $control_is_dynamic = ! empty( $control_to_check['dynamic']['active'] ); | |
| 899 | - $is_frontend_available = ! empty( $control_to_check['frontend_available'] ); | |
| 900 | - $has_prefix_class = ! empty( $control_to_check['prefix_class'] ); | |
| 901 | - | |
| 902 | - // If the new responsive controls experiment is active, create only one control - duplicates per device will | |
| 903 | - // be created in JS in the Editor. | |
| 904 | - if ( | |
| 905 | - $additional_breakpoints_active | |
| 906 | - && ( 'off' === $responsive_duplication_mode || ( 'dynamic' === $responsive_duplication_mode && ! $control_is_dynamic ) ) | |
| 907 | - // Some responsive controls need responsive settings to be available to the widget handler, even when empty. | |
| 908 | - && ! $is_frontend_available | |
| 909 | - && ! $has_prefix_class | |
| 910 | - ) { | |
| 911 | - $args['is_responsive'] = true; | |
| 912 | - | |
| 913 | - if ( ! empty( $options['overwrite'] ) ) { | |
| 914 | - $this->update_control( $id, $args, [ | |
| 915 | - 'recursive' => ! empty( $options['recursive'] ), | |
| 916 | - ] ); | |
| 917 | - } else { | |
| 918 | - $this->add_control( $id, $args, $options ); | |
| 919 | - } | |
| 920 | - | |
| 921 | - return; | |
| 922 | - } | |
| 923 | - | |
| 924 | 819 | if ( isset( $args['default'] ) ) { |
| 925 | 820 | $args['desktop_default'] = $args['default']; |
| 926 | 821 | |
| 927 | 822 | unset( $args['default'] ); |
| @@ -929,16 +824,8 @@ | ||
| 929 | 824 | |
| 930 | 825 | foreach ( $devices as $device_name ) { |
| 931 | 826 | $control_args = $args; |
| 932 | 827 | |
| 933 | - // Set parent using the name from previous iteration. | |
| 934 | - if ( isset( $control_name ) ) { | |
| 935 | - // If $control_name end with _widescreen use desktop name instead. | |
| 936 | - $control_args['parent'] = '_widescreen' === substr( $control_name, -strlen( '_widescreen' ) ) ? $id : $control_name; | |
| 937 | - } else { | |
| 938 | - $control_args['parent'] = null; | |
| 939 | - } | |
| 940 | - | |
| 941 | 828 | if ( isset( $control_args['device_args'] ) ) { |
| 942 | 829 | if ( ! empty( $control_args['device_args'][ $device_name ] ) ) { |
| 943 | 830 | $control_args = array_merge( $control_args, $control_args['device_args'][ $device_name ] ); |
| 944 | 831 | } |
| @@ -946,21 +833,15 @@ | ||
| 946 | 833 | unset( $control_args['device_args'] ); |
| 947 | 834 | } |
| 948 | 835 | |
| 949 | 836 | if ( ! empty( $args['prefix_class'] ) ) { |
| 950 | - $device_to_replace = Breakpoints_Manager::BREAKPOINT_KEY_DESKTOP === $device_name ? '' : '-' . $device_name; | |
| 837 | + $device_to_replace = self::RESPONSIVE_DESKTOP === $device_name ? '' : '-' . $device_name; | |
| 951 | 838 | |
| 952 | 839 | $control_args['prefix_class'] = sprintf( $args['prefix_class'], $device_to_replace ); |
| 953 | 840 | } |
| 954 | 841 | |
| 955 | - $direction = 'max'; | |
| 842 | + $control_args['responsive']['max'] = $device_name; | |
| 956 | 843 | |
| 957 | - if ( Breakpoints_Manager::BREAKPOINT_KEY_DESKTOP !== $device_name ) { | |
| 958 | - $direction = $active_breakpoints[ $device_name ]->get_direction(); | |
| 959 | - } | |
| 960 | - | |
| 961 | - $control_args['responsive'][ $direction ] = $device_name; | |
| 962 | - | |
| 963 | 844 | if ( isset( $control_args['min_affected_device'] ) ) { |
| 964 | 845 | if ( ! empty( $control_args['min_affected_device'][ $device_name ] ) ) { |
| 965 | 846 | $control_args['responsive']['min'] = $control_args['min_affected_device'][ $device_name ]; |
| 966 | 847 | } |
| @@ -971,26 +852,20 @@ | ||
| 971 | 852 | if ( isset( $control_args[ $device_name . '_default' ] ) ) { |
| 972 | 853 | $control_args['default'] = $control_args[ $device_name . '_default' ]; |
| 973 | 854 | } |
| 974 | 855 | |
| 975 | - foreach ( $devices as $device ) { | |
| 976 | - unset( $control_args[ $device . '_default' ] ); | |
| 977 | - } | |
| 856 | + unset( $control_args['desktop_default'] ); | |
| 857 | + unset( $control_args['tablet_default'] ); | |
| 858 | + unset( $control_args['mobile_default'] ); | |
| 978 | 859 | |
| 979 | - $id_suffix = Breakpoints_Manager::BREAKPOINT_KEY_DESKTOP === $device_name ? '' : '_' . $device_name; | |
| 980 | - $control_name = $id . $id_suffix; | |
| 860 | + $id_suffix = self::RESPONSIVE_DESKTOP === $device_name ? '' : '_' . $device_name; | |
| 981 | 861 | |
| 982 | - // 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 | - } | |
| 986 | - | |
| 987 | 862 | if ( ! empty( $options['overwrite'] ) ) { |
| 988 | - $this->update_control( $control_name, $control_args, [ | |
| 863 | + $this->update_control( $id . $id_suffix, $control_args, [ | |
| 989 | 864 | 'recursive' => ! empty( $options['recursive'] ), |
| 990 | 865 | ] ); |
| 991 | 866 | } else { |
| 992 | - $this->add_control( $control_name, $control_args, $options ); | |
| 867 | + $this->add_control( $id . $id_suffix, $control_args, $options ); | |
| 993 | 868 | } |
| 994 | 869 | } |
| 995 | 870 | } |
| 996 | 871 | |
| @@ -1025,12 +900,16 @@ | ||
| 1025 | 900 | * |
| 1026 | 901 | * @param string $id Responsive control ID. |
| 1027 | 902 | */ |
| 1028 | 903 | final public function remove_responsive_control( $id ) { |
| 1029 | - $devices = Plugin::$instance->breakpoints->get_active_devices_list( [ 'reverse' => true ] ); | |
| 904 | + $devices = [ | |
| 905 | + self::RESPONSIVE_DESKTOP, | |
| 906 | + self::RESPONSIVE_TABLET, | |
| 907 | + self::RESPONSIVE_MOBILE, | |
| 908 | + ]; | |
| 1030 | 909 | |
| 1031 | 910 | foreach ( $devices as $device_name ) { |
| 1032 | - $id_suffix = Breakpoints_Manager::BREAKPOINT_KEY_DESKTOP === $device_name ? '' : '_' . $device_name; | |
| 911 | + $id_suffix = self::RESPONSIVE_DESKTOP === $device_name ? '' : '_' . $device_name; | |
| 1033 | 912 | |
| 1034 | 913 | $this->remove_control( $id . $id_suffix ); |
| 1035 | 914 | } |
| 1036 | 915 | } |
| @@ -1060,25 +939,15 @@ | ||
| 1060 | 939 | * @return array|null The config. |
| 1061 | 940 | */ |
| 1062 | 941 | final public function get_config() { |
| 1063 | 942 | 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. | |
| 1066 | - if ( $this->has_own_method( '_get_initial_config', self::class ) ) { | |
| 1067 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_get_initial_config', '2.9.0', __CLASS__ . '::get_initial_config()' ); | |
| 1068 | - | |
| 943 | + // TODO: This is for backwards compatibility starting from 2.9.0 | |
| 944 | + // This if statement should be removed when the method is hard-deprecated | |
| 945 | + if ( method_exists( $this, '_get_initial_config' ) ) { | |
| 1069 | 946 | $this->config = $this->_get_initial_config(); |
| 1070 | 947 | } else { |
| 1071 | 948 | $this->config = $this->get_initial_config(); |
| 1072 | 949 | } |
| 1073 | - | |
| 1074 | - foreach ( $this->additional_config as $key => $value ) { | |
| 1075 | - if ( isset( $this->config[ $key ] ) ) { | |
| 1076 | - $this->config[ $key ] = wp_parse_args( $value, $this->config[ $key ] ); | |
| 1077 | - } else { | |
| 1078 | - $this->config[ $key ] = $value; | |
| 1079 | - } | |
| 1080 | - } | |
| 1081 | 950 | } |
| 1082 | 951 | |
| 1083 | 952 | return $this->config; |
| 1084 | 953 | } |
| @@ -1083,26 +952,8 @@ | ||
| 1083 | 952 | return $this->config; |
| 1084 | 953 | } |
| 1085 | 954 | |
| 1086 | 955 | /** |
| 1087 | - * Set a config property. | |
| 1088 | - * | |
| 1089 | - * Set a specific property of the config list for this controls-stack. | |
| 1090 | - * | |
| 1091 | - * @param string $key | |
| 1092 | - * @param string $value | |
| 1093 | - * @since 3.5.0 | |
| 1094 | - * @access public | |
| 1095 | - */ | |
| 1096 | - public function set_config( $key, $value ) { | |
| 1097 | - if ( isset( $this->additional_config[ $key ] ) ) { | |
| 1098 | - $this->additional_config[ $key ] = wp_parse_args( $value, $this->additional_config[ $key ] ); | |
| 1099 | - } else { | |
| 1100 | - $this->additional_config[ $key ] = $value; | |
| 1101 | - } | |
| 1102 | - } | |
| 1103 | - | |
| 1104 | - /** | |
| 1105 | 956 | * Get frontend settings keys. |
| 1106 | 957 | * |
| 1107 | 958 | * Retrieve settings keys for all frontend controls. |
| 1108 | 959 | * |
| @@ -1166,11 +1017,8 @@ | ||
| 1166 | 1017 | return self::get_items( $this->data, $item ); |
| 1167 | 1018 | } |
| 1168 | 1019 | |
| 1169 | 1020 | /** |
| 1170 | - * @param null $setting | |
| 1171 | - * @param null $settings | |
| 1172 | - * @return array|mixed|null | |
| 1173 | 1021 | * @since 2.0.14 |
| 1174 | 1022 | * @access public |
| 1175 | 1023 | */ |
| 1176 | 1024 | public function get_parsed_dynamic_settings( $setting = null, $settings = null ) { |
| @@ -1184,28 +1032,21 @@ | ||
| 1184 | 1032 | |
| 1185 | 1033 | return self::get_items( $this->parsed_dynamic_settings, $setting ); |
| 1186 | 1034 | } |
| 1187 | 1035 | |
| 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 | 1036 | /** |
| 1196 | 1037 | * Get active settings. |
| 1197 | 1038 | * |
| 1198 | 1039 | * Retrieve the settings from all the active controls. |
| 1199 | 1040 | * |
| 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. | |
| 1041 | + * @since 1.4.0 | |
| 1204 | 1042 | * @since 2.1.0 Added the `controls` and the `settings` parameters. |
| 1205 | 1043 | * @access public |
| 1206 | 1044 | * |
| 1207 | - * @since 1.4.0 | |
| 1045 | + * @param array $controls Optional. An array of controls. Default is null. | |
| 1046 | + * @param array $settings Optional. Controls settings. Default is null. | |
| 1047 | + * | |
| 1048 | + * @return array Active settings. | |
| 1208 | 1049 | */ |
| 1209 | 1050 | public function get_active_settings( $settings = null, $controls = null ) { |
| 1210 | 1051 | $is_first_request = ! $settings && ! $this->active_settings; |
| 1211 | 1052 | |
| @@ -1220,10 +1061,8 @@ | ||
| 1220 | 1061 | } |
| 1221 | 1062 | |
| 1222 | 1063 | $active_settings = []; |
| 1223 | 1064 | |
| 1224 | - $controls_objs = Plugin::$instance->controls_manager->get_controls(); | |
| 1225 | - | |
| 1226 | 1065 | foreach ( $settings as $setting_key => $setting ) { |
| 1227 | 1066 | if ( ! isset( $controls[ $setting_key ] ) ) { |
| 1228 | 1067 | $active_settings[ $setting_key ] = $setting; |
| 1229 | 1068 | |
| @@ -1231,10 +1070,10 @@ | ||
| 1231 | 1070 | } |
| 1232 | 1071 | |
| 1233 | 1072 | $control = $controls[ $setting_key ]; |
| 1234 | 1073 | |
| 1235 | - if ( $this->is_control_visible( $control, $settings, $controls ) ) { | |
| 1236 | - $control_obj = $controls_objs[ $control['type'] ] ?? null; | |
| 1074 | + if ( $this->is_control_visible( $control, $settings ) ) { | |
| 1075 | + $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] ); | |
| 1237 | 1076 | |
| 1238 | 1077 | if ( $control_obj instanceof Control_Repeater ) { |
| 1239 | 1078 | foreach ( $setting as & $item ) { |
| 1240 | 1079 | $item = $this->get_active_settings( $item, $control['fields'] ); |
| @@ -1301,13 +1140,11 @@ | ||
| 1301 | 1140 | if ( null === $controls ) { |
| 1302 | 1141 | $controls = $this->get_controls(); |
| 1303 | 1142 | } |
| 1304 | 1143 | |
| 1305 | - $controls_objs = Plugin::$instance->controls_manager->get_controls(); | |
| 1306 | - | |
| 1307 | 1144 | foreach ( $controls as $control ) { |
| 1308 | 1145 | $control_name = $control['name']; |
| 1309 | - $control_obj = $controls_objs[ $control['type'] ] ?? null; | |
| 1146 | + $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] ); | |
| 1310 | 1147 | |
| 1311 | 1148 | if ( ! $control_obj instanceof Base_Data_Control ) { |
| 1312 | 1149 | continue; |
| 1313 | 1150 | } |
| @@ -1417,33 +1254,21 @@ | ||
| 1417 | 1254 | ); |
| 1418 | 1255 | } |
| 1419 | 1256 | |
| 1420 | 1257 | /** |
| 1421 | - * Get Responsive Control Device Suffix | |
| 1422 | - * | |
| 1423 | - * @deprecated 3.7.6 Use `Elementor\Controls_Manager::get_responsive_control_device_suffix()` instead. | |
| 1424 | - * @param array $control | |
| 1425 | - * @return string $device suffix | |
| 1426 | - */ | |
| 1427 | - protected function get_responsive_control_device_suffix( $control ) { | |
| 1428 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.7.6', 'Elementor\Controls_Manager::get_responsive_control_device_suffix()' ); | |
| 1429 | - | |
| 1430 | - return Controls_Manager::get_responsive_control_device_suffix( $control ); | |
| 1431 | - } | |
| 1432 | - | |
| 1433 | - /** | |
| 1434 | 1258 | * Whether the control is visible or not. |
| 1435 | 1259 | * |
| 1436 | 1260 | * Used to determine whether the control is visible or not. |
| 1437 | 1261 | * |
| 1262 | + * @since 1.4.0 | |
| 1263 | + * @access public | |
| 1264 | + * | |
| 1438 | 1265 | * @param array $control The control. |
| 1439 | - * @param null $values Optional. Condition values. Default is null. | |
| 1440 | - * @param null $controls | |
| 1266 | + * @param array $values Optional. Condition values. Default is null. | |
| 1267 | + * | |
| 1441 | 1268 | * @return bool Whether the control is visible. |
| 1442 | - * @since 1.4.0 | |
| 1443 | - * @access public | |
| 1444 | 1269 | */ |
| 1445 | - public function is_control_visible( $control, $values = null, $controls = null ) { | |
| 1270 | + public function is_control_visible( $control, $values = null ) { | |
| 1446 | 1271 | if ( null === $values ) { |
| 1447 | 1272 | $values = $this->get_settings(); |
| 1448 | 1273 | } |
| 1449 | 1274 | |
| @@ -1454,37 +1279,21 @@ | ||
| 1454 | 1279 | if ( empty( $control['condition'] ) ) { |
| 1455 | 1280 | return true; |
| 1456 | 1281 | } |
| 1457 | 1282 | |
| 1458 | - if ( ! $controls ) { | |
| 1459 | - $controls = $this->get_controls(); | |
| 1460 | - } | |
| 1461 | - | |
| 1462 | 1283 | foreach ( $control['condition'] as $condition_key => $condition_value ) { |
| 1463 | 1284 | preg_match( '/([a-z_\-0-9]+)(?:\[([a-z_]+)])?(!?)$/i', $condition_key, $condition_key_parts ); |
| 1464 | 1285 | |
| 1465 | 1286 | $pure_condition_key = $condition_key_parts[1]; |
| 1466 | 1287 | $condition_sub_key = $condition_key_parts[2]; |
| 1467 | - $is_negative_condition = (bool) $condition_key_parts[3]; | |
| 1288 | + $is_negative_condition = ! ! $condition_key_parts[3]; | |
| 1468 | 1289 | |
| 1469 | 1290 | if ( ! isset( $values[ $pure_condition_key ] ) || null === $values[ $pure_condition_key ] ) { |
| 1470 | 1291 | return false; |
| 1471 | 1292 | } |
| 1472 | 1293 | |
| 1473 | - $are_control_and_condition_responsive = isset( $control['responsive'] ) && ! empty( $controls[ $pure_condition_key ]['responsive'] ); | |
| 1474 | - $condition_name_to_check = $pure_condition_key; | |
| 1294 | + $instance_value = $values[ $pure_condition_key ]; | |
| 1475 | 1295 | |
| 1476 | - if ( $are_control_and_condition_responsive ) { | |
| 1477 | - $device_suffix = Controls_Manager::get_responsive_control_device_suffix( $control ); | |
| 1478 | - | |
| 1479 | - $condition_name_to_check = $pure_condition_key . $device_suffix; | |
| 1480 | - | |
| 1481 | - // If the control is not desktop, and a conditioning control for the corresponding device exists, use it. | |
| 1482 | - $instance_value = $values[ $pure_condition_key . $device_suffix ] ?? $values[ $pure_condition_key ]; | |
| 1483 | - } else { | |
| 1484 | - $instance_value = $values[ $pure_condition_key ]; | |
| 1485 | - } | |
| 1486 | - | |
| 1487 | 1296 | if ( $condition_sub_key && is_array( $instance_value ) ) { |
| 1488 | 1297 | if ( ! isset( $instance_value[ $condition_sub_key ] ) ) { |
| 1489 | 1298 | return false; |
| 1490 | 1299 | } |
| @@ -1491,32 +1300,8 @@ | ||
| 1491 | 1300 | |
| 1492 | 1301 | $instance_value = $instance_value[ $condition_sub_key ]; |
| 1493 | 1302 | } |
| 1494 | 1303 | |
| 1495 | - if ( ! $instance_value ) { | |
| 1496 | - $parent = isset( $controls[ $condition_name_to_check ]['parent'] ) ? $controls[ $condition_name_to_check ]['parent'] : false; | |
| 1497 | - | |
| 1498 | - while ( $parent ) { | |
| 1499 | - $instance_value = $values[ $parent ]; | |
| 1500 | - | |
| 1501 | - if ( $instance_value ) { | |
| 1502 | - if ( ! is_array( $instance_value ) ) { | |
| 1503 | - break; | |
| 1504 | - } | |
| 1505 | - | |
| 1506 | - if ( $condition_sub_key && isset( $instance_value[ $condition_sub_key ] ) ) { | |
| 1507 | - $instance_value = $instance_value[ $condition_sub_key ]; | |
| 1508 | - | |
| 1509 | - if ( '' !== $instance_value ) { | |
| 1510 | - break; | |
| 1511 | - } | |
| 1512 | - } | |
| 1513 | - } | |
| 1514 | - | |
| 1515 | - $parent = isset( $controls[ $parent ]['parent'] ) ? $controls[ $parent ]['parent'] : false; | |
| 1516 | - } | |
| 1517 | - } | |
| 1518 | - | |
| 1519 | 1304 | /** |
| 1520 | 1305 | * If the $condition_value is a non empty array - check if the $condition_value contains the $instance_value, |
| 1521 | 1306 | * If the $instance_value is a non empty array - check if the $instance_value contains the $condition_value |
| 1522 | 1307 | * otherwise check if they are equal. ( and give the ability to check if the value is an empty array ) |
| @@ -1528,12 +1313,9 @@ | ||
| 1528 | 1313 | } else { |
| 1529 | 1314 | $is_contains = $instance_value === $condition_value; |
| 1530 | 1315 | } |
| 1531 | 1316 | |
| 1532 | - if ( | |
| 1533 | - ( $is_negative_condition && $is_contains ) || | |
| 1534 | - ( ! $is_negative_condition && ! $is_contains ) | |
| 1535 | - ) { | |
| 1317 | + if ( $is_negative_condition && $is_contains || ! $is_negative_condition && ! $is_contains ) { | |
| 1536 | 1318 | return false; |
| 1537 | 1319 | } |
| 1538 | 1320 | } |
| 1539 | 1321 | |
| @@ -1546,9 +1328,9 @@ | ||
| 1546 | 1328 | * Used to add a new section of controls. When you use this method, all the |
| 1547 | 1329 | * registered controls from this point will be assigned to this section, |
| 1548 | 1330 | * until you close the section using `end_controls_section()` method. |
| 1549 | 1331 | * |
| 1550 | - * This method should be used inside `register_controls()`. | |
| 1332 | + * This method should be used inside `_register_controls()`. | |
| 1551 | 1333 | * |
| 1552 | 1334 | * @since 1.4.0 |
| 1553 | 1335 | * @access public |
| 1554 | 1336 | * |
| @@ -1555,9 +1337,9 @@ | ||
| 1555 | 1337 | * @param string $section_id Section ID. |
| 1556 | 1338 | * @param array $args Section arguments Optional. |
| 1557 | 1339 | */ |
| 1558 | 1340 | public function start_controls_section( $section_id, array $args = [] ) { |
| 1559 | - $stack_name = $this->get_name(); | |
| 1341 | + $section_name = $this->get_name(); | |
| 1560 | 1342 | |
| 1561 | 1343 | /** |
| 1562 | 1344 | * Before section start. |
| 1563 | 1345 | * |
| @@ -1575,9 +1357,9 @@ | ||
| 1575 | 1357 | * Before section start. |
| 1576 | 1358 | * |
| 1577 | 1359 | * Fires before Elementor section starts in the editor panel. |
| 1578 | 1360 | * |
| 1579 | - * The dynamic portions of the hook name, `$stack_name` and `$section_id`, refers to the stack name and section ID, respectively. | |
| 1361 | + * The dynamic portions of the hook name, `$section_name` and `$section_id`, refers to the section name and section ID, respectively. | |
| 1580 | 1362 | * |
| 1581 | 1363 | * @since 1.4.0 |
| 1582 | 1364 | * |
| 1583 | 1365 | * @param Controls_Stack $this The control. |
| @@ -1582,20 +1364,16 @@ | ||
| 1582 | 1364 | * |
| 1583 | 1365 | * @param Controls_Stack $this The control. |
| 1584 | 1366 | * @param array $args Section arguments. |
| 1585 | 1367 | */ |
| 1586 | - do_action( "elementor/element/{$stack_name}/{$section_id}/before_section_start", $this, $args ); | |
| 1368 | + do_action( "elementor/element/{$section_name}/{$section_id}/before_section_start", $this, $args ); | |
| 1587 | 1369 | |
| 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 | 1370 | $args['type'] = Controls_Manager::SECTION; |
| 1593 | 1371 | |
| 1594 | 1372 | $this->add_control( $section_id, $args ); |
| 1595 | 1373 | |
| 1596 | 1374 | if ( null !== $this->current_section ) { |
| 1597 | - wp_die( sprintf( 'Elementor: You can\'t start a section before the end of the previous section "%s".', $this->current_section['section'] ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1375 | + wp_die( sprintf( 'Elementor: You can\'t start a section before the end of the previous section "%s".', $this->current_section['section'] ) ); // XSS ok. | |
| 1598 | 1376 | } |
| 1599 | 1377 | |
| 1600 | 1378 | $this->current_section = $this->get_section_args( $section_id ); |
| 1601 | 1379 | |
| @@ -1620,9 +1398,9 @@ | ||
| 1620 | 1398 | * After section start. |
| 1621 | 1399 | * |
| 1622 | 1400 | * Fires after Elementor section starts in the editor panel. |
| 1623 | 1401 | * |
| 1624 | - * The dynamic portions of the hook name, `$stack_name` and `$section_id`, refers to the stack name and section ID, respectively. | |
| 1402 | + * The dynamic portions of the hook name, `$section_name` and `$section_id`, refers to the section name and section ID, respectively. | |
| 1625 | 1403 | * |
| 1626 | 1404 | * @since 1.4.0 |
| 1627 | 1405 | * |
| 1628 | 1406 | * @param Controls_Stack $this The control. |
| @@ -1627,13 +1405,9 @@ | ||
| 1627 | 1405 | * |
| 1628 | 1406 | * @param Controls_Stack $this The control. |
| 1629 | 1407 | * @param array $args Section arguments. |
| 1630 | 1408 | */ |
| 1631 | - 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 | - } | |
| 1409 | + do_action( "elementor/element/{$section_name}/{$section_id}/after_section_start", $this, $args ); | |
| 1636 | 1410 | } |
| 1637 | 1411 | |
| 1638 | 1412 | /** |
| 1639 | 1413 | * End controls section. |
| @@ -1640,9 +1414,9 @@ | ||
| 1640 | 1414 | * |
| 1641 | 1415 | * Used to close an existing open controls section. When you use this method |
| 1642 | 1416 | * it stops adding new controls to this section. |
| 1643 | 1417 | * |
| 1644 | - * This method should be used inside `register_controls()`. | |
| 1418 | + * This method should be used inside `_register_controls()`. | |
| 1645 | 1419 | * |
| 1646 | 1420 | * @since 1.4.0 |
| 1647 | 1421 | * @access public |
| 1648 | 1422 | */ |
| @@ -1682,12 +1456,8 @@ | ||
| 1682 | 1456 | * @param array $args Section arguments. |
| 1683 | 1457 | */ |
| 1684 | 1458 | do_action( "elementor/element/{$stack_name}/{$section_id}/before_section_end", $this, $args ); |
| 1685 | 1459 | |
| 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 | 1460 | $this->current_section = null; |
| 1691 | 1461 | |
| 1692 | 1462 | /** |
| 1693 | 1463 | * After section end. |
| @@ -1706,9 +1476,9 @@ | ||
| 1706 | 1476 | * After section end. |
| 1707 | 1477 | * |
| 1708 | 1478 | * Fires after Elementor section ends in the editor panel. |
| 1709 | 1479 | * |
| 1710 | - * The dynamic portions of the hook name, `$stack_name` and `$section_id`, refers to the stack name and section ID, respectively. | |
| 1480 | + * The dynamic portions of the hook name, `$stack_name` and `$section_id`, refers to the section name and section ID, respectively. | |
| 1711 | 1481 | * |
| 1712 | 1482 | * @since 1.4.0 |
| 1713 | 1483 | * |
| 1714 | 1484 | * @param Controls_Stack $this The control. |
| @@ -1714,40 +1484,11 @@ | ||
| 1714 | 1484 | * @param Controls_Stack $this The control. |
| 1715 | 1485 | * @param array $args Section arguments. |
| 1716 | 1486 | */ |
| 1717 | 1487 | 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 | 1488 | } |
| 1723 | 1489 | |
| 1724 | 1490 | /** |
| 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 | 1491 | * Start controls tabs. |
| 1751 | 1492 | * |
| 1752 | 1493 | * Used to add a new set of tabs inside a section. You should use this |
| 1753 | 1494 | * method before adding new individual tabs using `start_controls_tab()`. |
| @@ -1753,9 +1494,9 @@ | ||
| 1753 | 1494 | * method before adding new individual tabs using `start_controls_tab()`. |
| 1754 | 1495 | * Each tab added after this point will be assigned to this group of tabs, |
| 1755 | 1496 | * until you close it using `end_controls_tabs()` method. |
| 1756 | 1497 | * |
| 1757 | - * This method should be used inside `register_controls()`. | |
| 1498 | + * This method should be used inside `_register_controls()`. | |
| 1758 | 1499 | * |
| 1759 | 1500 | * @since 1.4.0 |
| 1760 | 1501 | * @access public |
| 1761 | 1502 | * |
| @@ -1763,9 +1504,9 @@ | ||
| 1763 | 1504 | * @param array $args Tabs arguments. |
| 1764 | 1505 | */ |
| 1765 | 1506 | public function start_controls_tabs( $tabs_id, array $args = [] ) { |
| 1766 | 1507 | if ( null !== $this->current_tab ) { |
| 1767 | - wp_die( sprintf( 'Elementor: You can\'t start tabs before the end of the previous tabs "%s".', $this->current_tab['tabs_wrapper'] ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1508 | + wp_die( sprintf( 'Elementor: You can\'t start tabs before the end of the previous tabs "%s".', $this->current_tab['tabs_wrapper'] ) ); // XSS ok. | |
| 1768 | 1509 | } |
| 1769 | 1510 | |
| 1770 | 1511 | $args['type'] = Controls_Manager::TABS; |
| 1771 | 1512 | |
| @@ -1791,9 +1532,9 @@ | ||
| 1791 | 1532 | * |
| 1792 | 1533 | * Used to close an existing open controls tabs. When you use this method it |
| 1793 | 1534 | * stops adding new controls to this tabs. |
| 1794 | 1535 | * |
| 1795 | - * This method should be used inside `register_controls()`. | |
| 1536 | + * This method should be used inside `_register_controls()`. | |
| 1796 | 1537 | * |
| 1797 | 1538 | * @since 1.4.0 |
| 1798 | 1539 | * @access public |
| 1799 | 1540 | */ |
| @@ -1808,9 +1549,9 @@ | ||
| 1808 | 1549 | * adding new individual tabs using `start_controls_tab()`. |
| 1809 | 1550 | * Each tab added after this point will be assigned to this group of tabs, |
| 1810 | 1551 | * until you close it using `end_controls_tab()` method. |
| 1811 | 1552 | * |
| 1812 | - * This method should be used inside `register_controls()`. | |
| 1553 | + * This method should be used inside `_register_controls()`. | |
| 1813 | 1554 | * |
| 1814 | 1555 | * @since 1.4.0 |
| 1815 | 1556 | * @access public |
| 1816 | 1557 | * |
| @@ -1818,9 +1559,9 @@ | ||
| 1818 | 1559 | * @param array $args Tab arguments. |
| 1819 | 1560 | */ |
| 1820 | 1561 | public function start_controls_tab( $tab_id, $args ) { |
| 1821 | 1562 | if ( ! empty( $this->current_tab['inner_tab'] ) ) { |
| 1822 | - wp_die( sprintf( 'Elementor: You can\'t start a tab before the end of the previous tab "%s".', $this->current_tab['inner_tab'] ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1563 | + wp_die( sprintf( 'Elementor: You can\'t start a tab before the end of the previous tab "%s".', $this->current_tab['inner_tab'] ) ); // XSS ok. | |
| 1823 | 1564 | } |
| 1824 | 1565 | |
| 1825 | 1566 | $args['type'] = Controls_Manager::TAB; |
| 1826 | 1567 | $args['tabs_wrapper'] = $this->current_tab['tabs_wrapper']; |
| @@ -1839,9 +1580,9 @@ | ||
| 1839 | 1580 | * |
| 1840 | 1581 | * Used to close an existing open controls tab. When you use this method it |
| 1841 | 1582 | * stops adding new controls to this tab. |
| 1842 | 1583 | * |
| 1843 | - * This method should be used inside `register_controls()`. | |
| 1584 | + * This method should be used inside `_register_controls()`. | |
| 1844 | 1585 | * |
| 1845 | 1586 | * @since 1.4.0 |
| 1846 | 1587 | * @access public |
| 1847 | 1588 | */ |
| @@ -1855,9 +1596,9 @@ | ||
| 1855 | 1596 | * Used to add a new set of controls in a popover. When you use this method, |
| 1856 | 1597 | * all the registered controls from this point will be assigned to this |
| 1857 | 1598 | * popover, until you close the popover using `end_popover()` method. |
| 1858 | 1599 | * |
| 1859 | - * This method should be used inside `register_controls()`. | |
| 1600 | + * This method should be used inside `_register_controls()`. | |
| 1860 | 1601 | * |
| 1861 | 1602 | * @since 1.9.0 |
| 1862 | 1603 | * @access public |
| 1863 | 1604 | */ |
| @@ -1872,9 +1613,9 @@ | ||
| 1872 | 1613 | * |
| 1873 | 1614 | * Used to close an existing open popover. When you use this method it stops |
| 1874 | 1615 | * adding new controls to this popover. |
| 1875 | 1616 | * |
| 1876 | - * This method should be used inside `register_controls()`. | |
| 1617 | + * This method should be used inside `_register_controls()`. | |
| 1877 | 1618 | * |
| 1878 | 1619 | * @since 1.9.0 |
| 1879 | 1620 | * @access public |
| 1880 | 1621 | */ |
| @@ -1896,196 +1637,8 @@ | ||
| 1896 | 1637 | $this->update_control( $last_control_key, $args, $options ); |
| 1897 | 1638 | } |
| 1898 | 1639 | |
| 1899 | 1640 | /** |
| 1900 | - * Add render attribute. | |
| 1901 | - * | |
| 1902 | - * Used to add attributes to a specific HTML element. | |
| 1903 | - * | |
| 1904 | - * The HTML tag is represented by the element parameter, then you need to | |
| 1905 | - * define the attribute key and the attribute key. The final result will be: | |
| 1906 | - * `<element attribute_key="attribute_value">`. | |
| 1907 | - * | |
| 1908 | - * Example usage: | |
| 1909 | - * | |
| 1910 | - * `$this->add_render_attribute( 'wrapper', 'class', 'custom-widget-wrapper-class' );` | |
| 1911 | - * `$this->add_render_attribute( 'widget', 'id', 'custom-widget-id' );` | |
| 1912 | - * `$this->add_render_attribute( 'button', [ 'class' => 'custom-button-class', 'id' => 'custom-button-id' ] );` | |
| 1913 | - * | |
| 1914 | - * @since 1.0.0 | |
| 1915 | - * @access public | |
| 1916 | - * | |
| 1917 | - * @param array|string $element The HTML element. | |
| 1918 | - * @param array|string $key Optional. Attribute key. Default is null. | |
| 1919 | - * @param array|string $value Optional. Attribute value. Default is null. | |
| 1920 | - * @param bool $overwrite Optional. Whether to overwrite existing | |
| 1921 | - * attribute. Default is false, not to overwrite. | |
| 1922 | - * | |
| 1923 | - * @return self Current instance of the element. | |
| 1924 | - */ | |
| 1925 | - public function add_render_attribute( $element, $key = null, $value = null, $overwrite = false ) { | |
| 1926 | - if ( is_array( $element ) ) { | |
| 1927 | - foreach ( $element as $element_key => $attributes ) { | |
| 1928 | - $this->add_render_attribute( $element_key, $attributes, null, $overwrite ); | |
| 1929 | - } | |
| 1930 | - | |
| 1931 | - return $this; | |
| 1932 | - } | |
| 1933 | - | |
| 1934 | - if ( is_array( $key ) ) { | |
| 1935 | - foreach ( $key as $attribute_key => $attributes ) { | |
| 1936 | - $this->add_render_attribute( $element, $attribute_key, $attributes, $overwrite ); | |
| 1937 | - } | |
| 1938 | - | |
| 1939 | - return $this; | |
| 1940 | - } | |
| 1941 | - | |
| 1942 | - if ( empty( $this->render_attributes[ $element ][ $key ] ) ) { | |
| 1943 | - $this->render_attributes[ $element ][ $key ] = []; | |
| 1944 | - } | |
| 1945 | - | |
| 1946 | - settype( $value, 'array' ); | |
| 1947 | - | |
| 1948 | - if ( $overwrite ) { | |
| 1949 | - $this->render_attributes[ $element ][ $key ] = $value; | |
| 1950 | - } else { | |
| 1951 | - $this->render_attributes[ $element ][ $key ] = array_merge( $this->render_attributes[ $element ][ $key ], $value ); | |
| 1952 | - } | |
| 1953 | - | |
| 1954 | - return $this; | |
| 1955 | - } | |
| 1956 | - | |
| 1957 | - /** | |
| 1958 | - * Get Render Attributes | |
| 1959 | - * | |
| 1960 | - * Used to retrieve render attribute. | |
| 1961 | - * | |
| 1962 | - * The returned array is either all elements and their attributes if no `$element` is specified, an array of all | |
| 1963 | - * attributes of a specific element or a specific attribute properties if `$key` is specified. | |
| 1964 | - * | |
| 1965 | - * Returns null if one of the requested parameters isn't set. | |
| 1966 | - * | |
| 1967 | - * @since 2.2.6 | |
| 1968 | - * @access public | |
| 1969 | - * @param string $element | |
| 1970 | - * @param string $key | |
| 1971 | - * | |
| 1972 | - * @return array | |
| 1973 | - */ | |
| 1974 | - public function get_render_attributes( $element = '', $key = '' ) { | |
| 1975 | - $attributes = $this->render_attributes; | |
| 1976 | - | |
| 1977 | - if ( $element ) { | |
| 1978 | - if ( ! isset( $attributes[ $element ] ) ) { | |
| 1979 | - return null; | |
| 1980 | - } | |
| 1981 | - | |
| 1982 | - $attributes = $attributes[ $element ]; | |
| 1983 | - | |
| 1984 | - if ( $key ) { | |
| 1985 | - if ( ! isset( $attributes[ $key ] ) ) { | |
| 1986 | - return null; | |
| 1987 | - } | |
| 1988 | - | |
| 1989 | - $attributes = $attributes[ $key ]; | |
| 1990 | - } | |
| 1991 | - } | |
| 1992 | - | |
| 1993 | - return $attributes; | |
| 1994 | - } | |
| 1995 | - | |
| 1996 | - /** | |
| 1997 | - * Set render attribute. | |
| 1998 | - * | |
| 1999 | - * Used to set the value of the HTML element render attribute or to update | |
| 2000 | - * an existing render attribute. | |
| 2001 | - * | |
| 2002 | - * @since 1.0.0 | |
| 2003 | - * @access public | |
| 2004 | - * | |
| 2005 | - * @param array|string $element The HTML element. | |
| 2006 | - * @param array|string $key Optional. Attribute key. Default is null. | |
| 2007 | - * @param array|string $value Optional. Attribute value. Default is null. | |
| 2008 | - * | |
| 2009 | - * @return self Current instance of the element. | |
| 2010 | - */ | |
| 2011 | - public function set_render_attribute( $element, $key = null, $value = null ) { | |
| 2012 | - return $this->add_render_attribute( $element, $key, $value, true ); | |
| 2013 | - } | |
| 2014 | - | |
| 2015 | - /** | |
| 2016 | - * Remove render attribute. | |
| 2017 | - * | |
| 2018 | - * Used to remove an element (with its keys and their values), key (with its values), | |
| 2019 | - * or value/s from an HTML element's render attribute. | |
| 2020 | - * | |
| 2021 | - * @since 2.7.0 | |
| 2022 | - * @access public | |
| 2023 | - * | |
| 2024 | - * @param string $element The HTML element. | |
| 2025 | - * @param string $key Optional. Attribute key. Default is null. | |
| 2026 | - * @param array|string $values Optional. Attribute value/s. Default is null. | |
| 2027 | - */ | |
| 2028 | - public function remove_render_attribute( $element, $key = null, $values = null ) { | |
| 2029 | - if ( $key && ! isset( $this->render_attributes[ $element ][ $key ] ) ) { | |
| 2030 | - return; | |
| 2031 | - } | |
| 2032 | - | |
| 2033 | - if ( $values ) { | |
| 2034 | - $values = (array) $values; | |
| 2035 | - | |
| 2036 | - $this->render_attributes[ $element ][ $key ] = array_diff( $this->render_attributes[ $element ][ $key ], $values ); | |
| 2037 | - | |
| 2038 | - return; | |
| 2039 | - } | |
| 2040 | - | |
| 2041 | - if ( $key ) { | |
| 2042 | - unset( $this->render_attributes[ $element ][ $key ] ); | |
| 2043 | - | |
| 2044 | - return; | |
| 2045 | - } | |
| 2046 | - | |
| 2047 | - if ( isset( $this->render_attributes[ $element ] ) ) { | |
| 2048 | - unset( $this->render_attributes[ $element ] ); | |
| 2049 | - } | |
| 2050 | - } | |
| 2051 | - | |
| 2052 | - /** | |
| 2053 | - * Get render attribute string. | |
| 2054 | - * | |
| 2055 | - * Used to retrieve the value of the render attribute. | |
| 2056 | - * | |
| 2057 | - * @since 1.0.0 | |
| 2058 | - * @access public | |
| 2059 | - * | |
| 2060 | - * @param string $element The element. | |
| 2061 | - * | |
| 2062 | - * @return string Render attribute string, or an empty string if the attribute | |
| 2063 | - * is empty or not exist. | |
| 2064 | - */ | |
| 2065 | - public function get_render_attribute_string( $element ) { | |
| 2066 | - if ( empty( $this->render_attributes[ $element ] ) ) { | |
| 2067 | - return ''; | |
| 2068 | - } | |
| 2069 | - | |
| 2070 | - return Utils::render_html_attributes( $this->render_attributes[ $element ] ); | |
| 2071 | - } | |
| 2072 | - | |
| 2073 | - /** | |
| 2074 | - * Print render attribute string. | |
| 2075 | - * | |
| 2076 | - * Used to output the rendered attribute. | |
| 2077 | - * | |
| 2078 | - * @since 2.0.0 | |
| 2079 | - * @access public | |
| 2080 | - * | |
| 2081 | - * @param array|string $element The element. | |
| 2082 | - */ | |
| 2083 | - public function print_render_attribute_string( $element ) { | |
| 2084 | - Utils::print_unescaped_internal_string( $this->get_render_attribute_string( $element ) ); | |
| 2085 | - } | |
| 2086 | - | |
| 2087 | - /** | |
| 2088 | 1641 | * Print element template. |
| 2089 | 1642 | * |
| 2090 | 1643 | * Used to generate the element template on the editor. |
| 2091 | 1644 | * |
| @@ -2095,12 +1648,10 @@ | ||
| 2095 | 1648 | public function print_template() { |
| 2096 | 1649 | ob_start(); |
| 2097 | 1650 | |
| 2098 | 1651 | // TODO: This is for backwards compatibility starting from 2.9.0 |
| 2099 | - // This `if` statement should be removed when the method is removed. | |
| 2100 | - if ( $this->has_own_method( '_content_template', self::class ) ) { | |
| 2101 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_content_template', '2.9.0', __CLASS__ . '::content_template()' ); | |
| 2102 | - | |
| 1652 | + // This `if` statement should be removed when the method is removed | |
| 1653 | + if ( method_exists( $this, '_content_template' ) ) { | |
| 2103 | 1654 | $this->_content_template(); |
| 2104 | 1655 | } else { |
| 2105 | 1656 | $this->content_template(); |
| 2106 | 1657 | } |
| @@ -2133,23 +1684,8 @@ | ||
| 2133 | 1684 | <?php |
| 2134 | 1685 | } |
| 2135 | 1686 | |
| 2136 | 1687 | /** |
| 2137 | - * On import update dynamic content (e.g. post and term IDs). | |
| 2138 | - * | |
| 2139 | - * @since 3.8.0 | |
| 2140 | - * | |
| 2141 | - * @param array $config The config of the passed element. | |
| 2142 | - * @param array $data The data that requires updating/replacement when imported. | |
| 2143 | - * @param array|null $controls The available controls. | |
| 2144 | - * | |
| 2145 | - * @return array Element data. | |
| 2146 | - */ | |
| 2147 | - public static function on_import_update_dynamic_content( array $config, array $data, $controls = null ): array { | |
| 2148 | - return $config; | |
| 2149 | - } | |
| 2150 | - | |
| 2151 | - /** | |
| 2152 | 1688 | * Start injection. |
| 2153 | 1689 | * |
| 2154 | 1690 | * Used to inject controls and sections to a specific position in the stack. |
| 2155 | 1691 | * |
| @@ -2224,33 +1760,12 @@ | ||
| 2224 | 1760 | * `start_controls_tab()`. |
| 2225 | 1761 | * |
| 2226 | 1762 | * @since 1.4.0 |
| 2227 | 1763 | * @access protected |
| 2228 | - * @deprecated 3.1.0 Use `register_controls()` method instead. | |
| 2229 | 1764 | */ |
| 2230 | - protected function _register_controls() { | |
| 2231 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '3.1.0', 'register_controls()' ); | |
| 1765 | + protected function _register_controls() {} | |
| 2232 | 1766 | |
| 2233 | - $this->register_controls(); | |
| 2234 | - } | |
| 2235 | - | |
| 2236 | 1767 | /** |
| 2237 | - * Register controls. | |
| 2238 | - * | |
| 2239 | - * Used to add new controls to any element type. For example, external | |
| 2240 | - * developers use this method to register controls in a widget. | |
| 2241 | - * | |
| 2242 | - * Should be inherited and register new controls using `add_control()`, | |
| 2243 | - * `add_responsive_control()` and `add_group_control()`, inside control | |
| 2244 | - * wrappers like `start_controls_section()`, `start_controls_tabs()` and | |
| 2245 | - * `start_controls_tab()`. | |
| 2246 | - * | |
| 2247 | - * @since 3.1.0 | |
| 2248 | - * @access protected | |
| 2249 | - */ | |
| 2250 | - protected function register_controls() {} | |
| 2251 | - | |
| 2252 | - /** | |
| 2253 | 1768 | * Get default data. |
| 2254 | 1769 | * |
| 2255 | 1770 | * Retrieve the default data. Used to reset the data on initialization. |
| 2256 | 1771 | * |
| @@ -2272,12 +1787,10 @@ | ||
| 2272 | 1787 | */ |
| 2273 | 1788 | protected function get_init_settings() { |
| 2274 | 1789 | $settings = $this->get_data( 'settings' ); |
| 2275 | 1790 | |
| 2276 | - $controls_objs = Plugin::$instance->controls_manager->get_controls(); | |
| 2277 | - | |
| 2278 | 1791 | foreach ( $this->get_controls() as $control ) { |
| 2279 | - $control_obj = $controls_objs[ $control['type'] ] ?? null; | |
| 1792 | + $control_obj = Plugin::$instance->controls_manager->get_control( $control['type'] ); | |
| 2280 | 1793 | |
| 2281 | 1794 | if ( ! $control_obj instanceof Base_Data_Control ) { |
| 2282 | 1795 | continue; |
| 2283 | 1796 | } |
| @@ -2313,15 +1826,15 @@ | ||
| 2313 | 1826 | * Retrieve the current element initial configuration - controls list and |
| 2314 | 1827 | * the tabs assigned to the control. |
| 2315 | 1828 | * |
| 2316 | 1829 | * @since 1.4.0 |
| 2317 | - * @deprecated 2.9.0 Use `get_initial_config()` method instead. | |
| 1830 | + * @deprecated 2.9.0 use `get_initial_config()` instead | |
| 2318 | 1831 | * @access protected |
| 2319 | 1832 | * |
| 2320 | 1833 | * @return array The initial config. |
| 2321 | 1834 | */ |
| 2322 | 1835 | protected function _get_initial_config() { |
| 2323 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', 'get_initial_config()' ); | |
| 1836 | + // _deprecated_function( __METHOD__, '2.9.0', 'get_initial_config' ); | |
| 2324 | 1837 | |
| 2325 | 1838 | return $this->get_initial_config(); |
| 2326 | 1839 | } |
| 2327 | 1840 | |
| @@ -2359,30 +1872,8 @@ | ||
| 2359 | 1872 | */ |
| 2360 | 1873 | protected function render() {} |
| 2361 | 1874 | |
| 2362 | 1875 | /** |
| 2363 | - * Render element in static mode. | |
| 2364 | - * | |
| 2365 | - * If not inherent will call the base render. | |
| 2366 | - */ | |
| 2367 | - protected function render_static() { | |
| 2368 | - $this->render(); | |
| 2369 | - } | |
| 2370 | - | |
| 2371 | - /** | |
| 2372 | - * Determine the render logic. | |
| 2373 | - */ | |
| 2374 | - protected function render_by_mode() { | |
| 2375 | - if ( Plugin::$instance->frontend->is_static_render_mode() ) { | |
| 2376 | - $this->render_static(); | |
| 2377 | - | |
| 2378 | - return; | |
| 2379 | - } | |
| 2380 | - | |
| 2381 | - $this->render(); | |
| 2382 | - } | |
| 2383 | - | |
| 2384 | - /** | |
| 2385 | 1876 | * Print content template. |
| 2386 | 1877 | * |
| 2387 | 1878 | * Used to generate the content template on the editor, using a |
| 2388 | 1879 | * Backbone JavaScript template. |
| @@ -2392,9 +1883,9 @@ | ||
| 2392 | 1883 | * |
| 2393 | 1884 | * @param string $template_content Template content. |
| 2394 | 1885 | */ |
| 2395 | 1886 | protected function print_template_content( $template_content ) { |
| 2396 | - Utils::print_unescaped_internal_string( $template_content ); | |
| 1887 | + echo $template_content; | |
| 2397 | 1888 | } |
| 2398 | 1889 | |
| 2399 | 1890 | /** |
| 2400 | 1891 | * Render element output in the editor. |
| @@ -2411,13 +1902,13 @@ | ||
| 2411 | 1902 | * |
| 2412 | 1903 | * Used to generate the live preview, using a Backbone JavaScript template. |
| 2413 | 1904 | * |
| 2414 | 1905 | * @since 2.0.0 |
| 2415 | - * @deprecated 2.9.0 Use `content_template()` method instead. | |
| 1906 | + * @deprecated 2.9.0 use `content_template()` instead | |
| 2416 | 1907 | * @access protected |
| 2417 | 1908 | */ |
| 2418 | 1909 | protected function _content_template() { |
| 2419 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', 'content_template()' ); | |
| 1910 | + // _deprecated_function( __METHOD__, '2.9.0', 'content_template' ); | |
| 2420 | 1911 | |
| 2421 | 1912 | $this->content_template(); |
| 2422 | 1913 | } |
| 2423 | 1914 | |
| @@ -2423,9 +1914,9 @@ | ||
| 2423 | 1914 | |
| 2424 | 1915 | /** |
| 2425 | 1916 | * Initialize controls. |
| 2426 | 1917 | * |
| 2427 | - * Register the all controls added by `register_controls()`. | |
| 1918 | + * Register the all controls added by `_register_controls()`. | |
| 2428 | 1919 | * |
| 2429 | 1920 | * @since 2.0.0 |
| 2430 | 1921 | * @access protected |
| 2431 | 1922 | */ |
| @@ -2432,12 +1923,10 @@ | ||
| 2432 | 1923 | protected function init_controls() { |
| 2433 | 1924 | Plugin::$instance->controls_manager->open_stack( $this ); |
| 2434 | 1925 | |
| 2435 | 1926 | // TODO: This is for backwards compatibility starting from 2.9.0 |
| 2436 | - // This `if` statement should be removed when the method is removed. | |
| 2437 | - if ( $this->has_own_method( '_register_controls', self::class ) ) { | |
| 2438 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_register_controls', '3.1.0', __CLASS__ . '::register_controls()' ); | |
| 2439 | - | |
| 1927 | + // This `if` statement should be removed when the method is removed | |
| 1928 | + if ( method_exists( $this, '_register_controls' ) ) { | |
| 2440 | 1929 | $this->_register_controls(); |
| 2441 | 1930 | } else { |
| 2442 | 1931 | $this->register_controls(); |
| 2443 | 1932 | } |
| @@ -2461,9 +1950,9 @@ | ||
| 2461 | 1950 | } |
| 2462 | 1951 | |
| 2463 | 1952 | if ( null !== $target_section_args ) { |
| 2464 | 1953 | if ( ! empty( $args['section'] ) || ! empty( $args['tab'] ) ) { |
| 2465 | - _doing_it_wrong( sprintf( '%s::%s', get_called_class(), __FUNCTION__ ), sprintf( 'Cannot redeclare control with `tab` or `section` args inside section "%s".', $control_id ), '1.0.0' ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 1954 | + _doing_it_wrong( sprintf( '%s::%s', get_called_class(), __FUNCTION__ ), sprintf( 'Cannot redeclare control with `tab` or `section` args inside section "%s".', $control_id ), '1.0.0' ); | |
| 2466 | 1955 | } |
| 2467 | 1956 | |
| 2468 | 1957 | $args = array_replace_recursive( $target_section_args, $args ); |
| 2469 | 1958 | |
| @@ -2470,11 +1959,9 @@ | ||
| 2470 | 1959 | if ( null !== $target_tab ) { |
| 2471 | 1960 | $args = array_replace_recursive( $target_tab, $args ); |
| 2472 | 1961 | } |
| 2473 | 1962 | } 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 | - } | |
| 1963 | + wp_die( sprintf( '%s::%s: Cannot add a control outside of a section (use `start_controls_section`).', get_called_class(), __FUNCTION__ ) ); | |
| 2477 | 1964 | } |
| 2478 | 1965 | |
| 2479 | 1966 | return $args; |
| 2480 | 1967 | } |
| @@ -2500,15 +1987,15 @@ | ||
| 2500 | 1987 | * |
| 2501 | 1988 | * Set the raw data, the ID and the parsed settings. |
| 2502 | 1989 | * |
| 2503 | 1990 | * @since 1.4.0 |
| 2504 | - * @deprecated 2.9.0 Use `init()` method instead. | |
| 1991 | + * @deprecated 2.9.0 use `init()` instead | |
| 2505 | 1992 | * @access protected |
| 2506 | 1993 | * |
| 2507 | 1994 | * @param array $data Initial data. |
| 2508 | 1995 | */ |
| 2509 | 1996 | protected function _init( $data ) { |
| 2510 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( __METHOD__, '2.9.0', 'init()' ); | |
| 1997 | + // _deprecated_function( __METHOD__, '2.9.0', 'init' ); | |
| 2511 | 1998 | |
| 2512 | 1999 | $this->init( $data ); |
| 2513 | 2000 | } |
| 2514 | 2001 | |
| @@ -2579,12 +2066,10 @@ | ||
| 2579 | 2066 | */ |
| 2580 | 2067 | public function __construct( array $data = [] ) { |
| 2581 | 2068 | if ( $data ) { |
| 2582 | 2069 | // TODO: This is for backwards compatibility starting from 2.9.0 |
| 2583 | - // This if statement should be removed when the method is hard-deprecated. | |
| 2584 | - if ( $this->has_own_method( '_init', self::class ) ) { | |
| 2585 | - Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( '_init', '2.9.0', __CLASS__ . '::init()' ); | |
| 2586 | - | |
| 2070 | + // This if statement should be removed when the method is hard-deprecated | |
| 2071 | + if ( method_exists( $this, '_init' ) ) { | |
| 2587 | 2072 | $this->_init( $data ); |
| 2588 | 2073 | } else { |
| 2589 | 2074 | $this->init( $data ); |
| 2590 | 2075 | } |