-
Notifications
You must be signed in to change notification settings - Fork 14
feat: added compatibility notices for lazy loading #964
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ce97866
feat: added compatibility notices for lazy loading
RaduCristianPopescu 21c4f2c
chore: phpstan
RaduCristianPopescu 4003e22
feat: smush conflict
RaduCristianPopescu 737d709
chore: incorrect path
RaduCristianPopescu 3d7bb40
feat: litespeed conflict
RaduCristianPopescu 9ea23d8
fix: logical errors
RaduCristianPopescu 01e90e4
chore: phpcbf
RaduCristianPopescu f434d01
feat: autoptimize conflict handling
RaduCristianPopescu 390a9f6
feat:perfmatters conflict handling
RaduCristianPopescu a404964
fix: jetpack conflict
RaduCristianPopescu 95ab1e0
chore: phpstan
RaduCristianPopescu eafe7c7
chore: phpcs
RaduCristianPopescu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Class Optml_Autoptimize | ||
| * | ||
| * Handles conflicts with Autoptimize plugin. | ||
| */ | ||
| class Optml_Autoptimize extends Optml_Abstract_Conflict { | ||
|
|
||
| /** | ||
| * Optml_Autoptimize constructor. | ||
| */ | ||
| public function __construct() { | ||
| $this->severity = self::SEVERITY_MEDIUM; | ||
| parent::__construct(); | ||
| } | ||
|
|
||
| /** | ||
| * Set the message property | ||
| * | ||
| * @since 4.1.0 | ||
| * @access public | ||
| * @return void | ||
| */ | ||
| public function define_message() { | ||
| $this->message = sprintf( | ||
| /* translators: 1 is the settings path link */ | ||
| __( 'Autoptimize has <strong>Lazy loading</strong> enabled. Optimole already provides its own lazy loading mechanism, which may conflict with Autoptimize\'s. To continue using Optimole\'s lazy loading feature, please disable lazy loading in %1$s.', 'optimole-wp' ), | ||
| '<a href="' . admin_url( 'admin.php?page=autoptimize_imgopt' ) . '">Autoptimize → Image Optimization</a>' | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Determine if conflict is applicable. | ||
| * | ||
| * @return bool | ||
| * @since 2.0.6 | ||
| * @access public | ||
| */ | ||
| public function is_conflict_valid() { | ||
| if ( ! is_plugin_active( 'autoptimize/autoptimize.php' ) ) { | ||
| return false; | ||
| } | ||
|
|
||
| if ( ! Optml_Main::instance()->admin->settings->use_lazyload() ) { | ||
| return false; | ||
| } | ||
|
|
||
| $autoptimize_imgopt_settings = get_option( 'autoptimize_imgopt_settings', '' ); | ||
| if ( ! empty( $autoptimize_imgopt_settings ) ) { | ||
| $settings = maybe_unserialize( $autoptimize_imgopt_settings ); | ||
| if ( is_array( $settings ) && isset( $settings['autoptimize_imgopt_checkbox_field_3'] ) ) { | ||
| return (bool) $settings['autoptimize_imgopt_checkbox_field_3']; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Class Optml_Litespeed | ||
| * | ||
| * Handles conflict with LiteSpeed Cache lazy loading feature. | ||
| */ | ||
| class Optml_Litespeed extends Optml_Abstract_Conflict { | ||
|
|
||
| /** | ||
| * Optml_Litespeed constructor. | ||
| */ | ||
| public function __construct() { | ||
| $this->severity = self::SEVERITY_MEDIUM; | ||
| parent::__construct(); | ||
| } | ||
|
|
||
| /** | ||
| * Set the message property | ||
| * | ||
| * @since 4.1.0 | ||
| * @access public | ||
| * @return void | ||
| */ | ||
| public function define_message() { | ||
| $this->message = sprintf( | ||
| /* translators: 1 is the settings path link */ | ||
| __( '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' ), | ||
| '<a href="' . admin_url( 'admin.php?page=litespeed-page_optm#settings_media' ) . '">LiteSpeed Cache → Page Optimization → Media Settings</a>' | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Determine if conflict is applicable. | ||
| * | ||
| * @return bool | ||
| * @since 2.0.6 | ||
| * @access public | ||
| */ | ||
| public function is_conflict_valid() { | ||
| if ( ! is_plugin_active( 'litespeed-cache/litespeed-cache.php' ) ) { | ||
| return false; | ||
| } | ||
|
|
||
| if ( ! Optml_Main::instance()->admin->settings->use_lazyload() ) { | ||
| return false; | ||
| } | ||
|
|
||
| if ( ! class_exists( 'LiteSpeed\Conf', false ) || ! class_exists( 'LiteSpeed\Base', false ) ) { | ||
| return false; | ||
| } | ||
|
|
||
| $conf_instance = \LiteSpeed\Conf::cls(); | ||
| $lazy_setting = $conf_instance->conf( \LiteSpeed\Base::O_MEDIA_LAZY ); | ||
|
|
||
| if ( ! $lazy_setting ) { | ||
| return false; | ||
| } | ||
|
|
||
| if ( class_exists( 'LiteSpeed\Metabox', false ) ) { | ||
| $metabox = \LiteSpeed\Metabox::cls(); | ||
| $no_lazy_setting = $metabox->setting( 'litespeed_no_image_lazy' ); | ||
|
|
||
| return ! $no_lazy_setting; | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * Class Optml_Perfmatters | ||
| * | ||
| * Handles conflicts with Perfmatters plugin. | ||
| */ | ||
| class Optml_Perfmatters extends Optml_Abstract_Conflict { | ||
|
|
||
| /** | ||
| * Optml_Perfmatters constructor. | ||
| */ | ||
| public function __construct() { | ||
| $this->severity = self::SEVERITY_MEDIUM; | ||
| parent::__construct(); | ||
| } | ||
|
|
||
| /** | ||
| * Set the message property | ||
| * | ||
| * @since 4.1.0 | ||
| * @access public | ||
| * @return void | ||
| */ | ||
| public function define_message() { | ||
| $this->message = sprintf( | ||
| /* translators: 1 is the settings path link */ | ||
| __( 'Perfmatters has <strong>Lazy loading</strong> enabled. Optimole already provides its own lazy loading mechanism, which may conflict with Perfmatters\'. To continue using Optimole\'s lazy loading feature, please disable lazy loading in %1$s.', 'optimole-wp' ), | ||
| '<a href="' . admin_url( 'admin.php?page=perfmatters&tab=lazyload#lazyload' ) . '">Perfmatters → Lazy Load</a>' | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Determine if conflict is applicable. | ||
| * | ||
| * @return bool | ||
| * @since 2.0.6 | ||
| * @access public | ||
| */ | ||
| public function is_conflict_valid() { | ||
| if ( ! is_plugin_active( 'perfmatters/perfmatters.php' ) ) { | ||
| return false; | ||
| } | ||
|
|
||
| if ( ! Optml_Main::instance()->admin->settings->use_lazyload() ) { | ||
| return false; | ||
| } | ||
|
|
||
| $perfmatters_options = get_option( 'perfmatters_options', [] ); | ||
| if ( ! empty( $perfmatters_options ) && isset( $perfmatters_options['lazyload'] ) ) { | ||
| $lazyload_settings = $perfmatters_options['lazyload']; | ||
| if ( is_array( $lazyload_settings ) && isset( $lazyload_settings['lazy_loading'] ) ) { | ||
| return (bool) $lazyload_settings['lazy_loading']; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can simplify it with something like this: