Edit File by line
/home/zeestwma/ceyloniy.../wp-conte.../plugins/elemento.../modules/lazyload
File: module.php
<?php
[0] Fix | Delete
namespace Elementor\Modules\LazyLoad;
[1] Fix | Delete
[2] Fix | Delete
use Elementor\Core\Base\Module as BaseModule;
[3] Fix | Delete
use Elementor\Plugin;
[4] Fix | Delete
[5] Fix | Delete
if ( ! defined( 'ABSPATH' ) ) {
[6] Fix | Delete
exit; // Exit if accessed directly.
[7] Fix | Delete
}
[8] Fix | Delete
[9] Fix | Delete
class Module extends BaseModule {
[10] Fix | Delete
[11] Fix | Delete
public function get_name() {
[12] Fix | Delete
return 'lazyload';
[13] Fix | Delete
}
[14] Fix | Delete
[15] Fix | Delete
public function __construct() {
[16] Fix | Delete
parent::__construct();
[17] Fix | Delete
[18] Fix | Delete
add_action( 'init', [ $this, 'init' ] );
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
public function init() {
[22] Fix | Delete
if ( ! $this->is_lazy_load_background_images_enabled() ) {
[23] Fix | Delete
return;
[24] Fix | Delete
}
[25] Fix | Delete
[26] Fix | Delete
add_action( 'wp_head', function() {
[27] Fix | Delete
if ( ! $this->should_lazy_load_background_images() ) {
[28] Fix | Delete
return;
[29] Fix | Delete
}
[30] Fix | Delete
?>
[31] Fix | Delete
<style>
[32] Fix | Delete
.e-con.e-parent:nth-of-type(n+4):not(.e-lazyloaded):not(.e-no-lazyload),
[33] Fix | Delete
.e-con.e-parent:nth-of-type(n+4):not(.e-lazyloaded):not(.e-no-lazyload) * {
[34] Fix | Delete
background-image: none !important;
[35] Fix | Delete
}
[36] Fix | Delete
@media screen and (max-height: 1024px) {
[37] Fix | Delete
.e-con.e-parent:nth-of-type(n+3):not(.e-lazyloaded):not(.e-no-lazyload),
[38] Fix | Delete
.e-con.e-parent:nth-of-type(n+3):not(.e-lazyloaded):not(.e-no-lazyload) * {
[39] Fix | Delete
background-image: none !important;
[40] Fix | Delete
}
[41] Fix | Delete
}
[42] Fix | Delete
@media screen and (max-height: 640px) {
[43] Fix | Delete
.e-con.e-parent:nth-of-type(n+2):not(.e-lazyloaded):not(.e-no-lazyload),
[44] Fix | Delete
.e-con.e-parent:nth-of-type(n+2):not(.e-lazyloaded):not(.e-no-lazyload) * {
[45] Fix | Delete
background-image: none !important;
[46] Fix | Delete
}
[47] Fix | Delete
}
[48] Fix | Delete
</style>
[49] Fix | Delete
<?php
[50] Fix | Delete
} );
[51] Fix | Delete
[52] Fix | Delete
add_action( 'wp_footer', function() {
[53] Fix | Delete
if ( ! $this->should_lazy_load_background_images() ) {
[54] Fix | Delete
return;
[55] Fix | Delete
}
[56] Fix | Delete
?>
[57] Fix | Delete
<script>
[58] Fix | Delete
const lazyloadRunObserver = () => {
[59] Fix | Delete
const lazyloadBackgrounds = document.querySelectorAll( `.e-con.e-parent:not(.e-lazyloaded)` );
[60] Fix | Delete
const lazyloadBackgroundObserver = new IntersectionObserver( ( entries ) => {
[61] Fix | Delete
entries.forEach( ( entry ) => {
[62] Fix | Delete
if ( entry.isIntersecting ) {
[63] Fix | Delete
let lazyloadBackground = entry.target;
[64] Fix | Delete
if( lazyloadBackground ) {
[65] Fix | Delete
lazyloadBackground.classList.add( 'e-lazyloaded' );
[66] Fix | Delete
}
[67] Fix | Delete
lazyloadBackgroundObserver.unobserve( entry.target );
[68] Fix | Delete
}
[69] Fix | Delete
});
[70] Fix | Delete
}, { rootMargin: '200px 0px 200px 0px' } );
[71] Fix | Delete
lazyloadBackgrounds.forEach( ( lazyloadBackground ) => {
[72] Fix | Delete
lazyloadBackgroundObserver.observe( lazyloadBackground );
[73] Fix | Delete
} );
[74] Fix | Delete
};
[75] Fix | Delete
const events = [
[76] Fix | Delete
'DOMContentLoaded',
[77] Fix | Delete
'elementor/lazyload/observe',
[78] Fix | Delete
];
[79] Fix | Delete
events.forEach( ( event ) => {
[80] Fix | Delete
document.addEventListener( event, lazyloadRunObserver );
[81] Fix | Delete
} );
[82] Fix | Delete
</script>
[83] Fix | Delete
<?php
[84] Fix | Delete
} );
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
private function should_lazy_load_background_images(): bool {
[88] Fix | Delete
return ! is_admin() && ! Plugin::$instance->preview->is_preview_mode() && ! Plugin::$instance->editor->is_edit_mode();
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
private static function is_lazy_load_background_images_enabled(): bool {
[92] Fix | Delete
return '1' === get_option( 'elementor_lazy_load_background_images', '1' );
[93] Fix | Delete
}
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function