| @@ -5,12 +5,11 @@ | ||
| 5 | 5 | use Elementor\Core\Breakpoints\Breakpoint; |
| 6 | 6 | use Elementor\Core\Files\Base; |
| 7 | 7 | use Elementor\Core\Responsive\Responsive; |
| 8 | 8 | use Elementor\Plugin; |
| 9 | -use Elementor\Utils; | |
| 10 | 9 | |
| 11 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | - exit; // Exit if accessed directly. | |
| 11 | + exit; // Exit if accessed directly | |
| 13 | 12 | } |
| 14 | 13 | |
| 15 | 14 | class Frontend extends Base { |
| 16 | 15 | |
| @@ -36,47 +35,35 @@ | ||
| 36 | 35 | $breakpoints = Plugin::$instance->breakpoints->get_active_breakpoints(); |
| 37 | 36 | |
| 38 | 37 | $breakpoints_keys = array_keys( $breakpoints ); |
| 39 | 38 | |
| 40 | - $file_content = Utils::file_get_contents( $this->template_file ); | |
| 39 | + $file_content = file_get_contents( $this->template_file ); | |
| 41 | 40 | |
| 42 | - // The regex pattern parses placeholders located in the frontend _templates.scss file. | |
| 43 | 41 | $file_content = preg_replace_callback( '/ELEMENTOR_SCREEN_([A-Z_]+)(?:_(MIN|MAX|NEXT))/', function ( $placeholder_data ) use ( $breakpoints_keys, $breakpoints ) { |
| 44 | 42 | // Handle BC for legacy template files and Elementor Pro builds. |
| 45 | 43 | $placeholder_data = $this->maybe_convert_placeholder_data( $placeholder_data ); |
| 46 | 44 | |
| 47 | - $breakpoint_index = array_search( strtolower( $placeholder_data[1] ), $breakpoints_keys, true ); | |
| 48 | - | |
| 49 | 45 | if ( 'DESKTOP' === $placeholder_data[1] ) { |
| 50 | - if ( 'MIN' === $placeholder_data[2] ) { | |
| 51 | - $value = Plugin::$instance->breakpoints->get_desktop_min_point(); | |
| 52 | - } elseif ( isset( $breakpoints['widescreen'] ) ) { | |
| 53 | - // If the 'widescreen' breakpoint is active, the Desktop's max value is the Widescreen breakpoint - 1px. | |
| 54 | - $value = $breakpoints['widescreen']->get_value() - 1; | |
| 55 | - } else { | |
| 56 | - // If the 'widescreen' breakpoint is not active, the Desktop device should not have a max value. | |
| 57 | - $value = 99999; | |
| 58 | - } | |
| 59 | - } elseif ( false === $breakpoint_index ) { | |
| 60 | - // If the breakpoint in the placeholder is not active - use a -1 value for the media query, to make | |
| 61 | - // sure the setting is printed (to avoid a PHP error) but doesn't apply. | |
| 62 | - return -1; | |
| 63 | - } elseif ( 'WIDESCREEN' === $placeholder_data[1] ) { | |
| 64 | - $value = $breakpoints['widescreen']->get_value(); | |
| 46 | + $value = Plugin::$instance->breakpoints->get_desktop_min_point(); | |
| 65 | 47 | } else { |
| 66 | 48 | $breakpoint_index = array_search( strtolower( $placeholder_data[1] ), $breakpoints_keys, true ); |
| 67 | 49 | |
| 68 | - $is_max_point = 'MAX' === $placeholder_data[2]; | |
| 50 | + // Handle cases where a placeholder is found for an additional breakpoint that isn't active. | |
| 51 | + if ( false === $breakpoint_index ) { | |
| 52 | + $value = -1; | |
| 53 | + } else { | |
| 54 | + $is_max_point = 'MAX' === $placeholder_data[2]; | |
| 69 | 55 | |
| 70 | - // If the placeholder capture is `MOBILE_NEXT` or `TABLET_NEXT`, the original breakpoint value is used. | |
| 71 | - if ( ! $is_max_point && 'NEXT' !== $placeholder_data[2] ) { | |
| 72 | - $breakpoint_index--; | |
| 73 | - } | |
| 56 | + // If the placeholder capture is `MOBILE_NEXT` or `TABLET_NEXT`, the original breakpoint value is used. | |
| 57 | + if ( ! $is_max_point && 'NEXT' !== $placeholder_data[2] ) { | |
| 58 | + $breakpoint_index--; | |
| 59 | + } | |
| 74 | 60 | |
| 75 | - $value = $breakpoints[ $breakpoints_keys[ $breakpoint_index ] ]->get_value(); | |
| 61 | + $value = $breakpoints[ $breakpoints_keys[ $breakpoint_index ] ]->get_value(); | |
| 76 | 62 | |
| 77 | - if ( ! $is_max_point ) { | |
| 78 | - $value++; | |
| 63 | + if ( ! $is_max_point ) { | |
| 64 | + $value++; | |
| 65 | + } | |
| 79 | 66 | } |
| 80 | 67 | } |
| 81 | 68 | |
| 82 | 69 | return $value . 'px'; |
| @@ -175,8 +162,11 @@ | ||
| 175 | 162 | * Converts responsive placeholders in Elementor CSS template files from the legacy format into the new format. |
| 176 | 163 | * Used for backwards compatibility for old Pro versions that were built with an Elementor Core version <3.2.0. |
| 177 | 164 | * |
| 178 | 165 | * @since 3.2.3 |
| 166 | + * | |
| 167 | + * @param $placeholder_data | |
| 168 | + * @return mixed | |
| 179 | 169 | */ |
| 180 | 170 | private function maybe_convert_placeholder_data( $placeholder_data ) { |
| 181 | 171 | switch ( $placeholder_data[1] ) { |
| 182 | 172 | case 'SM': |