Skip to content

Commit 64b0bfe

Browse files
committed
Fix new sniffs
1 parent ae74dc1 commit 64b0bfe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+227
-267
lines changed

inc/admin.php

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,9 @@ public function register_public_actions() {
506506
add_action( 'wp_enqueue_scripts', [ $this, 'add_diagnosis_script' ] );
507507
}
508508
if ( ! $this->settings->use_lazyload()
509-
|| ( $this->settings->get( 'native_lazyload' ) === 'enabled'
510-
&& $this->settings->get( 'video_lazyload' ) === 'disabled'
511-
&& $this->settings->get( 'bg_replacer' ) === 'disabled' ) ) {
509+
|| ( $this->settings->get( 'native_lazyload' ) === 'enabled'
510+
&& $this->settings->get( 'video_lazyload' ) === 'disabled'
511+
&& $this->settings->get( 'bg_replacer' ) === 'disabled' ) ) {
512512
return;
513513
}
514514
add_action( 'wp_enqueue_scripts', [ $this, 'frontend_scripts' ] );
@@ -556,7 +556,7 @@ public function inline_bootstrap_script() {
556556
$limit_width = $limit_dimensions ? $this->settings->get( 'limit_width' ) : 0;
557557
$limit_height = $limit_dimensions ? $this->settings->get( 'limit_height' ) : 0;
558558
$retina_ready = $limit_dimensions ||
559-
! ( $this->settings->get( 'retina_images' ) === 'enabled' );
559+
! ( $this->settings->get( 'retina_images' ) === 'enabled' );
560560
$scale_is_disabled = ( $this->settings->get( 'scale' ) === 'enabled' );
561561
$native_lazy_enabled = ( $this->settings->get( 'native_lazyload' ) === 'enabled' );
562562
$output = sprintf(
@@ -647,7 +647,7 @@ public function add_diagnosis_script() {
647647
*
648648
* @return array Altered links.
649649
*/
650-
function add_action_links( $links ) {
650+
public function add_action_links( $links ) {
651651
if ( ! is_array( $links ) ) {
652652
return $links;
653653
}
@@ -704,7 +704,7 @@ public function add_notice_upgrade() {
704704
}
705705
?>
706706
<div class="notice optml-notice-optin"
707-
style="background-color: #577BF9; color:white; border: none !important; display: flex;">
707+
style="background-color: #577BF9; color:white; border: none !important; display: flex;">
708708
<div style="margin: 1% 2%;">
709709
<img src='<?php echo OPTML_URL . 'assets/img/upgrade_icon.png'; ?>'>
710710
</div>
@@ -725,11 +725,11 @@ public function add_notice_upgrade() {
725725
</p>
726726
<p style="margin: 1.5% 0;">
727727
<a href="<?php echo esc_url( tsdk_translate_link( 'https://optimole.com/pricing' ) ); ?>"
728-
target="_blank"
729-
style="border-radius: 4px;padding: 9px 10px;border: 2px solid #FFF;color: white;text-decoration: none;"><?php _e( 'Check upgrade plans', 'optimole-wp' ); ?>
728+
target="_blank"
729+
style="border-radius: 4px;padding: 9px 10px;border: 2px solid #FFF;color: white;text-decoration: none;"><?php _e( 'Check upgrade plans', 'optimole-wp' ); ?>
730730
</a>
731731
<a style="padding: 2%; color: white;"
732-
href="<?php echo wp_nonce_url( add_query_arg( [ 'optml_hide_upg' => 'yes' ] ), 'hide_nonce', 'optml_nonce' ); ?>"><?php _e( 'I have already done this', 'optimole-wp' ); ?></a>
732+
href="<?php echo wp_nonce_url( add_query_arg( [ 'optml_hide_upg' => 'yes' ] ), 'hide_nonce', 'optml_nonce' ); ?>"><?php _e( 'I have already done this', 'optimole-wp' ); ?></a>
733733
</p>
734734
</div>
735735
</div>
@@ -744,10 +744,10 @@ public function add_notice_upgrade() {
744744
public function should_show_upgrade() {
745745
$current_screen = get_current_screen();
746746
if ( ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ||
747-
is_network_admin() ||
748-
! current_user_can( 'manage_options' ) ||
749-
! $this->settings->is_connected() ||
750-
empty( $current_screen )
747+
is_network_admin() ||
748+
! current_user_can( 'manage_options' ) ||
749+
! $this->settings->is_connected() ||
750+
empty( $current_screen )
751751
) {
752752
return false;
753753
}
@@ -870,7 +870,7 @@ public function add_notice() {
870870
<div class="notice notice-info optml-notice-optin">
871871
<div class="content">
872872
<img src="<?php echo OPTML_URL . '/assets/img/logo.svg'; ?>"
873-
alt="<?php echo esc_attr__( 'Logo', 'optimole-wp' ); ?>"/>
873+
alt="<?php echo esc_attr__( 'Logo', 'optimole-wp' ); ?>"/>
874874

875875
<div>
876876
<p class="notice-title"> <?php echo esc_html__( 'Finish setting up!', 'optimole-wp' ); ?></p>
@@ -888,10 +888,10 @@ public function add_notice() {
888888
</p>
889889
<div class="actions">
890890
<a href="<?php echo esc_url( admin_url( 'admin.php?page=optimole' ) ); ?>"
891-
class="button button-primary button-hero"><?php _e( 'Connect to OptiMole', 'optimole-wp' ); ?>
891+
class="button button-primary button-hero"><?php _e( 'Connect to OptiMole', 'optimole-wp' ); ?>
892892
</a>
893893
<a class="button button-secondary button-hero"
894-
href="<?php echo wp_nonce_url( add_query_arg( [ 'optml_hide_optin' => 'yes' ] ), 'hide_nonce', 'optml_nonce' ); ?>"><?php _e( 'I will do it later', 'optimole-wp' ); ?>
894+
href="<?php echo wp_nonce_url( add_query_arg( [ 'optml_hide_optin' => 'yes' ] ), 'hide_nonce', 'optml_nonce' ); ?>"><?php _e( 'I will do it later', 'optimole-wp' ); ?>
895895
</a>
896896
</div>
897897
</div>
@@ -924,7 +924,7 @@ public function add_notice_conflicts() {
924924
<div class="notice notice-info optml-notice-optin has-dismiss">
925925
<div class="content">
926926
<img src="<?php echo OPTML_URL . '/assets/img/logo.svg'; ?>"
927-
alt="<?php echo esc_attr__( 'Logo', 'optimole-wp' ); ?>"/>
927+
alt="<?php echo esc_attr__( 'Logo', 'optimole-wp' ); ?>"/>
928928

929929
<div>
930930
<p class="notice-title">
@@ -943,7 +943,7 @@ public function add_notice_conflicts() {
943943
</p>
944944
<div class="actions">
945945
<a href="<?php echo esc_url( admin_url( 'plugins.php?optimole_conflicts' ) ); ?>"
946-
class="button button-primary button-hero"><?php _e( 'Manage Plugins', 'optimole-wp' ); ?>
946+
class="button button-primary button-hero"><?php _e( 'Manage Plugins', 'optimole-wp' ); ?>
947947
</a>
948948
</div>
949949
</div>
@@ -1006,7 +1006,6 @@ public function frontend_scripts() {
10061006
';
10071007
wp_add_inline_script( 'optml-print', $script );
10081008
}
1009-
10101009
}
10111010

10121011
/**
@@ -1059,7 +1058,7 @@ public function generator() {
10591058
/**
10601059
* Update daily the quota routine.
10611060
*/
1062-
function daily_sync() {
1061+
public function daily_sync() {
10631062

10641063
$api_key = $this->settings->get( 'api_key' );
10651064
$service_data = $this->settings->get( 'service_data' );
@@ -1093,7 +1092,6 @@ function daily_sync() {
10931092
}
10941093

10951094
remove_filter( 'optml_dont_trigger_settings_updated', '__return_true' );
1096-
10971095
}
10981096

10991097
/**
@@ -1106,7 +1104,7 @@ function daily_sync() {
11061104
*/
11071105
public function add_dns_prefetch( $hints, $relation_type ) {
11081106
if ( 'dns-prefetch' !== $relation_type &&
1109-
'preconnect' !== $relation_type
1107+
'preconnect' !== $relation_type
11101108
) {
11111109
return $hints;
11121110
}

inc/api.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,6 @@ public function request( $path, $method = 'GET', $params = [], $extra_headers =
221221
}
222222

223223
return $response['data'];
224-
225224
}
226225

227226
/**
@@ -256,7 +255,7 @@ private function build_args( $method, $url, $headers, $params ) {
256255
* @return bool Whether or not the url is valid.
257256
*/
258257
public function check_optimized_url( $url ) {
259-
$response = wp_remote_get( $url, ['timeout' => 30] );
258+
$response = wp_remote_get( $url, [ 'timeout' => 30 ] );
260259

261260
if ( is_wp_error( $response ) || wp_remote_retrieve_response_code( $response ) !== 200 || ! empty( wp_remote_retrieve_header( $response, 'x-not-found-o' ) ) ) {
262261
$this->log_offload_error( $response );
@@ -304,7 +303,7 @@ public function call_onboard_api( $images = [] ) {
304303
* @return array
305304
*/
306305
public function call_data_enrich_api( $images = [] ) {
307-
return $this->request( 'optml/v2/media/add_data', 'POST', ['images' => $images, 'key' => Optml_Config::$key] );
306+
return $this->request( 'optml/v2/media/add_data', 'POST', [ 'images' => $images, 'key' => Optml_Config::$key ] );
308307
}
309308
/**
310309
* Register user remotely on optimole.com.
@@ -343,7 +342,7 @@ public function get_optimized_images( $api_key = '' ) {
343342
if ( isset( $service_data['cdn_key'] ) ) {
344343
$app_key = $service_data['cdn_key'];
345344
}
346-
return $this->request( '/optml/v1/stats/images', 'GET', [], ['application' => $app_key] );
345+
return $this->request( '/optml/v1/stats/images', 'GET', [], [ 'application' => $app_key ] );
347346
}
348347

349348
/**
@@ -409,7 +408,7 @@ public function add_watermark( $file ) {
409408
*/
410409
public function get_cloud_images( $page = 0, $domains = [], $search = '' ) {
411410

412-
$params = ['key' => Optml_Config::$key ];
411+
$params = [ 'key' => Optml_Config::$key ];
413412
$params['page'] = $page;
414413
$params['size'] = 40;
415414
if ( $search !== '' ) {
@@ -447,7 +446,7 @@ public function log_offload_error( $error_response ) {
447446
wp_remote_post(
448447
$this->upload_conflicts_api,
449448
[
450-
'headers' => [ 'Content-Type' => 'application/json' ],
449+
'headers' => [ 'Content-Type' => 'application/json' ],
451450
'timeout' => 15,
452451
'blocking' => true,
453452
'sslverify' => false,

inc/app_replacer.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
*/
1212
abstract class Optml_App_Replacer {
1313
use Optml_Dam_Offload_Utils;
14+
1415
/**
1516
* Filters used for lazyload.
1617
*
@@ -198,7 +199,7 @@ public static function possible_tag_flags() {
198199

199200
self::$ignore_tag_strings = apply_filters( 'optml_skip_optimizations_css_classes', [ 'skip-optimization' ] );
200201

201-
return self::$ignore_tag_strings;
202+
return self::$ignore_tag_strings;
202203
}
203204
/**
204205
* Returns possible data-opt-src ignore flags attributes.
@@ -257,7 +258,6 @@ public static function add_size( $width = null, $height = null, $crop = null ) {
257258
'enlarge' => true,
258259
'crop' => $crop,
259260
];
260-
261261
}
262262

263263
/**
@@ -335,7 +335,7 @@ public function init() {
335335
self::$filters = $this->settings->get_filters();
336336
add_filter(
337337
'optml_should_avif_ext',
338-
function( $should_avif, $ext ) {
338+
function ( $should_avif, $ext ) {
339339
return $ext !== 'svg';
340340
},
341341
10,
@@ -481,7 +481,7 @@ public function get_upload_resource() {
481481
*
482482
* @return mixed Original value.
483483
*/
484-
static function listen_to_sizes( $value, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
484+
public static function listen_to_sizes( $value, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
485485
self::add_size( $dest_w, $dest_h, $crop );
486486

487487
return $value;

inc/attachment_cache.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public static function set_cached_attachment_id( $url, $id ) {
5959
wp_using_ext_object_cache()
6060
? wp_cache_set( $cache_key, $id, self::CACHE_GROUP, $expiration )
6161
: set_transient( self::CACHE_GROUP . $cache_key, $id, $expiration );
62-
6362
}
6463

6564
/**

inc/cli/cli_media.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@ private function update_images_template( $action ) {
8383
}
8484

8585
$progress->tick();
86-
$tick++;
86+
++$tick;
8787
}
8888
$progress->finish();
8989
WP_CLI::line( $strings[ $action ]['success'] );
9090
}
9191
}
92-

inc/compatibilities/beaver_builder.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class Optml_beaver_builder extends Optml_compatibility {
1313
*
1414
* @return bool Should we load.
1515
*/
16-
function should_load() {
17-
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
16+
public function should_load() {
17+
include_once ABSPATH . 'wp-admin/includes/plugin.php';
1818

1919
return is_plugin_active( 'bb-plugin/fl-builder.php' ) || is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' );
2020
}
@@ -35,5 +35,4 @@ function ( $all_watchers ) {
3535
add_filter( 'fl_builder_render_css', [ Optml_Main::instance()->manager, 'replace_content' ], PHP_INT_MAX, 1 );
3636
add_filter( 'fl_builder_render_js', [ Optml_Main::instance()->manager, 'replace_content' ], PHP_INT_MAX, 1 );
3737
}
38-
3938
}

inc/compatibilities/cache_enabler.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ class Optml_cache_enabler extends Optml_compatibility {
1212
*
1313
* @return bool Should we load.
1414
*/
15-
function should_load() {
16-
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
15+
public function should_load() {
16+
include_once ABSPATH . 'wp-admin/includes/plugin.php';
1717

1818
return is_plugin_active( 'cache-enabler/cache-enabler.php' );
1919
}
@@ -32,7 +32,6 @@ function () {
3232
do_action( 'cache_enabler_clear_site_cache' );
3333
}
3434
);
35-
3635
}
3736

3837
/**
@@ -43,5 +42,4 @@ function () {
4342
public function should_load_early() {
4443
return true;
4544
}
46-
4745
}

inc/compatibilities/compatibility.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,21 @@ abstract class Optml_compatibility {
66
/**
77
* Register compatibility actions/filters.
88
*/
9-
abstract function register();
9+
abstract public function register();
1010

1111
/**
1212
* Should we load the compatibility?
1313
*
1414
* @return bool Compatiblity
1515
*/
16-
abstract function should_load();
16+
abstract public function should_load();
1717

1818
/**
1919
* Will the compatibility be loaded?
2020
*
2121
* @return bool
2222
*/
23-
public final function will_load() {
23+
final public function will_load() {
2424
if ( ! Optml_Main::instance()->admin->settings->is_connected() ) {
2525
return false;
2626
}

inc/compatibilities/divi_builder.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class Optml_divi_builder extends Optml_compatibility {
1313
*
1414
* @return bool Should we load.
1515
*/
16-
function should_load() {
16+
public function should_load() {
1717
return (
1818
strcmp( wp_get_theme(), 'Divi' ) === 0 ||
1919
is_plugin_active( 'divi-builder/divi-builder.php' )
@@ -25,9 +25,9 @@ function should_load() {
2525
*/
2626
public function register() {
2727

28-
add_action( 'et_core_static_file_created', [$this, 'optimize_divi_static_files'] );
28+
add_action( 'et_core_static_file_created', [ $this, 'optimize_divi_static_files' ] );
2929

30-
add_action( 'optml_settings_updated', [$this, 'clear_divi_static_files'] );
30+
add_action( 'optml_settings_updated', [ $this, 'clear_divi_static_files' ] );
3131

3232
add_filter(
3333
'optml_lazyload_bg_selectors',
@@ -47,17 +47,17 @@ function ( $all_watchers ) {
4747
/**
4848
* Replace image urls upon divi's static css files creation
4949
*
50-
* @param ET_Core_PageResource $resource ET_Core_PageResource object.
50+
* @param ET_Core_PageResource $page_resource ET_Core_PageResource object.
5151
* @return void
5252
*/
53-
public function optimize_divi_static_files( $resource ) {
53+
public function optimize_divi_static_files( $page_resource ) {
5454
if ( class_exists( 'ET_Core_PageResource' ) && null !== ET_Core_PageResource::$wpfs ) {
55-
if ( isset( $resource->path ) ) {
56-
$data = $resource->get_data( 'file' );
55+
if ( isset( $page_resource->path ) ) {
56+
$data = $page_resource->get_data( 'file' );
5757

5858
if ( ! empty( $data ) ) {
5959
$data = Optml_Main::instance()->manager->replace_content( $data );
60-
ET_Core_PageResource::$wpfs->put_contents( $resource->path, $data, 0644 );
60+
ET_Core_PageResource::$wpfs->put_contents( $page_resource->path, $data, 0644 );
6161
}
6262
}
6363
}

0 commit comments

Comments
 (0)