| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Class Optml_revslider. |
| 5 |
* |
| 6 |
* @reason The slider output dont needs the data-opt-src and uses a background lazyload approach. |
| 7 |
*/ |
| 8 |
class Optml_revslider extends Optml_compatibility { |
| 9 |
|
| 10 |
/** |
| 11 |
* Should we load the integration logic. |
| 12 |
* |
| 13 |
* @return bool Should we load. |
| 14 |
*/ |
| 15 |
function should_load() { |
| 16 |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); |
| 17 |
|
| 18 |
return is_plugin_active( 'revslider/revslider.php' ); |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Register integration details. |
| 23 |
*/ |
| 24 |
public function register() { |
| 25 |
|
| 26 |
add_filter( 'optml_possible_lazyload_flags', [ $this, 'add_lazyflag' ], 10, 2 ); |
| 27 |
add_filter( 'optml_ignore_data_opt_flag', [$this, 'add_data_ignore'], 10, 3 ); |
| 28 |
add_filter( 'optml_lazyload_bg_classes', [$this, 'add_bg_class'], 10, 1 ); |
| 29 |
} |
| 30 |
|
| 31 |
/** |
| 32 |
* Add Slider Revolution lazyload flag. |
| 33 |
* |
| 34 |
* @param array $strings Old strings. |
| 35 |
* |
| 36 |
* @return array New flags. |
| 37 |
*/ |
| 38 |
function add_lazyflag( $strings = array() ) { |
| 39 |
|
| 40 |
$strings[] = 'rev-slidebg'; |
| 41 |
|
| 42 |
return $strings; |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* Add classes for lazyload on background. |
| 47 |
* |
| 48 |
* @param string $classes Old classes. |
| 49 |
* |
| 50 |
* @return array New classes. |
| 51 |
*/ |
| 52 |
public function add_bg_class( $classes = array() ) { |
| 53 |
$classes[] = 'tp-bgimg'; |
| 54 |
|
| 55 |
return $classes; |
| 56 |
} |
| 57 |
|
| 58 |
/** |
| 59 |
* Adds flag that should ignore applying the data-opt-src |
| 60 |
* |
| 61 |
* @param string $flags Flag that should ignore. |
| 62 |
* |
| 63 |
* @return array New flags. |
| 64 |
*/ |
| 65 |
public function add_data_ignore( $flags = array() ) { |
| 66 |
$flags[] = 'rev-slidebg'; |
| 67 |
|
| 68 |
return $flags; |
| 69 |
} |
| 70 |
|
| 71 |
} |
| 72 |
|