PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / trunk
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization vtrunk
4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 2.5.5 2.5.6 2.5.7 3.0.0 3.0.1 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.11.0 3.11.1 3.11.2 3.11.3 3.12.0 All 135 releases
← All changes | inc/compatibilities/elementor_builder.php +19 -13 3.11.1 → trunk View file →
@@ -11,10 +11,10 @@
11 11 * Should we load the integration logic.
12 12 *
13 13 * @return bool Should we load.
14 14 */
15 - function should_load() {
16 - include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
15 + public function should_load() {
16 + include_once ABSPATH . 'wp-admin/includes/plugin.php';
17 17
18 18 return is_plugin_active( 'elementor/elementor.php' );
19 19 }
20 20
@@ -21,13 +21,13 @@
21 21 /**
22 22 * Register integration details.
23 23 */
24 24 public function register() {
25 - add_action( 'elementor/frontend/after_enqueue_styles', [$this, 'add_src'], PHP_INT_MIN, 1 );
25 + add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'add_src' ], PHP_INT_MIN, 1 );
26 26
27 - add_filter( 'elementor/frontend/builder_content/before_enqueue_css_file', [$this, 'add_src_filter'], PHP_INT_MIN, 1 );
27 + add_filter( 'elementor/frontend/builder_content/before_enqueue_css_file', [ $this, 'add_src_filter' ], PHP_INT_MIN, 1 );
28 28
29 - add_filter( 'elementor/frontend/builder_content/before_print_css', [$this, 'remove_src_filter'], PHP_INT_MIN, 1 );
29 + add_filter( 'elementor/frontend/builder_content/before_print_css', [ $this, 'remove_src_filter' ], PHP_INT_MIN, 1 );
30 30
31 31 add_filter(
32 32 'optml_lazyload_bg_selectors',
33 33 function ( $all_watchers ) {
@@ -32,8 +32,13 @@
32 32 'optml_lazyload_bg_selectors',
33 33 function ( $all_watchers ) {
34 34 $all_watchers[] = '.elementor-widget-container';
35 35 $all_watchers[] = '.elementor-background-slideshow__slide__image';
36 + $all_watchers[] = '.elementor-section[data-settings*="background_background"]';
37 + $all_watchers[] = '.elementor-column[data-settings*="background_background"] > .elementor-widget-wrap';
38 + $all_watchers[] = '.elementor-element[data-settings*="background_background"]';
39 + $all_watchers[] = '.elementor-section > .elementor-background-overlay';
40 +
36 41 return $all_watchers;
37 42 }
38 43 );
39 44 add_action(
@@ -45,9 +50,8 @@
45 50 }
46 51 }
47 52 }
48 53 );
49 -
50 54 }
51 55
52 56 /**
53 57 * Remove filter for the image src after the css is saved by elementor.
@@ -57,9 +61,9 @@
57 61 * @uses filter:elementor/frontend/builder_content/before_print_css
58 62 */
59 63 public function remove_src_filter( $with_css ) {
60 64
61 - remove_filter( 'wp_get_attachment_image_src', [$this, 'optimize_src'], PHP_INT_MAX );
65 + remove_filter( 'wp_get_attachment_image_src', [ $this, 'optimize_src' ], PHP_INT_MAX );
62 66
63 67 return $with_css;
64 68 }
65 69 /**
@@ -71,13 +75,13 @@
71 75 */
72 76 public function add_src_filter( $css ) {
73 77
74 78 // check if the filter was added to avoid duplication
75 - if ( has_filter( 'wp_get_attachment_image_src', [$this, 'optimize_src'] ) ) {
79 + if ( has_filter( 'wp_get_attachment_image_src', [ $this, 'optimize_src' ] ) ) {
76 80 return $css;
77 81 }
78 82
79 - add_filter( 'wp_get_attachment_image_src', [$this, 'optimize_src'], PHP_INT_MAX, 4 );
83 + add_filter( 'wp_get_attachment_image_src', [ $this, 'optimize_src' ], PHP_INT_MAX, 4 );
80 84
81 85 return $css;
82 86 }
83 87
@@ -86,10 +90,10 @@
86 90 *
87 91 * @return void
88 92 */
89 93 public function add_src() {
90 - if ( ! has_filter( 'wp_get_attachment_image_src', [$this, 'optimize_src'] ) ) {
91 - add_filter( 'wp_get_attachment_image_src', [$this, 'optimize_src'], PHP_INT_MAX, 4 );
94 + if ( ! has_filter( 'wp_get_attachment_image_src', [ $this, 'optimize_src' ] ) ) {
95 + add_filter( 'wp_get_attachment_image_src', [ $this, 'optimize_src' ], PHP_INT_MAX, 4 );
92 96 }
93 97 }
94 98
95 99 /**
@@ -106,13 +110,15 @@
106 110
107 111 if ( ! isset( $image[0] ) ) {
108 112 return $image;
109 113 }
110 -
114 + // We can't run the replacer before the setup is done, otherwise it will throw errors.
115 + if ( ! did_action( 'optml_replacer_setup' ) ) {
116 + return $image;
117 + }
111 118 $image[0] = Optml_Main::instance()->manager->url_replacer->build_url( $image[0] );
112 119
113 120 return $image;
114 -
115 121 }
116 122 /**
117 123 * Should we early load the compatibility?
118 124 *