| @@ -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,69 +17,13 @@ | ||
| 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 | - /** | |
| 26 | - * Breakpoints | |
| 27 | - * | |
| 28 | - * An array containing instances of the all of the system's available breakpoints. | |
| 29 | - * | |
| 30 | - * @since 3.2.0 | |
| 31 | - * @access private | |
| 32 | - * | |
| 33 | - * @var Breakpoint[] | |
| 34 | - */ | |
| 35 | 23 | private $breakpoints; |
| 36 | - | |
| 37 | - /** | |
| 38 | - * Active Breakpoints | |
| 39 | - * | |
| 40 | - * An array containing instances of the enabled breakpoints. | |
| 41 | - * | |
| 42 | - * @since 3.2.0 | |
| 43 | - * @access private | |
| 44 | - * | |
| 45 | - * @var Breakpoint[] | |
| 46 | - */ | |
| 47 | 24 | private $active_breakpoints; |
| 48 | 25 | |
| 49 | - /** | |
| 50 | - * Responsive Control Duplication Mode. | |
| 51 | - * | |
| 52 | - * Determines the current responsive control generation mode. | |
| 53 | - * Options are: | |
| 54 | - * -- 'on': Responsive controls are duplicated in `add_responsive_control()`. | |
| 55 | - * -- 'off': Responsive controls are NOT duplicated in `add_responsive_control()`. | |
| 56 | - * -- 'dynamic': Responsive controls are only duplicated if their config contains `'dynamic' => 'active' => true`. | |
| 57 | - * | |
| 58 | - * When generating Post CSS, the mode is set to 'on'. When generating Dynamic CSS, the mode is set to 'dynamic'. | |
| 59 | - * | |
| 60 | - * default value is 'off'. | |
| 61 | - * | |
| 62 | - * @since 3.4.0 | |
| 63 | - * @access private | |
| 64 | - * | |
| 65 | - * @var string | |
| 66 | - */ | |
| 67 | - private $responsive_control_duplication_mode = 'off'; | |
| 68 | - | |
| 69 | - private $icons_map; | |
| 70 | - | |
| 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 | 26 | public function get_name() { |
| 84 | 27 | return 'breakpoints'; |
| 85 | 28 | } |
| 86 | 29 | |
| @@ -119,53 +62,12 @@ | ||
| 119 | 62 | |
| 120 | 63 | return self::get_items( $this->active_breakpoints, $breakpoint_name ); |
| 121 | 64 | } |
| 122 | 65 | |
| 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 | 66 | /** Has Custom Breakpoints |
| 163 | 67 | * |
| 164 | 68 | * Checks whether there are currently custom breakpoints saved in the database. |
| 165 | 69 | * 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 | 70 | * |
| 169 | 71 | * @since 3.2.0 |
| 170 | 72 | * |
| 171 | 73 | * @return boolean |
| @@ -170,38 +72,17 @@ | ||
| 170 | 72 | * |
| 171 | 73 | * @return boolean |
| 172 | 74 | */ |
| 173 | 75 | public function has_custom_breakpoints() { |
| 174 | - if ( isset( $this->has_custom_breakpoints ) ) { | |
| 175 | - return $this->has_custom_breakpoints; | |
| 176 | - } | |
| 76 | + $breakpoints = $this->get_breakpoints(); | |
| 177 | 77 | |
| 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 | - | |
| 78 | + foreach ( $breakpoints as $breakpoint ) { | |
| 194 | 79 | /** @var Breakpoint $breakpoint */ |
| 195 | 80 | if ( $breakpoint->is_custom() ) { |
| 196 | - $this->has_custom_breakpoints = true; | |
| 197 | - | |
| 198 | 81 | return true; |
| 199 | 82 | } |
| 200 | 83 | } |
| 201 | 84 | |
| 202 | - $this->has_custom_breakpoints = false; | |
| 203 | - | |
| 204 | 85 | return false; |
| 205 | 86 | } |
| 206 | 87 | |
| 207 | 88 | /** |
| @@ -209,12 +90,11 @@ | ||
| 209 | 90 | * |
| 210 | 91 | * For a given device, return the minimum possible breakpoint. Except for the cases of mobile and widescreen |
| 211 | 92 | * devices, A device's min breakpoint is determined by the previous device's max breakpoint + 1px. |
| 212 | 93 | * |
| 213 | - * @since 3.2.0 | |
| 214 | - * | |
| 215 | 94 | * @param string $device_name |
| 216 | 95 | * @return int the min breakpoint of the passed device |
| 96 | + *@since 3.2.0 | |
| 217 | 97 | */ |
| 218 | 98 | public function get_device_min_breakpoint( $device_name ) { |
| 219 | 99 | if ( 'desktop' === $device_name ) { |
| 220 | 100 | return $this->get_desktop_min_point(); |
| @@ -247,17 +127,8 @@ | ||
| 247 | 127 | |
| 248 | 128 | return $min_breakpoint; |
| 249 | 129 | } |
| 250 | 130 | |
| 251 | - /** | |
| 252 | - * Get Desktop Min Breakpoint | |
| 253 | - * | |
| 254 | - * Returns the minimum possible breakpoint for the default (desktop) device. | |
| 255 | - * | |
| 256 | - * @since 3.2.0 | |
| 257 | - * | |
| 258 | - * @return int the min breakpoint of the passed device | |
| 259 | - */ | |
| 260 | 131 | public function get_desktop_min_point() { |
| 261 | 132 | $active_breakpoints = $this->get_active_breakpoints(); |
| 262 | 133 | $desktop_previous_device = $this->get_desktop_previous_device_key(); |
| 263 | 134 | |
| @@ -264,44 +135,13 @@ | ||
| 264 | 135 | return $active_breakpoints[ $desktop_previous_device ]->get_value() + 1; |
| 265 | 136 | } |
| 266 | 137 | |
| 267 | 138 | public function refresh() { |
| 268 | - unset( $this->has_custom_breakpoints ); | |
| 269 | - | |
| 270 | 139 | $this->init_breakpoints(); |
| 271 | 140 | $this->init_active_breakpoints(); |
| 272 | 141 | } |
| 273 | 142 | |
| 274 | 143 | /** |
| 275 | - * Get Responsive Icons Classes Map | |
| 276 | - * | |
| 277 | - * If a $device parameter is passed, this method retrieves the device's icon class list (the ones attached to the `<i>` | |
| 278 | - * element). If no parameter is passed, it returns an array of devices containing each device's icon class list. | |
| 279 | - * | |
| 280 | - * This method was created because 'mobile_extra' and 'tablet_extra' breakpoint icons need to be tilted by 90 | |
| 281 | - * degrees, and this tilt is achieved in CSS via the class `eicon-tilted`. | |
| 282 | - * | |
| 283 | - * @since 3.4.0 | |
| 284 | - * | |
| 285 | - * @return array|string | |
| 286 | - */ | |
| 287 | - public function get_responsive_icons_classes_map( $device = null ) { | |
| 288 | - if ( ! $this->icons_map ) { | |
| 289 | - $this->icons_map = [ | |
| 290 | - 'mobile' => 'eicon-device-mobile', | |
| 291 | - 'mobile_extra' => 'eicon-device-mobile eicon-tilted', | |
| 292 | - 'tablet' => 'eicon-device-tablet', | |
| 293 | - 'tablet_extra' => 'eicon-device-tablet eicon-tilted', | |
| 294 | - 'laptop' => 'eicon-device-laptop', | |
| 295 | - 'desktop' => 'eicon-device-desktop', | |
| 296 | - 'widescreen' => 'eicon-device-wide', | |
| 297 | - ]; | |
| 298 | - } | |
| 299 | - | |
| 300 | - return self::get_items( $this->icons_map, $device ); | |
| 301 | - } | |
| 302 | - | |
| 303 | - /** | |
| 304 | 144 | * Get Default Config |
| 305 | 145 | * |
| 306 | 146 | * Retrieve the default breakpoints config array. The 'selector' property is used for CSS generation (the |
| 307 | 147 | * Stylesheet::add_device() method). |
| @@ -310,34 +150,34 @@ | ||
| 310 | 150 | */ |
| 311 | 151 | public static function get_default_config() { |
| 312 | 152 | return [ |
| 313 | 153 | self::BREAKPOINT_KEY_MOBILE => [ |
| 314 | - 'label' => esc_html__( 'Mobile Portrait', 'elementor' ), | |
| 154 | + 'label' => __( 'Mobile', 'elementor' ), | |
| 315 | 155 | 'default_value' => 767, |
| 316 | 156 | 'direction' => 'max', |
| 317 | 157 | ], |
| 318 | 158 | self::BREAKPOINT_KEY_MOBILE_EXTRA => [ |
| 319 | - 'label' => esc_html__( 'Mobile Landscape', 'elementor' ), | |
| 159 | + 'label' => __( 'Mobile Extra', 'elementor' ), | |
| 320 | 160 | 'default_value' => 880, |
| 321 | 161 | 'direction' => 'max', |
| 322 | 162 | ], |
| 323 | 163 | self::BREAKPOINT_KEY_TABLET => [ |
| 324 | - 'label' => esc_html__( 'Tablet Portrait', 'elementor' ), | |
| 164 | + 'label' => __( 'Tablet', 'elementor' ), | |
| 325 | 165 | 'default_value' => 1024, |
| 326 | 166 | 'direction' => 'max', |
| 327 | 167 | ], |
| 328 | 168 | self::BREAKPOINT_KEY_TABLET_EXTRA => [ |
| 329 | - 'label' => esc_html__( 'Tablet Landscape', 'elementor' ), | |
| 330 | - 'default_value' => 1200, | |
| 169 | + 'label' => __( 'Tablet Extra', 'elementor' ), | |
| 170 | + 'default_value' => 1365, | |
| 331 | 171 | 'direction' => 'max', |
| 332 | 172 | ], |
| 333 | 173 | self::BREAKPOINT_KEY_LAPTOP => [ |
| 334 | - 'label' => esc_html__( 'Laptop', 'elementor' ), | |
| 335 | - 'default_value' => 1366, | |
| 174 | + 'label' => __( 'Laptop', 'elementor' ), | |
| 175 | + 'default_value' => 1620, | |
| 336 | 176 | 'direction' => 'max', |
| 337 | 177 | ], |
| 338 | 178 | self::BREAKPOINT_KEY_WIDESCREEN => [ |
| 339 | - 'label' => esc_html__( 'Widescreen', 'elementor' ), | |
| 179 | + 'label' => __( 'Widescreen', 'elementor' ), | |
| 340 | 180 | 'default_value' => 2400, |
| 341 | 181 | 'direction' => 'min', |
| 342 | 182 | ], |
| 343 | 183 | ]; |
| @@ -343,63 +183,8 @@ | ||
| 343 | 183 | ]; |
| 344 | 184 | } |
| 345 | 185 | |
| 346 | 186 | /** |
| 347 | - * Get Breakpoints Config | |
| 348 | - * | |
| 349 | - * Iterates over an array of all of the system's breakpoints (both active and inactive), queries each breakpoint's | |
| 350 | - * class instance, and generates an array containing data on each breakpoint: its label, current value, direction | |
| 351 | - * ('min'/'max') and whether it is enabled or not. | |
| 352 | - * | |
| 353 | - * @return array | |
| 354 | - */ | |
| 355 | - public function get_breakpoints_config() { | |
| 356 | - $breakpoints = $this->get_breakpoints(); | |
| 357 | - | |
| 358 | - $config = []; | |
| 359 | - | |
| 360 | - foreach ( $breakpoints as $breakpoint_name => $breakpoint ) { | |
| 361 | - $config[ $breakpoint_name ] = [ | |
| 362 | - 'label' => $breakpoint->get_label(), | |
| 363 | - 'value' => $breakpoint->get_value(), | |
| 364 | - 'default_value' => $breakpoint->get_default_value(), | |
| 365 | - 'direction' => $breakpoint->get_direction(), | |
| 366 | - 'is_enabled' => $breakpoint->is_enabled(), | |
| 367 | - ]; | |
| 368 | - } | |
| 369 | - | |
| 370 | - return $config; | |
| 371 | - } | |
| 372 | - | |
| 373 | - /** | |
| 374 | - * Get Responsive Control Duplication Mode | |
| 375 | - * | |
| 376 | - * Retrieve the value of the $responsive_control_duplication_mode private class variable. | |
| 377 | - * See the variable's PHPDoc for details. | |
| 378 | - * | |
| 379 | - * @since 3.4.0 | |
| 380 | - * @access public | |
| 381 | - */ | |
| 382 | - public function get_responsive_control_duplication_mode() { | |
| 383 | - return $this->responsive_control_duplication_mode; | |
| 384 | - } | |
| 385 | - | |
| 386 | - /** | |
| 387 | - * Set Responsive Control Duplication Mode | |
| 388 | - * | |
| 389 | - * Sets the value of the $responsive_control_duplication_mode private class variable. | |
| 390 | - * See the variable's PHPDoc for details. | |
| 391 | - * | |
| 392 | - * @since 3.4.0 | |
| 393 | - * | |
| 394 | - * @access public | |
| 395 | - * @param string $mode | |
| 396 | - */ | |
| 397 | - public function set_responsive_control_duplication_mode( $mode ) { | |
| 398 | - $this->responsive_control_duplication_mode = $mode; | |
| 399 | - } | |
| 400 | - | |
| 401 | - /** | |
| 402 | 187 | * Get Stylesheet Templates Path |
| 403 | 188 | * |
| 404 | 189 | * @since 3.2.0 |
| 405 | 190 | * @access public |
| @@ -433,28 +218,12 @@ | ||
| 433 | 218 | * @since 3.2.0 |
| 434 | 219 | */ |
| 435 | 220 | private function init_breakpoints() { |
| 436 | 221 | $breakpoints = []; |
| 437 | - | |
| 438 | - $setting_prefix = self::BREAKPOINT_SETTING_PREFIX; | |
| 439 | - | |
| 440 | - $active_breakpoint_keys = [ | |
| 441 | - $setting_prefix . self::BREAKPOINT_KEY_MOBILE, | |
| 442 | - $setting_prefix . self::BREAKPOINT_KEY_TABLET, | |
| 443 | - ]; | |
| 444 | - | |
| 445 | - if ( Plugin::$instance->experiments->is_feature_active( 'additional_custom_breakpoints' ) ) { | |
| 446 | - $kit_active_id = Plugin::$instance->kits_manager->get_active_id(); | |
| 447 | - // Get the breakpoint settings saved in the kit directly from the DB to avoid initializing the kit too early. | |
| 448 | - $raw_kit_settings = get_post_meta( $kit_active_id, '_elementor_page_settings', true ); | |
| 449 | - | |
| 450 | - // If there is an existing kit with an active breakpoints value saved, use it. | |
| 451 | - if ( isset( $raw_kit_settings[ Settings_Layout::ACTIVE_BREAKPOINTS_CONTROL_ID ] ) ) { | |
| 452 | - $active_breakpoint_keys = $raw_kit_settings[ Settings_Layout::ACTIVE_BREAKPOINTS_CONTROL_ID ]; | |
| 453 | - } | |
| 454 | - } | |
| 455 | - | |
| 222 | + $kit = Plugin::$instance->kits_manager->get_active_kit_for_frontend(); | |
| 223 | + $active_breakpoint_keys = $kit->get_settings( Settings_Layout::ACTIVE_BREAKPOINTS_CONTROL_ID ); | |
| 456 | 224 | $default_config = self::get_default_config(); |
| 225 | + $prefix = self::BREAKPOINT_SETTING_PREFIX; | |
| 457 | 226 | |
| 458 | 227 | foreach ( $default_config as $breakpoint_name => $breakpoint_config ) { |
| 459 | 228 | $args = [ 'name' => $breakpoint_name ] + $breakpoint_config; |
| 460 | 229 | |
| @@ -463,9 +232,9 @@ | ||
| 463 | 232 | // Make sure the default Mobile and Tablet breakpoints are always enabled. |
| 464 | 233 | $args['is_enabled'] = true; |
| 465 | 234 | } else { |
| 466 | 235 | // If the breakpoint is in the active breakpoints array, make sure it's instantiated as enabled. |
| 467 | - $args['is_enabled'] = in_array( $setting_prefix . $breakpoint_name, $active_breakpoint_keys, true ); | |
| 236 | + $args['is_enabled'] = in_array( $prefix . $breakpoint_name, $active_breakpoint_keys, true ); | |
| 468 | 237 | } |
| 469 | 238 | |
| 470 | 239 | $breakpoints[ $breakpoint_name ] = new Breakpoint( $args ); |
| 471 | 240 | } |
| @@ -523,15 +292,12 @@ | ||
| 523 | 292 | |
| 524 | 293 | $deprecated_hook = 'elementor/core/responsive/get_stylesheet_templates'; |
| 525 | 294 | $replacement_hook = 'elementor/core/breakpoints/get_stylesheet_template'; |
| 526 | 295 | |
| 527 | - /** | |
| 528 | - * @type Deprecation $deprecation_module | |
| 529 | - */ | |
| 530 | - $deprecation_module = Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation; | |
| 296 | + Plugin::$instance->modules_manager->get_modules( 'dev-tools' )->deprecation->deprecated_hook( $deprecated_hook, '3.2.0', $replacement_hook ); | |
| 531 | 297 | |
| 532 | 298 | // 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 ); | |
| 299 | + $templates = apply_filters( $deprecated_hook, $templates ); | |
| 534 | 300 | |
| 535 | 301 | return apply_filters( $replacement_hook, $templates ); |
| 536 | 302 | } |
| 537 | 303 | } |