| @@ -4,9 +4,9 @@ | ||
| 4 | 4 | use Elementor\Core\Base\Module as BaseModule; |
| 5 | 5 | use Elementor\Plugin; |
| 6 | 6 | |
| 7 | 7 | if ( ! defined( 'ABSPATH' ) ) { |
| 8 | - exit; // Exit if accessed directly. | |
| 8 | + exit; // Exit if accessed directly | |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | 11 | class Module extends BaseModule { |
| 12 | 12 | |
| @@ -25,9 +25,9 @@ | ||
| 25 | 25 | return; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | add_action( 'wp_head', function() { |
| 29 | - if ( ! $this->should_lazy_load_background_images() ) { | |
| 29 | + if ( ! $this->should_lazyload() ) { | |
| 30 | 30 | return; |
| 31 | 31 | } |
| 32 | 32 | ?> |
| 33 | 33 | <style> |
| @@ -51,13 +51,13 @@ | ||
| 51 | 51 | <?php |
| 52 | 52 | } ); |
| 53 | 53 | |
| 54 | 54 | add_action( 'wp_footer', function() { |
| 55 | - if ( ! $this->should_lazy_load_background_images() ) { | |
| 55 | + if ( ! $this->should_lazyload() ) { | |
| 56 | 56 | return; |
| 57 | 57 | } |
| 58 | 58 | ?> |
| 59 | - <script> | |
| 59 | + <script type='text/javascript'> | |
| 60 | 60 | const lazyloadRunObserver = () => { |
| 61 | 61 | const lazyloadBackgrounds = document.querySelectorAll( `.e-con.e-parent:not(.e-lazyloaded)` ); |
| 62 | 62 | const lazyloadBackgroundObserver = new IntersectionObserver( ( entries ) => { |
| 63 | 63 | entries.forEach( ( entry ) => { |
| @@ -85,9 +85,9 @@ | ||
| 85 | 85 | <?php |
| 86 | 86 | } ); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | - private function should_lazy_load_background_images(): bool { | |
| 89 | + private function should_lazyload() { | |
| 90 | 90 | return ! is_admin() && ! Plugin::$instance->preview->is_preview_mode() && ! Plugin::$instance->editor->is_edit_mode(); |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | private static function is_lazy_load_background_images_enabled(): bool { |