| @@ -1,9 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor; |
| 3 | 3 | |
| 4 | -use Elementor\Core\Frontend\Performance; | |
| 5 | - | |
| 6 | 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | 5 | exit; // Exit if accessed directly. |
| 8 | 6 | } |
| 9 | 7 | |
| @@ -158,13 +156,8 @@ | ||
| 158 | 156 | */ |
| 159 | 157 | const CHOOSE = 'choose'; |
| 160 | 158 | |
| 161 | 159 | /** |
| 162 | - * Visual_Choice control. | |
| 163 | - */ | |
| 164 | - const VISUAL_CHOICE = 'visual_choice'; | |
| 165 | - | |
| 166 | - /** | |
| 167 | 160 | * WYSIWYG control. |
| 168 | 161 | */ |
| 169 | 162 | const WYSIWYG = 'wysiwyg'; |
| 170 | 163 | |
| @@ -309,9 +302,10 @@ | ||
| 309 | 302 | |
| 310 | 303 | /** |
| 311 | 304 | * Has stacks cache been cleared. |
| 312 | 305 | * |
| 313 | - * Boolean flag used to determine whether the controls manager stack cache has been cleared once during the current runtime. | |
| 306 | + * Boolean flag used to determine whether the controls manager stack cache has been cleared once during the current | |
| 307 | + * runtime. | |
| 314 | 308 | * |
| 315 | 309 | * @since 3.13.0 |
| 316 | 310 | * @access private |
| 317 | 311 | * @static |
| @@ -425,9 +419,8 @@ | ||
| 425 | 419 | self::MEDIA, |
| 426 | 420 | self::SLIDER, |
| 427 | 421 | self::DIMENSIONS, |
| 428 | 422 | self::CHOOSE, |
| 429 | - self::VISUAL_CHOICE, | |
| 430 | 423 | self::WYSIWYG, |
| 431 | 424 | self::CODE, |
| 432 | 425 | self::FONT, |
| 433 | 426 | self::IMAGE_DIMENSIONS, |
| @@ -494,14 +487,14 @@ | ||
| 494 | 487 | * |
| 495 | 488 | * @param Controls_Manager $this The controls manager. |
| 496 | 489 | */ |
| 497 | 490 | // TODO: Uncomment when Pro uses the new hook. |
| 498 | - // Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->do_deprecated_action( | |
| 499 | - // 'elementor/controls/controls_registered', | |
| 500 | - // [ $this ], | |
| 501 | - // '3.5.0', | |
| 502 | - // 'elementor/controls/register' | |
| 503 | - // ); | |
| 491 | + //Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->do_deprecated_action( | |
| 492 | + // 'elementor/controls/controls_registered', | |
| 493 | + // [ $this ], | |
| 494 | + // '3.5.0', | |
| 495 | + // 'elementor/controls/register' | |
| 496 | + //); | |
| 504 | 497 | |
| 505 | 498 | do_action( 'elementor/controls/controls_registered', $this ); |
| 506 | 499 | |
| 507 | 500 | /** |
| @@ -531,13 +524,13 @@ | ||
| 531 | 524 | * current instance. |
| 532 | 525 | */ |
| 533 | 526 | public function register_control( $control_id, Base_Control $control_instance ) { |
| 534 | 527 | // TODO: Uncomment when Pro uses the new hook. |
| 535 | - // Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( | |
| 536 | - // __METHOD__, | |
| 537 | - // '3.5.0', | |
| 538 | - // 'register()' | |
| 539 | - // ); | |
| 528 | + //Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function( | |
| 529 | + // __METHOD__, | |
| 530 | + // '3.5.0', | |
| 531 | + // 'register()' | |
| 532 | + //); | |
| 540 | 533 | |
| 541 | 534 | $this->register( $control_instance, $control_id ); |
| 542 | 535 | } |
| 543 | 536 | |
| @@ -765,9 +758,8 @@ | ||
| 765 | 758 | |
| 766 | 759 | $this->stacks[ $stack_id ] = [ |
| 767 | 760 | 'tabs' => [], |
| 768 | 761 | 'controls' => [], |
| 769 | - 'style_controls' => [], | |
| 770 | 762 | 'responsive_control_duplication_mode' => Plugin::$instance->breakpoints->get_responsive_control_duplication_mode(), |
| 771 | 763 | ]; |
| 772 | 764 | } |
| 773 | 765 | |
| @@ -806,13 +798,8 @@ | ||
| 806 | 798 | 'overwrite' => false, |
| 807 | 799 | 'index' => null, |
| 808 | 800 | ]; |
| 809 | 801 | |
| 810 | - $control_type = 'controls'; | |
| 811 | - if ( Performance::should_optimize_controls() && $this->is_style_control( $control_data ) ) { | |
| 812 | - $control_type = 'style_controls'; | |
| 813 | - } | |
| 814 | - | |
| 815 | 802 | $options = array_merge( $default_options, $options ); |
| 816 | 803 | |
| 817 | 804 | $default_args = [ |
| 818 | 805 | 'type' => self::TEXT, |
| @@ -829,17 +816,8 @@ | ||
| 829 | 816 | _doing_it_wrong( sprintf( '%1$s::%2$s', __CLASS__, __FUNCTION__ ), sprintf( 'Control type "%s" not found.', esc_html( $control_data['type'] ) ), '1.0.0' ); |
| 830 | 817 | return false; |
| 831 | 818 | } |
| 832 | 819 | |
| 833 | - if ( $control_type_instance instanceof Has_Validation ) { | |
| 834 | - try { | |
| 835 | - $control_type_instance->validate( $control_data ); | |
| 836 | - } catch ( \Exception $e ) { | |
| 837 | - _doing_it_wrong( sprintf( '%1$s::%2$s', __CLASS__, __FUNCTION__ ), esc_html( $e->getMessage() ), '3.23.0' ); | |
| 838 | - return false; | |
| 839 | - } | |
| 840 | - } | |
| 841 | - | |
| 842 | 820 | if ( $control_type_instance instanceof Base_Data_Control ) { |
| 843 | 821 | $control_default_value = $control_type_instance->get_default_value(); |
| 844 | 822 | |
| 845 | 823 | if ( is_array( $control_default_value ) ) { |
| @@ -850,9 +828,9 @@ | ||
| 850 | 828 | } |
| 851 | 829 | |
| 852 | 830 | $stack_id = $element->get_unique_name(); |
| 853 | 831 | |
| 854 | - if ( ! $options['overwrite'] && isset( $this->stacks[ $stack_id ][ $control_type ][ $control_id ] ) ) { | |
| 832 | + if ( ! $options['overwrite'] && isset( $this->stacks[ $stack_id ]['controls'][ $control_id ] ) ) { | |
| 855 | 833 | _doing_it_wrong( sprintf( '%1$s::%2$s', __CLASS__, __FUNCTION__ ), sprintf( 'Cannot redeclare control with same name "%s".', esc_html( $control_id ) ), '1.0.0' ); |
| 856 | 834 | |
| 857 | 835 | return false; |
| 858 | 836 | } |
| @@ -864,18 +842,18 @@ | ||
| 864 | 842 | } |
| 865 | 843 | |
| 866 | 844 | $this->stacks[ $stack_id ]['tabs'][ $control_data['tab'] ] = $tabs[ $control_data['tab'] ]; |
| 867 | 845 | |
| 868 | - $this->stacks[ $stack_id ][ $control_type ][ $control_id ] = $control_data; | |
| 846 | + $this->stacks[ $stack_id ]['controls'][ $control_id ] = $control_data; | |
| 869 | 847 | |
| 870 | 848 | if ( null !== $options['index'] ) { |
| 871 | - $controls = $this->stacks[ $stack_id ][ $control_type ]; | |
| 849 | + $controls = $this->stacks[ $stack_id ]['controls']; | |
| 872 | 850 | |
| 873 | 851 | $controls_keys = array_keys( $controls ); |
| 874 | 852 | |
| 875 | 853 | array_splice( $controls_keys, $options['index'], 0, $control_id ); |
| 876 | 854 | |
| 877 | - $this->stacks[ $stack_id ][ $control_type ] = array_merge( array_flip( $controls_keys ), $controls ); | |
| 855 | + $this->stacks[ $stack_id ]['controls'] = array_merge( array_flip( $controls_keys ), $controls ); | |
| 878 | 856 | } |
| 879 | 857 | |
| 880 | 858 | return true; |
| 881 | 859 | } |
| @@ -887,9 +865,9 @@ | ||
| 887 | 865 | * |
| 888 | 866 | * @since 1.0.0 |
| 889 | 867 | * @access public |
| 890 | 868 | * |
| 891 | - * @param string $stack_id Stack ID. | |
| 869 | + * @param string $stack_id Stack ID. | |
| 892 | 870 | * @param array|string $control_id The ID of the control to remove. |
| 893 | 871 | * |
| 894 | 872 | * @return bool|\WP_Error True if the stack was removed, False otherwise. |
| 895 | 873 | */ |
| @@ -912,9 +890,8 @@ | ||
| 912 | 890 | } |
| 913 | 891 | |
| 914 | 892 | /** |
| 915 | 893 | * Has Stacks Cache Been Cleared. |
| 916 | - * | |
| 917 | 894 | * @since 3.13.0 |
| 918 | 895 | * @access public |
| 919 | 896 | * @return bool True if the CSS requires to clear the controls stack cache, False otherwise. |
| 920 | 897 | */ |
| @@ -924,9 +901,8 @@ | ||
| 924 | 901 | |
| 925 | 902 | /** |
| 926 | 903 | * Clear stack. |
| 927 | 904 | * This method clears the stack. |
| 928 | - * | |
| 929 | 905 | * @since 3.13.0 |
| 930 | 906 | * @access public |
| 931 | 907 | */ |
| 932 | 908 | public function clear_stack_cache() { |
| @@ -951,19 +927,13 @@ | ||
| 951 | 927 | * |
| 952 | 928 | * @return array|\WP_Error The control, or an error. |
| 953 | 929 | */ |
| 954 | 930 | public function get_control_from_stack( $stack_id, $control_id ) { |
| 955 | - $stack_data = $this->get_stacks( $stack_id ); | |
| 956 | - | |
| 957 | - if ( ! empty( $stack_data['controls'][ $control_id ] ) ) { | |
| 958 | - return $stack_data['controls'][ $control_id ]; | |
| 931 | + if ( empty( $this->stacks[ $stack_id ]['controls'][ $control_id ] ) ) { | |
| 932 | + return new \WP_Error( 'Cannot get a not-exists control.' ); | |
| 959 | 933 | } |
| 960 | 934 | |
| 961 | - if ( ! empty( $stack_data['style_controls'][ $control_id ] ) ) { | |
| 962 | - return $stack_data['style_controls'][ $control_id ]; | |
| 963 | - } | |
| 964 | - | |
| 965 | - return new \WP_Error( 'Cannot get a not-exists control.' ); | |
| 935 | + return $this->stacks[ $stack_id ]['controls'][ $control_id ]; | |
| 966 | 936 | } |
| 967 | 937 | |
| 968 | 938 | /** |
| 969 | 939 | * Update control in stack. |
| @@ -1064,10 +1034,11 @@ | ||
| 1064 | 1034 | * @since 1.0.0 |
| 1065 | 1035 | * @access public |
| 1066 | 1036 | * |
| 1067 | 1037 | * @param Controls_Stack $controls_stack . |
| 1068 | - * @param string $tab | |
| 1069 | - * @param array $additional_messages | |
| 1038 | + * @param string $tab | |
| 1039 | + * @param array $additional_messages | |
| 1040 | + * | |
| 1070 | 1041 | */ |
| 1071 | 1042 | public function add_custom_css_controls( Controls_Stack $controls_stack, $tab = self::TAB_ADVANCED, $additional_messages = [] ) { |
| 1072 | 1043 | $controls_stack->start_controls_section( |
| 1073 | 1044 | 'section_custom_css_pro', |
| @@ -1107,10 +1078,10 @@ | ||
| 1107 | 1078 | * version of elementor uses this method to display an upgrade message to |
| 1108 | 1079 | * Elementor Pro. |
| 1109 | 1080 | * |
| 1110 | 1081 | * @param Controls_Stack $controls_stack . |
| 1111 | - * @param string $tab | |
| 1112 | - * @param array $additional_messages | |
| 1082 | + * @param string $tab | |
| 1083 | + * @param array $additional_messages | |
| 1113 | 1084 | * |
| 1114 | 1085 | * @return void |
| 1115 | 1086 | */ |
| 1116 | 1087 | public function add_page_transitions_controls( Controls_Stack $controls_stack, $tab = self::TAB_ADVANCED, $additional_messages = [] ) { |
| @@ -1148,9 +1119,9 @@ | ||
| 1148 | 1119 | public function get_teaser_template( $texts ) { |
| 1149 | 1120 | ob_start(); |
| 1150 | 1121 | ?> |
| 1151 | 1122 | <div class="elementor-nerd-box"> |
| 1152 | - <img class="elementor-nerd-box-icon" src="<?php echo esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ); ?>" loading="lazy" alt="<?php echo esc_attr__( 'Upgrade', 'elementor' ); ?>" /> | |
| 1123 | + <img class="elementor-nerd-box-icon" src="<?php echo esc_url( ELEMENTOR_ASSETS_URL . 'images/go-pro.svg' ); ?>" loading="lazy" /> | |
| 1153 | 1124 | <div class="elementor-nerd-box-title"><?php Utils::print_unescaped_internal_string( $texts['title'] ); ?></div> |
| 1154 | 1125 | <?php foreach ( $texts['messages'] as $message ) { ?> |
| 1155 | 1126 | <div class="elementor-nerd-box-message"><?php Utils::print_unescaped_internal_string( $message ); ?></div> |
| 1156 | 1127 | <?php } |
| @@ -1191,19 +1162,19 @@ | ||
| 1191 | 1162 | * This method adds a new control for the "Custom Attributes" feature. The free |
| 1192 | 1163 | * version of elementor uses this method to display an upgrade message to |
| 1193 | 1164 | * Elementor Pro. |
| 1194 | 1165 | * |
| 1195 | - * @param Controls_Stack $controls_stack . | |
| 1196 | - * @param string $tab | |
| 1197 | 1166 | * @since 2.8.3 |
| 1198 | 1167 | * @access public |
| 1168 | + * | |
| 1169 | + * @param Controls_Stack $controls_stack. | |
| 1199 | 1170 | */ |
| 1200 | - public function add_custom_attributes_controls( Controls_Stack $controls_stack, string $tab = self::TAB_ADVANCED ) { | |
| 1171 | + public function add_custom_attributes_controls( Controls_Stack $controls_stack ) { | |
| 1201 | 1172 | $controls_stack->start_controls_section( |
| 1202 | 1173 | 'section_custom_attributes_pro', |
| 1203 | 1174 | [ |
| 1204 | 1175 | 'label' => esc_html__( 'Attributes', 'elementor' ), |
| 1205 | - 'tab' => $tab, | |
| 1176 | + 'tab' => self::TAB_ADVANCED, | |
| 1206 | 1177 | ] |
| 1207 | 1178 | ); |
| 1208 | 1179 | |
| 1209 | 1180 | $controls_stack->add_control( |
| @@ -1225,9 +1196,9 @@ | ||
| 1225 | 1196 | |
| 1226 | 1197 | /** |
| 1227 | 1198 | * Check if a stack should be cleaned by the current responsive control duplication mode. |
| 1228 | 1199 | * |
| 1229 | - * @param array $stack | |
| 1200 | + * @param $stack | |
| 1230 | 1201 | * @return bool |
| 1231 | 1202 | */ |
| 1232 | 1203 | private function should_clean_stack( $stack ): bool { |
| 1233 | 1204 | if ( ! isset( $stack['responsive_control_duplication_mode'] ) ) { |
| @@ -1365,36 +1336,6 @@ | ||
| 1365 | 1336 | </div> |
| 1366 | 1337 | </div> |
| 1367 | 1338 | </div> |
| 1368 | 1339 | </div>'; |
| 1369 | - } | |
| 1370 | - | |
| 1371 | - private function is_style_control( $control_data ): bool { | |
| 1372 | - $frontend_available = $control_data['frontend_available'] ?? false; | |
| 1373 | - if ( $frontend_available ) { | |
| 1374 | - return false; | |
| 1375 | - } | |
| 1376 | - | |
| 1377 | - if ( ! empty( $control_data['control_type'] ) && 'content' === $control_data['control_type'] ) { | |
| 1378 | - return false; | |
| 1379 | - } | |
| 1380 | - | |
| 1381 | - if ( ! empty( $control_data['prefix_class'] ) ) { | |
| 1382 | - return false; | |
| 1383 | - } | |
| 1384 | - | |
| 1385 | - $render_type = $control_data['render_type'] ?? ''; | |
| 1386 | - if ( 'template' === $render_type ) { | |
| 1387 | - return false; | |
| 1388 | - } | |
| 1389 | - | |
| 1390 | - if ( 'ui' === $render_type ) { | |
| 1391 | - return true; | |
| 1392 | - } | |
| 1393 | - | |
| 1394 | - if ( ! empty( $control_data['selectors'] ) ) { | |
| 1395 | - return true; | |
| 1396 | - } | |
| 1397 | - | |
| 1398 | - return false; | |
| 1399 | 1340 | } |
| 1400 | 1341 | } |