| @@ -9,8 +9,9 @@ | ||
| 9 | 9 | use Elementor\Core\Files\CSS\Post as Post_CSS; |
| 10 | 10 | use Elementor\Core\Files\CSS\Post_Preview; |
| 11 | 11 | use Elementor\Core\Responsive\Responsive; |
| 12 | 12 | use Elementor\Core\Settings\Manager as SettingsManager; |
| 13 | +use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager; | |
| 13 | 14 | |
| 14 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 15 | 16 | exit; // Exit if accessed directly. |
| 16 | 17 | } |
| @@ -219,9 +220,11 @@ | ||
| 219 | 220 | } |
| 220 | 221 | |
| 221 | 222 | $this->post_id = get_the_ID(); |
| 222 | 223 | |
| 223 | - if ( is_singular() && Plugin::$instance->db->is_built_with_elementor( $this->post_id ) ) { | |
| 224 | + $document = Plugin::$instance->documents->get( $this->post_id ); | |
| 225 | + | |
| 226 | + if ( is_singular() && $document && $document->is_built_with_elementor() ) { | |
| 224 | 227 | add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_styles' ] ); |
| 225 | 228 | } |
| 226 | 229 | |
| 227 | 230 | // Priority 7 to allow google fonts in header template to load in <head> tag |
| @@ -279,9 +282,11 @@ | ||
| 279 | 282 | $classes = array_merge( $classes, $this->body_classes ); |
| 280 | 283 | |
| 281 | 284 | $id = get_the_ID(); |
| 282 | 285 | |
| 283 | - if ( is_singular() && Plugin::$instance->db->is_built_with_elementor( $id ) ) { | |
| 286 | + $document = Plugin::$instance->documents->get( $id ); | |
| 287 | + | |
| 288 | + if ( is_singular() && $document && $document->is_built_with_elementor() ) { | |
| 284 | 289 | $classes[] = 'elementor-page elementor-page-' . $id; |
| 285 | 290 | } |
| 286 | 291 | |
| 287 | 292 | return $classes; |
| @@ -512,12 +517,12 @@ | ||
| 512 | 517 | $direction_suffix = is_rtl() ? '-rtl' : ''; |
| 513 | 518 | |
| 514 | 519 | $frontend_file_name = 'frontend' . $direction_suffix . $min_suffix . '.css'; |
| 515 | 520 | |
| 516 | - $has_custom_file = Responsive::has_custom_breakpoints(); | |
| 521 | + $has_custom_file = Plugin::$instance->breakpoints->has_custom_breakpoints(); | |
| 517 | 522 | |
| 518 | 523 | if ( $has_custom_file ) { |
| 519 | - $frontend_file = new FrontendFile( 'custom-' . $frontend_file_name, Responsive::get_stylesheet_templates_path() . $frontend_file_name ); | |
| 524 | + $frontend_file = new FrontendFile( 'custom-' . $frontend_file_name, Breakpoints_Manager::get_stylesheet_templates_path() . $frontend_file_name ); | |
| 520 | 525 | |
| 521 | 526 | $time = $frontend_file->get_meta( 'time' ); |
| 522 | 527 | |
| 523 | 528 | if ( ! $time ) { |
| @@ -581,10 +586,10 @@ | ||
| 581 | 586 | wp_enqueue_script( 'elementor-frontend' ); |
| 582 | 587 | |
| 583 | 588 | if ( ! $this->is_improved_assets_loading() ) { |
| 584 | 589 | wp_enqueue_script( |
| 585 | - 'preloaded-elements-handlers', | |
| 586 | - $this->get_js_assets_url( 'preloaded-elements-handlers', 'assets/js/' ), | |
| 590 | + 'preloaded-modules', | |
| 591 | + $this->get_js_assets_url( 'preloaded-modules', 'assets/js/' ), | |
| 587 | 592 | [ |
| 588 | 593 | 'elementor-frontend', |
| 589 | 594 | ], |
| 590 | 595 | ELEMENTOR_VERSION, |
| @@ -623,9 +628,12 @@ | ||
| 623 | 628 | * @since 1.0.0 |
| 624 | 629 | */ |
| 625 | 630 | do_action( 'elementor/frontend/before_enqueue_styles' ); |
| 626 | 631 | |
| 627 | - wp_enqueue_style( 'elementor-icons' ); | |
| 632 | + // The e-icons are needed in preview mode for the editor icons (plus-icon for new section, folder-icon for the templates library etc.). | |
| 633 | + if ( ! $this->is_improved_assets_loading() || Plugin::$instance->preview->is_preview_mode() ) { | |
| 634 | + wp_enqueue_style( 'elementor-icons' ); | |
| 635 | + } | |
| 628 | 636 | wp_enqueue_style( 'elementor-animations' ); |
| 629 | 637 | wp_enqueue_style( 'elementor-frontend' ); |
| 630 | 638 | |
| 631 | 639 | /** |
| @@ -792,10 +800,13 @@ | ||
| 792 | 800 | foreach ( $google_fonts['google'] as &$font ) { |
| 793 | 801 | $font = str_replace( ' ', '+', $font ) . ':100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic'; |
| 794 | 802 | } |
| 795 | 803 | |
| 796 | - $fonts_url = sprintf( 'https://fonts.googleapis.com/css?family=%s', implode( rawurlencode( '|' ), $google_fonts['google'] ) ); | |
| 804 | + // Defining a font-display type to google fonts. | |
| 805 | + $font_display_url_str = '&display=' . Fonts::get_font_display_setting(); | |
| 797 | 806 | |
| 807 | + $fonts_url = sprintf( 'https://fonts.googleapis.com/css?family=%1$s%2$s', implode( rawurlencode( '|' ), $google_fonts['google'] ), $font_display_url_str ); | |
| 808 | + | |
| 798 | 809 | $subsets = [ |
| 799 | 810 | 'ru_RU' => 'cyrillic', |
| 800 | 811 | 'bg_BG' => 'cyrillic', |
| 801 | 812 | 'he_IL' => 'hebrew', |
| @@ -926,14 +937,14 @@ | ||
| 926 | 937 | if ( post_password_required( $post_id ) ) { |
| 927 | 938 | return ''; |
| 928 | 939 | } |
| 929 | 940 | |
| 930 | - if ( ! Plugin::$instance->db->is_built_with_elementor( $post_id ) ) { | |
| 941 | + $document = Plugin::$instance->documents->get_doc_for_frontend( $post_id ); | |
| 942 | + | |
| 943 | + if ( ! $document || ! $document->is_built_with_elementor() ) { | |
| 931 | 944 | return ''; |
| 932 | 945 | } |
| 933 | 946 | |
| 934 | - $document = Plugin::$instance->documents->get_doc_for_frontend( $post_id ); | |
| 935 | - | |
| 936 | 947 | // Change the current post, so widgets can use `documents->get_current`. |
| 937 | 948 | Plugin::$instance->documents->switch_to_document( $document ); |
| 938 | 949 | |
| 939 | 950 | $data = $document->get_elements_data(); |
| @@ -1168,9 +1179,8 @@ | ||
| 1168 | 1179 | 'environmentMode' => [ |
| 1169 | 1180 | 'edit' => $is_preview_mode, |
| 1170 | 1181 | 'wpPreview' => is_preview(), |
| 1171 | 1182 | 'isScriptDebug' => Utils::is_script_debug(), |
| 1172 | - 'isImprovedAssetsLoading' => $this->is_improved_assets_loading(), | |
| 1173 | 1183 | ], |
| 1174 | 1184 | 'i18n' => [ |
| 1175 | 1185 | 'shareOnFacebook' => __( 'Share on Facebook', 'elementor' ), |
| 1176 | 1186 | 'shareOnTwitter' => __( 'Share on Twitter', 'elementor' ), |
| @@ -1185,9 +1195,14 @@ | ||
| 1185 | 1195 | 'next' => __( 'Next', 'elementor' ), |
| 1186 | 1196 | 'close' => __( 'Close', 'elementor' ), |
| 1187 | 1197 | ], |
| 1188 | 1198 | 'is_rtl' => is_rtl(), |
| 1199 | + // 'breakpoints' object is kept for BC. | |
| 1189 | 1200 | 'breakpoints' => Responsive::get_breakpoints(), |
| 1201 | + // 'responsive' contains the custom breakpoints config introduced in Elementor v3.2.0 | |
| 1202 | + 'responsive' => [ | |
| 1203 | + 'breakpoints' => $this->get_breakpoints_config(), | |
| 1204 | + ], | |
| 1190 | 1205 | 'version' => ELEMENTOR_VERSION, |
| 1191 | 1206 | 'is_static' => $this->is_static_render_mode(), |
| 1192 | 1207 | 'experimentalFeatures' => $active_experimental_features, |
| 1193 | 1208 | 'urls' => [ |
| @@ -1251,8 +1266,25 @@ | ||
| 1251 | 1266 | |
| 1252 | 1267 | return $settings; |
| 1253 | 1268 | } |
| 1254 | 1269 | |
| 1270 | + private function get_breakpoints_config() { | |
| 1271 | + $breakpoints = Plugin::$instance->breakpoints->get_breakpoints(); | |
| 1272 | + | |
| 1273 | + $config = []; | |
| 1274 | + | |
| 1275 | + foreach ( $breakpoints as $breakpoint_name => $breakpoint ) { | |
| 1276 | + $config[ $breakpoint_name ] = [ | |
| 1277 | + 'label' => $breakpoint->get_label(), | |
| 1278 | + 'value' => $breakpoint->get_value(), | |
| 1279 | + 'direction' => $breakpoint->get_direction(), | |
| 1280 | + 'is_enabled' => $breakpoint->is_enabled(), | |
| 1281 | + ]; | |
| 1282 | + } | |
| 1283 | + | |
| 1284 | + return $config; | |
| 1285 | + } | |
| 1286 | + | |
| 1255 | 1287 | /** |
| 1256 | 1288 | * Restore content filters. |
| 1257 | 1289 | * |
| 1258 | 1290 | * Restore removed WordPress filters that conflicted with Elementor. |
| @@ -1319,11 +1351,10 @@ | ||
| 1319 | 1351 | |
| 1320 | 1352 | private function get_elementor_frontend_dependencies() { |
| 1321 | 1353 | $dependencies = [ |
| 1322 | 1354 | 'elementor-frontend-modules', |
| 1323 | - 'elementor-dialog', | |
| 1324 | 1355 | 'elementor-waypoints', |
| 1325 | - 'share-link', | |
| 1356 | + 'jquery-ui-position', | |
| 1326 | 1357 | ]; |
| 1327 | 1358 | |
| 1328 | 1359 | if ( ! $this->is_improved_assets_loading() ) { |
| 1329 | 1360 | wp_register_script( |
| @@ -1334,8 +1365,10 @@ | ||
| 1334 | 1365 | true |
| 1335 | 1366 | ); |
| 1336 | 1367 | |
| 1337 | 1368 | $dependencies[] = 'swiper'; |
| 1369 | + $dependencies[] = 'share-link'; | |
| 1370 | + $dependencies[] = 'elementor-dialog'; | |
| 1338 | 1371 | } |
| 1339 | 1372 | |
| 1340 | 1373 | return $dependencies; |
| 1341 | 1374 | } |