PluginProbe
Elementor Website Builder – more than just a page builder / 3.20.0-dev2
Elementor Website Builder – more than just a page builder v3.20.0-dev2
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | includes/managers/controls.php +30 -90 4.1.0-dev23.20.0-dev2 View file →
@@ -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
@@ -425,9 +418,8 @@
425 418 self::MEDIA,
426 419 self::SLIDER,
427 420 self::DIMENSIONS,
428 421 self::CHOOSE,
429 - self::VISUAL_CHOICE,
430 422 self::WYSIWYG,
431 423 self::CODE,
432 424 self::FONT,
433 425 self::IMAGE_DIMENSIONS,
@@ -494,14 +486,14 @@
494 486 *
495 487 * @param Controls_Manager $this The controls manager.
496 488 */
497 489 // 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 - // );
490 + //Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->do_deprecated_action(
491 + // 'elementor/controls/controls_registered',
492 + // [ $this ],
493 + // '3.5.0',
494 + // 'elementor/controls/register'
495 + //);
504 496
505 497 do_action( 'elementor/controls/controls_registered', $this );
506 498
507 499 /**
@@ -531,13 +523,13 @@
531 523 * current instance.
532 524 */
533 525 public function register_control( $control_id, Base_Control $control_instance ) {
534 526 // 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 - // );
527 + //Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_function(
528 + // __METHOD__,
529 + // '3.5.0',
530 + // 'register()'
531 + //);
540 532
541 533 $this->register( $control_instance, $control_id );
542 534 }
543 535
@@ -765,9 +757,8 @@
765 757
766 758 $this->stacks[ $stack_id ] = [
767 759 'tabs' => [],
768 760 'controls' => [],
769 - 'style_controls' => [],
770 761 'responsive_control_duplication_mode' => Plugin::$instance->breakpoints->get_responsive_control_duplication_mode(),
771 762 ];
772 763 }
773 764
@@ -806,13 +797,8 @@
806 797 'overwrite' => false,
807 798 'index' => null,
808 799 ];
809 800
810 - $control_type = 'controls';
811 - if ( Performance::should_optimize_controls() && $this->is_style_control( $control_data ) ) {
812 - $control_type = 'style_controls';
813 - }
814 -
815 801 $options = array_merge( $default_options, $options );
816 802
817 803 $default_args = [
818 804 'type' => self::TEXT,
@@ -829,17 +815,8 @@
829 815 _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 816 return false;
831 817 }
832 818
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 819 if ( $control_type_instance instanceof Base_Data_Control ) {
843 820 $control_default_value = $control_type_instance->get_default_value();
844 821
845 822 if ( is_array( $control_default_value ) ) {
@@ -850,9 +827,9 @@
850 827 }
851 828
852 829 $stack_id = $element->get_unique_name();
853 830
854 - if ( ! $options['overwrite'] && isset( $this->stacks[ $stack_id ][ $control_type ][ $control_id ] ) ) {
831 + if ( ! $options['overwrite'] && isset( $this->stacks[ $stack_id ]['controls'][ $control_id ] ) ) {
855 832 _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 833
857 834 return false;
858 835 }
@@ -864,18 +841,18 @@
864 841 }
865 842
866 843 $this->stacks[ $stack_id ]['tabs'][ $control_data['tab'] ] = $tabs[ $control_data['tab'] ];
867 844
868 - $this->stacks[ $stack_id ][ $control_type ][ $control_id ] = $control_data;
845 + $this->stacks[ $stack_id ]['controls'][ $control_id ] = $control_data;
869 846
870 847 if ( null !== $options['index'] ) {
871 - $controls = $this->stacks[ $stack_id ][ $control_type ];
848 + $controls = $this->stacks[ $stack_id ]['controls'];
872 849
873 850 $controls_keys = array_keys( $controls );
874 851
875 852 array_splice( $controls_keys, $options['index'], 0, $control_id );
876 853
877 - $this->stacks[ $stack_id ][ $control_type ] = array_merge( array_flip( $controls_keys ), $controls );
854 + $this->stacks[ $stack_id ]['controls'] = array_merge( array_flip( $controls_keys ), $controls );
878 855 }
879 856
880 857 return true;
881 858 }
@@ -887,9 +864,9 @@
887 864 *
888 865 * @since 1.0.0
889 866 * @access public
890 867 *
891 - * @param string $stack_id Stack ID.
868 + * @param string $stack_id Stack ID.
892 869 * @param array|string $control_id The ID of the control to remove.
893 870 *
894 871 * @return bool|\WP_Error True if the stack was removed, False otherwise.
895 872 */
@@ -912,9 +889,8 @@
912 889 }
913 890
914 891 /**
915 892 * Has Stacks Cache Been Cleared.
916 - *
917 893 * @since 3.13.0
918 894 * @access public
919 895 * @return bool True if the CSS requires to clear the controls stack cache, False otherwise.
920 896 */
@@ -924,9 +900,8 @@
924 900
925 901 /**
926 902 * Clear stack.
927 903 * This method clears the stack.
928 - *
929 904 * @since 3.13.0
930 905 * @access public
931 906 */
932 907 public function clear_stack_cache() {
@@ -951,19 +926,13 @@
951 926 *
952 927 * @return array|\WP_Error The control, or an error.
953 928 */
954 929 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 ];
930 + if ( empty( $this->stacks[ $stack_id ]['controls'][ $control_id ] ) ) {
931 + return new \WP_Error( 'Cannot get a not-exists control.' );
959 932 }
960 933
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.' );
934 + return $this->stacks[ $stack_id ]['controls'][ $control_id ];
966 935 }
967 936
968 937 /**
969 938 * Update control in stack.
@@ -1064,10 +1033,11 @@
1064 1033 * @since 1.0.0
1065 1034 * @access public
1066 1035 *
1067 1036 * @param Controls_Stack $controls_stack .
1068 - * @param string $tab
1069 - * @param array $additional_messages
1037 + * @param string $tab
1038 + * @param array $additional_messages
1039 + *
1070 1040 */
1071 1041 public function add_custom_css_controls( Controls_Stack $controls_stack, $tab = self::TAB_ADVANCED, $additional_messages = [] ) {
1072 1042 $controls_stack->start_controls_section(
1073 1043 'section_custom_css_pro',
@@ -1107,10 +1077,10 @@
1107 1077 * version of elementor uses this method to display an upgrade message to
1108 1078 * Elementor Pro.
1109 1079 *
1110 1080 * @param Controls_Stack $controls_stack .
1111 - * @param string $tab
1112 - * @param array $additional_messages
1081 + * @param string $tab
1082 + * @param array $additional_messages
1113 1083 *
1114 1084 * @return void
1115 1085 */
1116 1086 public function add_page_transitions_controls( Controls_Stack $controls_stack, $tab = self::TAB_ADVANCED, $additional_messages = [] ) {
@@ -1191,19 +1161,19 @@
1191 1161 * This method adds a new control for the "Custom Attributes" feature. The free
1192 1162 * version of elementor uses this method to display an upgrade message to
1193 1163 * Elementor Pro.
1194 1164 *
1195 - * @param Controls_Stack $controls_stack .
1196 - * @param string $tab
1197 1165 * @since 2.8.3
1198 1166 * @access public
1167 + *
1168 + * @param Controls_Stack $controls_stack.
1199 1169 */
1200 - public function add_custom_attributes_controls( Controls_Stack $controls_stack, string $tab = self::TAB_ADVANCED ) {
1170 + public function add_custom_attributes_controls( Controls_Stack $controls_stack ) {
1201 1171 $controls_stack->start_controls_section(
1202 1172 'section_custom_attributes_pro',
1203 1173 [
1204 1174 'label' => esc_html__( 'Attributes', 'elementor' ),
1205 - 'tab' => $tab,
1175 + 'tab' => self::TAB_ADVANCED,
1206 1176 ]
1207 1177 );
1208 1178
1209 1179 $controls_stack->add_control(
@@ -1225,9 +1195,9 @@
1225 1195
1226 1196 /**
1227 1197 * Check if a stack should be cleaned by the current responsive control duplication mode.
1228 1198 *
1229 - * @param array $stack
1199 + * @param $stack
1230 1200 * @return bool
1231 1201 */
1232 1202 private function should_clean_stack( $stack ): bool {
1233 1203 if ( ! isset( $stack['responsive_control_duplication_mode'] ) ) {
@@ -1360,41 +1330,11 @@
1360 1330 <span class="e-control-motion-effects-promotion__lock-wrapper">
1361 1331 <i class="eicon-lock"></i>
1362 1332 </span>
1363 1333 <div class="elementor-control-input-wrapper elementor-control-unit-5 e-control-' . $id . '-promotion">
1364 - <div class="select-promotion elementor-control-unit-5">' . esc_html__( 'None', 'elementor' ) . '</div>
1334 + <div class="select-promotion elementor-control-unit-5">None</div>
1365 1335 </div>
1366 1336 </div>
1367 1337 </div>
1368 1338 </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 1339 }
1400 1340 }