| @@ -3,9 +3,8 @@ | ||
| 3 | 3 | |
| 4 | 4 | use Elementor\Core\Base\Module; |
| 5 | 5 | use Elementor\Core\Kits\Documents\Tabs\Settings_Layout; |
| 6 | 6 | use Elementor\Core\Responsive\Files\Frontend; |
| 7 | -use Elementor\Modules\DevTools\Deprecation; | |
| 8 | 7 | use Elementor\Plugin; |
| 9 | 8 | |
| 10 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 11 | 10 | exit; // Exit if accessed directly. |
| @@ -18,9 +17,8 @@ | ||
| 18 | 17 | const BREAKPOINT_KEY_MOBILE_EXTRA = 'mobile_extra'; |
| 19 | 18 | const BREAKPOINT_KEY_TABLET = 'tablet'; |
| 20 | 19 | const BREAKPOINT_KEY_TABLET_EXTRA = 'tablet_extra'; |
| 21 | 20 | const BREAKPOINT_KEY_LAPTOP = 'laptop'; |
| 22 | - const BREAKPOINT_KEY_DESKTOP = 'desktop'; | |
| 23 | 21 | const BREAKPOINT_KEY_WIDESCREEN = 'widescreen'; |
| 24 | 22 | |
| 25 | 23 | /** |
| 26 | 24 | * Breakpoints |
| @@ -67,20 +65,8 @@ | ||
| 67 | 65 | private $responsive_control_duplication_mode = 'off'; |
| 68 | 66 | |
| 69 | 67 | private $icons_map; |
| 70 | 68 | |
| 71 | - /** | |
| 72 | - * Has Custom Breakpoints | |
| 73 | - * | |
| 74 | - * A flag that holds a cached value that indicates if there are active custom-breakpoints. | |
| 75 | - * | |
| 76 | - * @since 3.5.0 | |
| 77 | - * @access private | |
| 78 | - * | |
| 79 | - * @var boolean | |
| 80 | - */ | |
| 81 | - private $has_custom_breakpoints; | |
| 82 | - | |
| 83 | 69 | public function get_name() { |
| 84 | 70 | return 'breakpoints'; |
| 85 | 71 | } |
| 86 | 72 | |
| @@ -119,53 +105,12 @@ | ||
| 119 | 105 | |
| 120 | 106 | return self::get_items( $this->active_breakpoints, $breakpoint_name ); |
| 121 | 107 | } |
| 122 | 108 | |
| 123 | - /** | |
| 124 | - * Get Active Devices List | |
| 125 | - * | |
| 126 | - * Retrieve an array containing the keys of all active devices, including 'desktop'. | |
| 127 | - * | |
| 128 | - * @since 3.2.0 | |
| 129 | - * | |
| 130 | - * @param array $args | |
| 131 | - * @return array | |
| 132 | - */ | |
| 133 | - public function get_active_devices_list( $args = [] ) { | |
| 134 | - $default_args = [ | |
| 135 | - 'add_desktop' => true, | |
| 136 | - 'reverse' => false, | |
| 137 | - 'desktop_first' => false, | |
| 138 | - ]; | |
| 139 | - | |
| 140 | - $args = array_merge( $default_args, $args ); | |
| 141 | - | |
| 142 | - $active_devices = array_keys( Plugin::$instance->breakpoints->get_active_breakpoints() ); | |
| 143 | - | |
| 144 | - if ( $args['add_desktop'] ) { | |
| 145 | - // Insert the 'desktop' device in the correct position. | |
| 146 | - if ( ! $args['desktop_first'] && in_array( 'widescreen', $active_devices, true ) ) { | |
| 147 | - $widescreen_index = array_search( 'widescreen', $active_devices, true ); | |
| 148 | - | |
| 149 | - array_splice( $active_devices, $widescreen_index, 0, [ 'desktop' ] ); | |
| 150 | - } else { | |
| 151 | - $active_devices[] = 'desktop'; | |
| 152 | - } | |
| 153 | - } | |
| 154 | - | |
| 155 | - if ( $args['reverse'] ) { | |
| 156 | - $active_devices = array_reverse( $active_devices ); | |
| 157 | - } | |
| 158 | - | |
| 159 | - return $active_devices; | |
| 160 | - } | |
| 161 | - | |
| 162 | 109 | /** Has Custom Breakpoints |
| 163 | 110 | * |
| 164 | 111 | * Checks whether there are currently custom breakpoints saved in the database. |
| 165 | 112 | * Returns true if there are breakpoint values saved in the active kit. |
| 166 | - * If the user has activated any additional custom breakpoints (mobile extra, tablet extra, laptop, widescreen) - | |
| 167 | - * that is considered as having custom breakpoints. | |
| 168 | 113 | * |
| 169 | 114 | * @since 3.2.0 |
| 170 | 115 | * |
| 171 | 116 | * @return boolean |
| @@ -170,38 +115,17 @@ | ||
| 170 | 115 | * |
| 171 | 116 | * @return boolean |
| 172 | 117 | */ |
| 173 | 118 | public function has_custom_breakpoints() { |
| 174 | - if ( isset( $this->has_custom_breakpoints ) ) { | |
| 175 | - return $this->has_custom_breakpoints; | |
| 176 | - } | |
| 119 | + $breakpoints = $this->get_breakpoints(); | |
| 177 | 120 | |
| 178 | - $breakpoints = $this->get_active_breakpoints(); | |
| 179 | - | |
| 180 | - $additional_breakpoints = [ | |
| 181 | - self::BREAKPOINT_KEY_MOBILE_EXTRA, | |
| 182 | - self::BREAKPOINT_KEY_TABLET_EXTRA, | |
| 183 | - self::BREAKPOINT_KEY_LAPTOP, | |
| 184 | - self::BREAKPOINT_KEY_WIDESCREEN, | |
| 185 | - ]; | |
| 186 | - | |
| 187 | - foreach ( $breakpoints as $breakpoint_name => $breakpoint ) { | |
| 188 | - if ( in_array( $breakpoint_name, $additional_breakpoints, true ) ) { | |
| 189 | - $this->has_custom_breakpoints = true; | |
| 190 | - | |
| 191 | - return true; | |
| 192 | - } | |
| 193 | - | |
| 121 | + foreach ( $breakpoints as $breakpoint ) { | |
| 194 | 122 | /** @var Breakpoint $breakpoint */ |
| 195 | 123 | if ( $breakpoint->is_custom() ) { |
| 196 | - $this->has_custom_breakpoints = true; | |
| 197 | - | |
| 198 | 124 | return true; |
| 199 | 125 | } |
| 200 | 126 | } |
| 201 | 127 | |
| 202 | - $this->has_custom_breakpoints = false; | |
| 203 | - | |
| 204 | 128 | return false; |
| 205 | 129 | } |
| 206 | 130 | |
| 207 | 131 | /** |
| @@ -264,10 +188,8 @@ | ||
| 264 | 188 | return $active_breakpoints[ $desktop_previous_device ]->get_value() + 1; |
| 265 | 189 | } |
| 266 | 190 | |
| 267 | 191 | public function refresh() { |
| 268 | - unset( $this->has_custom_breakpoints ); | |
| 269 | - | |
| 270 | 192 | $this->init_breakpoints(); |
| 271 | 193 | $this->init_active_breakpoints(); |
| 272 | 194 | } |
| 273 | 195 | |
| @@ -310,24 +232,24 @@ | ||
| 310 | 232 | */ |
| 311 | 233 | public static function get_default_config() { |
| 312 | 234 | return [ |
| 313 | 235 | self::BREAKPOINT_KEY_MOBILE => [ |
| 314 | - 'label' => esc_html__( 'Mobile Portrait', 'elementor' ), | |
| 236 | + 'label' => esc_html__( 'Mobile', 'elementor' ), | |
| 315 | 237 | 'default_value' => 767, |
| 316 | 238 | 'direction' => 'max', |
| 317 | 239 | ], |
| 318 | 240 | self::BREAKPOINT_KEY_MOBILE_EXTRA => [ |
| 319 | - 'label' => esc_html__( 'Mobile Landscape', 'elementor' ), | |
| 241 | + 'label' => esc_html__( 'Mobile Extra', 'elementor' ), | |
| 320 | 242 | 'default_value' => 880, |
| 321 | 243 | 'direction' => 'max', |
| 322 | 244 | ], |
| 323 | 245 | self::BREAKPOINT_KEY_TABLET => [ |
| 324 | - 'label' => esc_html__( 'Tablet Portrait', 'elementor' ), | |
| 246 | + 'label' => esc_html__( 'Tablet', 'elementor' ), | |
| 325 | 247 | 'default_value' => 1024, |
| 326 | 248 | 'direction' => 'max', |
| 327 | 249 | ], |
| 328 | 250 | self::BREAKPOINT_KEY_TABLET_EXTRA => [ |
| 329 | - 'label' => esc_html__( 'Tablet Landscape', 'elementor' ), | |
| 251 | + 'label' => esc_html__( 'Tablet Extra', 'elementor' ), | |
| 330 | 252 | 'default_value' => 1200, |
| 331 | 253 | 'direction' => 'max', |
| 332 | 254 | ], |
| 333 | 255 | self::BREAKPOINT_KEY_LAPTOP => [ |
| @@ -523,15 +445,12 @@ | ||
| 523 | 445 | |
| 524 | 446 | $deprecated_hook = 'elementor/core/responsive/get_stylesheet_templates'; |
| 525 | 447 | $replacement_hook = 'elementor/core/breakpoints/get_stylesheet_template'; |
| 526 | 448 | |
| 527 | - /** | |
| 528 | - * @type Deprecation $deprecation_module | |
| 529 | - */ | |
| 530 | - $deprecation_module = Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation; | |
| 449 | + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_hook( $deprecated_hook, '3.2.0', $replacement_hook ); | |
| 531 | 450 | |
| 532 | 451 | // TODO: REMOVE THIS DEPRECATED HOOK IN ELEMENTOR v3.10.0/v4.0.0 |
| 533 | - $templates = $deprecation_module->apply_deprecated_filter( $deprecated_hook, [ $templates ], '3.2.0', $replacement_hook ); | |
| 452 | + $templates = apply_filters( $deprecated_hook, $templates ); | |
| 534 | 453 | |
| 535 | 454 | return apply_filters( $replacement_hook, $templates ); |
| 536 | 455 | } |
| 537 | 456 | } |