Skip to content

Commit 5a02a7a

Browse files
authored
Merge pull request #1012 from Codeinwp/enh/bg-lazy-coverage
Improve background lazyload coverage for third party plugins
2 parents fbba0ab + 85d56e1 commit 5a02a7a

File tree

7 files changed

+95
-4
lines changed

7 files changed

+95
-4
lines changed

inc/compatibilities/beaver_builder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public function register() {
2828
function ( $all_watchers ) {
2929
$all_watchers[] = '.fl-col-content';
3030
$all_watchers[] = '.fl-row-bg-photo > .fl-row-content-wrap';
31+
$all_watchers[] = '.fl-module-box';
3132

3233
return $all_watchers;
3334
}

inc/compatibilities/elementor_builder.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public function register() {
3333
function ( $all_watchers ) {
3434
$all_watchers[] = '.elementor-widget-container';
3535
$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+
3641
return $all_watchers;
3742
}
3843
);
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/**
4+
* Class Optml_essential_blocks
5+
*
6+
* @reason Adding selectors for background lazyload
7+
*/
8+
class Optml_essential_blocks extends Optml_compatibility {
9+
10+
/**
11+
* Should we load the integration logic.
12+
*
13+
* @return bool Should we load.
14+
*/
15+
public function should_load() {
16+
include_once ABSPATH . 'wp-admin/includes/plugin.php';
17+
18+
return is_plugin_active( 'essential-blocks/essential-blocks.php' );
19+
}
20+
21+
/**
22+
* Register integration details.
23+
*
24+
* @return void
25+
*/
26+
public function register() {
27+
add_filter(
28+
'optml_lazyload_bg_selectors',
29+
function ( $all_watchers ) {
30+
// Class starts with `eb-` and ends with `-container`
31+
$all_watchers[] = '[class^="eb-"][class*="-container"]';
32+
33+
return $all_watchers;
34+
}
35+
);
36+
}
37+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
/**
4+
* Class Optml_kadence_blocks.
5+
*
6+
* @reason @reason Adding selectors for background lazyload
7+
*/
8+
class Optml_kadence_blocks extends Optml_compatibility {
9+
10+
11+
/**
12+
* Should we load the integration logic.
13+
*
14+
* @return bool Should we load.
15+
*/
16+
public function should_load() {
17+
include_once ABSPATH . 'wp-admin/includes/plugin.php';
18+
19+
return is_plugin_active( 'kadence-blocks/kadence-blocks.php' );
20+
}
21+
22+
/**
23+
* Register integration details.
24+
*
25+
* @return void
26+
*/
27+
public function register() {
28+
add_filter(
29+
'optml_lazyload_bg_selectors',
30+
function ( $all_watchers ) {
31+
$all_watchers[] = '.kt-row-has-bg';
32+
$all_watchers[] = '.kt-row-layout-overlay';
33+
$all_watchers[] = '.kt-inside-inner-col';
34+
35+
return $all_watchers;
36+
}
37+
);
38+
}
39+
}

inc/compatibilities/spectra.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,24 @@ class Optml_spectra extends Optml_compatibility {
1414
*/
1515
public function should_load() {
1616
include_once ABSPATH . 'wp-admin/includes/plugin.php';
17-
return is_plugin_active( 'ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php' ) && 'enabled' === get_option( '_uagb_allow_file_generation', 'enabled' );
17+
18+
return is_plugin_active( 'ultimate-addons-for-gutenberg/ultimate-addons-for-gutenberg.php' );
1819
}
1920

2021
/**
2122
* Register integration details.
2223
*/
2324
public function register() {
2425
add_filter( 'uagb_block_attributes_for_css_and_js', [ $this, 'optimize_src' ], PHP_INT_MAX, 2 );
26+
27+
add_filter(
28+
'optml_lazyload_bg_selectors',
29+
function ( $all_watchers ) {
30+
$all_watchers[] = '.wp-block-uagb-container';
31+
32+
return $all_watchers;
33+
}
34+
);
2535
}
2636

2737
/**

inc/lazyload_replacer.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,6 @@ public static function get_background_lazyload_selectors() {
125125
return self::$background_lazyload_selectors;
126126
}
127127
$default_watchers = [
128-
'.elementor-section[data-settings*="background_background"]',
129-
'.elementor-column[data-settings*="background_background"] > .elementor-widget-wrap',
130-
'.elementor-section > .elementor-background-overlay',
131128
'[class*="wp-block-cover"][style*="background-image"]',
132129
'[style*="background-image:url("]', '[style*="background-image: url("]',
133130
'[style*="background:url("]', '[style*="background: url("]',

inc/manager.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ final class Optml_Manager {
6969
* @var array Integrations classes.
7070
*/
7171
private $possible_compatibilities = [
72+
'kadence_blocks',
73+
'essential_blocks',
7274
'shortcode_ultimate',
7375
'foogallery',
7476
'envira',

0 commit comments

Comments
 (0)