PluginProbe
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization / 2.5.5
Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization v2.5.5
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 3.12.1 All 134 releases
optimole-wp / inc / compatibilities / metaslider.php

metaslider.php in Optimole – Optimize Images | Convert WebP & AVIF | CDN & Lazy Load | Image Optimization 2.5.5, at inc/compatibilities/metaslider.php

94 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Class Optml_metaslider.
5 *
6 * @reason Metaslider behaves strange when the noscript tag is present near the image tag.
7 */
8 class Optml_metaslider extends Optml_compatibility {
9
10
11 /**
12 * Should we load the integration logic.
13 *
14 * @return bool Should we load.
15 */
16 function should_load() {
17 include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
18
19 return is_plugin_active( 'ml-slider/ml-slider.php' ) || is_plugin_active( 'ml-slider-pro/ml-slider-pro.php' );
20 }
21
22 /**
23 * Register integration details.
24 */
25 public function register() {
26 add_filter( 'optml_ignore_noscript_on', [ $this, 'add_noscript_flags' ], PHP_INT_MAX, 1 );
27 add_filter( 'optml_possible_lazyload_flags', [ $this, 'add_ignore_lazyload' ], PHP_INT_MAX, 1 );
28 add_filter( 'optml_watcher_lz_classes', [ $this, 'add_watcher_class' ], 10, 1 );
29 add_filter( 'metaslider_coin_slider_image_attributes', [ $this, 'setup_listner' ], PHP_INT_MAX, 1 );
30 add_filter(
31 'optml_lazyload_bg_selectors',
32 function ( $all_watchers ) {
33 $all_watchers[] = '.coin-slider > .coin-slider > a';
34 $all_watchers[] = '.coin-slider > .coin-slider';
35 return $all_watchers;
36 }
37 );
38 }
39
40 /**
41 * Disable lazyload on coinslider type.
42 *
43 * @param array $attributes Old attributes.
44 *
45 * @return mixed Slider attributes.
46 */
47 public function setup_listner( $attributes ) {
48 $attributes['class'] .= 'no-optml-lazyload';
49
50 return $attributes;
51 }
52
53 /**
54 * Add ignore lazyload flag.
55 *
56 * @param array $flags Old flags.
57 *
58 * @return array New flags.
59 */
60 public function add_ignore_lazyload( $flags = array() ) {
61 $flags[] = 'no-optml-lazyload';
62
63 return $flags;
64 }
65
66 /**
67 * Add nive slider watcher class.
68 *
69 * @param array $classes Old watcher.
70 *
71 * @return array New watchers.
72 */
73 public function add_watcher_class( $classes ) {
74 $classes[] = 'nivo-main-image';
75
76 return $classes;
77 }
78
79
80 /**
81 * Return metaslider flags.
82 *
83 * @param array $flags Old flags.
84 *
85 * @return array New flags.
86 */
87 public function add_noscript_flags( $flags = array() ) {
88 $flags[] = 'slide-';
89
90 return $flags;
91 }
92
93 }
94