| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* Class Optml_Litespeed |
| 5 |
* |
| 6 |
* Handles conflict with LiteSpeed Cache lazy loading feature. |
| 7 |
*/ |
| 8 |
class Optml_Litespeed extends Optml_Abstract_Conflict { |
| 9 |
|
| 10 |
/** |
| 11 |
* Optml_Litespeed constructor. |
| 12 |
*/ |
| 13 |
public function __construct() { |
| 14 |
$this->severity = self::SEVERITY_MEDIUM; |
| 15 |
parent::__construct(); |
| 16 |
} |
| 17 |
|
| 18 |
/** |
| 19 |
* Set the message property |
| 20 |
* |
| 21 |
* @since 4.1.0 |
| 22 |
* @access public |
| 23 |
* @return void |
| 24 |
*/ |
| 25 |
public function define_message() { |
| 26 |
$this->message = sprintf( |
| 27 |
/* translators: 1 is the settings path link */ |
| 28 |
__( 'LiteSpeed Cache has <strong>Lazy Loading</strong> enabled. Optimole already provides its own lazy loading mechanism, which may conflict with LiteSpeed Cache\'s. To continue using Optimole\'s lazy loading feature, please disable lazy loading in %1$s.', 'optimole-wp' ), |
| 29 |
'<a href="' . admin_url( 'admin.php?page=litespeed-page_optm#settings_media' ) . '">LiteSpeed Cache → Page Optimization → Media Settings</a>' |
| 30 |
); |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Determine if conflict is applicable. |
| 35 |
* |
| 36 |
* @return bool |
| 37 |
* @since 2.0.6 |
| 38 |
* @access public |
| 39 |
*/ |
| 40 |
public function is_conflict_valid() { |
| 41 |
if ( ! is_plugin_active( 'litespeed-cache/litespeed-cache.php' ) ) { |
| 42 |
return false; |
| 43 |
} |
| 44 |
|
| 45 |
if ( ! Optml_Main::instance()->admin->settings->use_lazyload() ) { |
| 46 |
return false; |
| 47 |
} |
| 48 |
|
| 49 |
if ( ! class_exists( 'LiteSpeed\Conf', false ) || ! class_exists( 'LiteSpeed\Base', false ) ) { |
| 50 |
return false; |
| 51 |
} |
| 52 |
|
| 53 |
$conf_instance = \LiteSpeed\Conf::cls(); |
| 54 |
$lazy_setting = $conf_instance->conf( \LiteSpeed\Base::O_MEDIA_LAZY ); |
| 55 |
|
| 56 |
if ( ! $lazy_setting ) { |
| 57 |
return false; |
| 58 |
} |
| 59 |
|
| 60 |
if ( class_exists( 'LiteSpeed\Metabox', false ) ) { |
| 61 |
$metabox = \LiteSpeed\Metabox::cls(); |
| 62 |
$no_lazy_setting = $metabox->setting( 'litespeed_no_image_lazy' ); |
| 63 |
|
| 64 |
return ! $no_lazy_setting; |
| 65 |
} |
| 66 |
|
| 67 |
return false; |
| 68 |
} |
| 69 |
} |
| 70 |
|