Skip to content

Commit 7d14bb5

Browse files
committed
Release new version 2.3.1
= 2.3.1 - 2020/02/29 = * This maintenance release contains various PHP code updates to resolve PHP warnings and depreciations in PHP 7.0 to 7.4 * Fix - Update global ${$this- to $GLOBALS[$this to resolve 7.0+ PHP warnings * Fix - Update global ${$option} to $GLOBALS[$option] to resolve 7.0+ PHP warnings * Fix - Update less PHP lib that use square brackets [] instead of curly braces {} for Array , depreciated in PHP 7.4 * Fix - Validate for do not use get_magic_quotes_gpc function for PHP 7.4
1 parent 660fa80 commit 7d14bb5

File tree

10 files changed

+47
-56
lines changed

10 files changed

+47
-56
lines changed

a3-lazy-load.php

+5-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
Plugin Name: a3 Lazy Load
44
Description: Speed up your site and enhance frontend user's visual experience in PC's, Tablets and mobile with a3 Lazy Load.
5-
Version: 2.3.0
5+
Version: 2.3.1
66
Author: a3rev Software
77
Author URI: https://a3rev.com/
88
Requires at least: 4.9
@@ -33,7 +33,7 @@
3333

3434
define( 'A3_LAZY_LOAD_KEY', 'a3_lazy_load' );
3535
define( 'A3_LAZY_LOAD_PREFIX', 'a3_lazy_load_' );
36-
define( 'A3_LAZY_VERSION', '2.3.0' );
36+
define( 'A3_LAZY_VERSION', '2.3.1' );
3737
define( 'A3_LAZY_LOAD_G_FONTS', false );
3838

3939
use \A3Rev\LazyLoad\FrameWork;
@@ -44,17 +44,14 @@
4444
/**
4545
* Plugin Framework init
4646
*/
47-
global ${A3_LAZY_LOAD_PREFIX.'admin_interface'};
48-
${A3_LAZY_LOAD_PREFIX.'admin_interface'} = new FrameWork\Admin_Interface();
47+
$GLOBALS[A3_LAZY_LOAD_PREFIX.'admin_interface'] = new FrameWork\Admin_Interface();
4948

5049
global $a3_lazy_load_settings_page;
5150
$a3_lazy_load_settings_page = new FrameWork\Pages\Settings();
5251

53-
global ${A3_LAZY_LOAD_PREFIX.'admin_init'};
54-
${A3_LAZY_LOAD_PREFIX.'admin_init'} = new FrameWork\Admin_Init();
52+
$GLOBALS[A3_LAZY_LOAD_PREFIX.'admin_init'] = new FrameWork\Admin_Init();
5553

56-
global ${A3_LAZY_LOAD_PREFIX.'less'};
57-
${A3_LAZY_LOAD_PREFIX.'less'} = new FrameWork\Less_Sass();
54+
$GLOBALS[A3_LAZY_LOAD_PREFIX.'less'] = new FrameWork\Less_Sass();
5855

5956
// End - Plugin Framework init
6057

admin/a3-lazy-load-admin.php

+4-7
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
function a3_lazy_load_activated(){
44
update_option('a3_lazy_load_version', A3_LAZY_VERSION );
55

6-
global ${A3_LAZY_LOAD_PREFIX.'admin_init'};
7-
delete_metadata( 'user', 0, ${A3_LAZY_LOAD_PREFIX.'admin_init'}->plugin_name . '-' . 'plugin_framework_global_box' . '-' . 'opened', '', true );
6+
delete_metadata( 'user', 0, $GLOBALS[A3_LAZY_LOAD_PREFIX.'admin_init']->plugin_name . '-' . 'plugin_framework_global_box' . '-' . 'opened', '', true );
87

98
update_option('a3_lazy_load_just_installed', true);
109
}
@@ -18,20 +17,18 @@ function a3_lazy_load_init() {
1817
delete_option( 'a3_lazy_load_just_installed' );
1918

2019
// Set Settings Default from Admin Init
21-
global ${A3_LAZY_LOAD_PREFIX.'admin_init'};
22-
${A3_LAZY_LOAD_PREFIX.'admin_init'}->set_default_settings();
20+
$GLOBALS[A3_LAZY_LOAD_PREFIX.'admin_init']->set_default_settings();
2321
}
2422

2523
a3_lazy_load_plugin_textdomain();
2624

2725
a3_lazy_load_upgrade_plugin();
2826
}
2927

30-
global ${A3_LAZY_LOAD_PREFIX.'admin_init'};
31-
${A3_LAZY_LOAD_PREFIX.'admin_init'}->init();
28+
$GLOBALS[A3_LAZY_LOAD_PREFIX.'admin_init']->init();
3229

3330
// Add upgrade notice to Dashboard pages
34-
add_filter( ${A3_LAZY_LOAD_PREFIX.'admin_init'}->plugin_name . '_plugin_extension_boxes', array( '\A3Rev\LazyLoad\Hook_Filter', 'plugin_extension_box' ) );
31+
add_filter( $GLOBALS[A3_LAZY_LOAD_PREFIX.'admin_init']->plugin_name . '_plugin_extension_boxes', array( '\A3Rev\LazyLoad\Hook_Filter', 'plugin_extension_box' ) );
3532

3633
// Add language
3734
add_action('init', 'a3_lazy_load_init', 105);

admin/admin-interface.php

+12-17
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,10 @@ public function get_reset_message( $message = '' ) {
298298
/*-----------------------------------------------------------------------------------*/
299299
public function admin_includes() {
300300
// Includes Font Face Lib
301-
global ${$this->plugin_prefix.'fonts_face'};
302-
${$this->plugin_prefix.'fonts_face'} = new Fonts_Face();
301+
$GLOBALS[$this->plugin_prefix.'fonts_face'] = new Fonts_Face();
303302

304303
// Includes Uploader Lib
305-
global ${$this->plugin_prefix.'uploader'};
306-
${$this->plugin_prefix.'uploader'} = new Uploader();
304+
$GLOBALS[$this->plugin_prefix.'uploader'] = new Uploader();
307305
}
308306

309307
/*-----------------------------------------------------------------------------------*/
@@ -425,9 +423,7 @@ public function get_settings( $options, $option_name = '' ) {
425423
$new_settings = array(); $new_single_setting = ''; // :)
426424

427425
// Get settings for option values is an array and it's in single option name for all settings
428-
if ( trim( $option_name ) != '' ) {
429-
global ${$option_name};
430-
426+
if ( trim( $option_name ) != '' ) {
431427
$default_settings = $this->get_settings_default( $options, $option_name );
432428

433429
$current_settings = get_option( $option_name );
@@ -437,7 +433,7 @@ public function get_settings( $options, $option_name = '' ) {
437433
$current_settings = array_map( array( $this, 'admin_stripslashes' ), $current_settings );
438434
$current_settings = apply_filters( $this->plugin_name . '_' . $option_name . '_get_settings' , $current_settings );
439435

440-
$$option_name = $current_settings;
436+
$GLOBALS[$option_name] = $current_settings;
441437

442438
}
443439

@@ -465,7 +461,6 @@ public function get_settings( $options, $option_name = '' ) {
465461
}
466462

467463
if ( trim( $option_name ) == '' || $value['separate_option'] != false ) {
468-
global ${$id_attribute};
469464

470465
$current_setting = get_option( $id_attribute, $value['default'] );
471466

@@ -496,7 +491,7 @@ public function get_settings( $options, $option_name = '' ) {
496491

497492
$current_setting = apply_filters( $this->plugin_name . '_' . $id_attribute . '_get_setting' , $current_setting );
498493

499-
$$id_attribute = $current_setting;
494+
$GLOBALS[$id_attribute] = $current_setting;
500495
}
501496
}
502497

@@ -515,7 +510,7 @@ public function get_settings( $options, $option_name = '' ) {
515510

516511
if ( trim( $option_name ) != '' ) {
517512
update_option( $option_name, $new_settings );
518-
$$option_name = $new_settings;
513+
$GLOBALS[$option_name] = $new_settings;
519514
}
520515

521516
foreach ( $options as $value ) {
@@ -543,7 +538,7 @@ public function get_settings( $options, $option_name = '' ) {
543538

544539
if ( trim( $option_name ) == '' || $value['separate_option'] != false ) {
545540
update_option( $id_attribute, $new_single_setting );
546-
$$id_attribute = $new_single_setting;
541+
$GLOBALS[$id_attribute] = $new_single_setting;
547542
}
548543
}
549544
}
@@ -1360,7 +1355,7 @@ public function settings_get_option( $option_name, $default = '' ) {
13601355
*/
13611356

13621357
public function admin_forms( $options, $form_key, $option_name = '', $form_messages = array() ) {
1363-
global ${$this->plugin_prefix.'fonts_face'}, ${$this->plugin_prefix.'uploader'}, $current_subtab;
1358+
global $current_subtab;
13641359

13651360
$new_settings = array(); $new_single_setting = ''; // :)
13661361
$admin_message = '';
@@ -1890,7 +1885,7 @@ class="a3rev-ui-onoff_checkbox a3rev-ui-onoff_google_api_key_enable"
18901885
<div class="a3rev-ui-google-api-key-description"><?php echo sprintf( __( "Enter your existing Google Fonts API Key below. Don't have a key? Visit <a href='%s' target='_blank'>Google Developer API</a> to create a key", 'a3-lazy-load' ), 'https://developers.google.com/fonts/docs/developer_api#APIKey' ); ?></div>
18911886
<div class="a3rev-ui-google-api-key-inside
18921887
<?php
1893-
if ( ${$this->plugin_prefix.'fonts_face'}->is_valid_google_api_key() ) {
1888+
if ( $GLOBALS[$this->plugin_prefix.'fonts_face']->is_valid_google_api_key() ) {
18941889
echo 'a3rev-ui-google-valid-key';
18951890
} elseif ( '' != $google_api_key ) {
18961891
echo 'a3rev-ui-google-unvalid-key';
@@ -2712,7 +2707,7 @@ class="a3rev-ui-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>-face
27122707
>
27132708
<optgroup label="<?php _e( '-- Default Fonts --', 'a3-lazy-load' ); ?>">
27142709
<?php
2715-
foreach ( ${$this->plugin_prefix.'fonts_face'}->get_default_fonts() as $val => $text ) {
2710+
foreach ( $GLOBALS[$this->plugin_prefix.'fonts_face']->get_default_fonts() as $val => $text ) {
27162711
?>
27172712
<option value="<?php echo esc_attr( $val ); ?>" <?php
27182713
selected( esc_attr( $val ), esc_attr( $face ) );
@@ -2723,7 +2718,7 @@ class="a3rev-ui-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>-face
27232718
</optgroup>
27242719
<optgroup label="<?php _e( '-- Google Fonts --', 'a3-lazy-load' ); ?>">
27252720
<?php
2726-
foreach ( ${$this->plugin_prefix.'fonts_face'}->get_google_fonts() as $font ) {
2721+
foreach ( $GLOBALS[$this->plugin_prefix.'fonts_face']->get_google_fonts() as $font ) {
27272722
?>
27282723
<option value="<?php echo esc_attr( $font['name'] ); ?>" <?php
27292724
selected( esc_attr( $font['name'] ), esc_attr( $face ) );
@@ -3396,7 +3391,7 @@ class="a3rev-ui-slider"
33963391
</th>
33973392
<td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>">
33983393
<?php echo $description; ?>
3399-
<?php echo ${$this->plugin_prefix.'uploader'}->upload_input( $name_attribute, $id_attribute, $option_value, $attachment_id, $value['default'], $value['name'], $class, esc_attr( $value['css'] ) , '', $strip_methods );?>
3394+
<?php echo $GLOBALS[$this->plugin_prefix.'uploader']->upload_input( $name_attribute, $id_attribute, $option_value, $attachment_id, $value['default'], $value['name'], $class, esc_attr( $value['css'] ) , '', $strip_methods );?>
34003395
</td>
34013396
</tr><?php
34023397

admin/admin-pages/admin-settings-page.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,12 @@ public function tabs_include() {
105105
/* Show Settings Page */
106106
/*-----------------------------------------------------------------------------------*/
107107
public function admin_settings_page() {
108-
global ${$this->plugin_prefix.'admin_init'};
109108

110-
${$this->plugin_prefix.'admin_init'}->admin_settings_page( $this->page_data() );
109+
$GLOBALS[$this->plugin_prefix.'admin_init']->admin_settings_page( $this->page_data() );
111110

112111
//$my_page_data = $this->page_data();
113112
//$my_page_data = array_values( $my_page_data );
114-
//${$this->plugin_prefix.'admin_init'}->admin_settings_page( $my_page_data[1] );
113+
//$GLOBALS[$this->plugin_prefix.'admin_init']->admin_settings_page( $my_page_data[1] );
115114
}
116115

117116
/*-----------------------------------------------------------------------------------*/

admin/admin-ui.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public function is_valid_google_map_api_key( $cache=true ) {
144144
// Check it is a valid request
145145
if ( ! is_wp_error( $respone_api ) ) {
146146

147-
$json_string = get_magic_quotes_gpc() ? stripslashes( $respone_api['body'] ) : $respone_api['body'];
147+
$json_string = version_compare( PHP_VERSION, '7.4', '>=' ) || get_magic_quotes_gpc() ? stripslashes( $respone_api['body'] ) : $respone_api['body'];
148148
$response_map = json_decode( $json_string, true );
149149

150150
// Make sure that the valid response from google is not an error message

admin/includes/fonts_face.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ public function is_valid_google_api_key( $cache=true ) {
451451
// Check it is a valid request
452452
if ( ! is_wp_error( $respone_api ) ) {
453453

454-
$json_string = get_magic_quotes_gpc() ? stripslashes( $respone_api['body'] ) : $respone_api['body'];
454+
$json_string = version_compare( PHP_VERSION, '7.4', '>=' ) || get_magic_quotes_gpc() ? stripslashes( $respone_api['body'] ) : $respone_api['body'];
455455
$response_fonts = json_decode( $json_string, true );
456456

457457
// Make sure that the valid response from google is not an error message
@@ -470,7 +470,7 @@ public function is_valid_google_api_key( $cache=true ) {
470470
$response = wp_remote_get( $this->admin_plugin_url() . '/assets/webfonts/webfonts.json', array( 'timeout' => 120 ) );
471471
$webfonts = wp_remote_retrieve_body( $response );
472472
if ( ! empty( $webfonts ) ) {
473-
$json_string = get_magic_quotes_gpc() ? stripslashes( $webfonts ) : $webfonts;
473+
$json_string = version_compare( PHP_VERSION, '7.4', '>=' ) || get_magic_quotes_gpc() ? stripslashes( $webfonts ) : $webfonts;
474474
$response_fonts = json_decode( $json_string, true );
475475
}
476476
}
@@ -524,7 +524,7 @@ public function is_valid_google_api_key( $cache=true ) {
524524
$response = wp_remote_get( $this->admin_plugin_url() . '/assets/webfonts/webfonts.json', array( 'timeout' => 120 ) );
525525
$webfonts = wp_remote_retrieve_body( $response );
526526
if ( ! empty( $webfonts ) ) {
527-
$json_string = get_magic_quotes_gpc() ? stripslashes( $webfonts ) : $webfonts;
527+
$json_string = version_compare( PHP_VERSION, '7.4', '>=' ) || get_magic_quotes_gpc() ? stripslashes( $webfonts ) : $webfonts;
528528
$response_fonts = json_decode( $json_string, true );
529529
}
530530
}

admin/less/lib/lessc.inc.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ protected function zipSetArgs($args, $orderedValues, $keywordValues) {
634634

635635
// check for a rest
636636
$last = end($args);
637-
if ($last[0] == "rest") {
637+
if ( ! is_bool( $last ) && $last[0] == "rest") {
638638
$rest = array_slice($orderedValues, count($args) - 1);
639639
$this->set($last[1], $this->reduce(array("list", " ", $rest)));
640640
}
@@ -719,7 +719,7 @@ protected function compileProp($prop, $block, $out) {
719719
if ($suffix !== null &&
720720
$subProp[0] == "assign" &&
721721
is_string($subProp[1]) &&
722-
$subProp[1]{0} != $this->vPrefix)
722+
$subProp[1][0] != $this->vPrefix)
723723
{
724724
$subProp[2] = array(
725725
'list', ' ',
@@ -1770,7 +1770,7 @@ protected function injectVariables($args) {
17701770
$this->pushEnv();
17711771
$parser = new a3_lessc_parser($this, __METHOD__);
17721772
foreach ($args as $name => $strValue) {
1773-
if ($name{0} != '@') $name = '@'.$name;
1773+
if ($name[0] != '@') $name = '@'.$name;
17741774
$parser->count = 0;
17751775
$parser->buffer = (string)$strValue;
17761776
if (!$parser->propertyValue($value)) {
@@ -2427,7 +2427,7 @@ protected function parseChunk() {
24272427
$hidden = true;
24282428
if (!isset($block->args)) {
24292429
foreach ($block->tags as $tag) {
2430-
if (!is_string($tag) || $tag{0} != $this->lessc->mPrefix) {
2430+
if (!is_string($tag) || $tag[0] != $this->lessc->mPrefix) {
24312431
$hidden = false;
24322432
break;
24332433
}
@@ -2481,7 +2481,7 @@ protected function isDirective($dirname, $directives) {
24812481
protected function fixTags($tags) {
24822482
// move @ tags out of variable namespace
24832483
foreach ($tags as &$tag) {
2484-
if ($tag{0} == $this->lessc->vPrefix)
2484+
if ($tag[0] == $this->lessc->vPrefix)
24852485
$tag[0] = $this->lessc->mPrefix;
24862486
}
24872487
return $tags;

admin/settings/template-settings/global-settings.php

+3-8
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ public function subtab_init() {
114114
/* Set default settings with function called from Admin Interface */
115115
/*-----------------------------------------------------------------------------------*/
116116
public function set_default_settings() {
117-
global ${$this->plugin_prefix.'admin_interface'};
118-
119-
${$this->plugin_prefix.'admin_interface'}->reset_settings( $this->form_fields, $this->option_name, false );
117+
$GLOBALS[$this->plugin_prefix.'admin_interface']->reset_settings( $this->form_fields, $this->option_name, false );
120118
}
121119

122120
/*-----------------------------------------------------------------------------------*/
@@ -136,9 +134,7 @@ public function after_save_settings() {
136134
/* Get settings with function called from Admin Interface */
137135
/*-----------------------------------------------------------------------------------*/
138136
public function get_settings() {
139-
global ${$this->plugin_prefix.'admin_interface'};
140-
141-
${$this->plugin_prefix.'admin_interface'}->get_settings( $this->form_fields, $this->option_name );
137+
$GLOBALS[$this->plugin_prefix.'admin_interface']->get_settings( $this->form_fields, $this->option_name );
142138
}
143139

144140
/**
@@ -182,10 +178,9 @@ public function add_subtab( $subtabs_array ) {
182178
/* Call the form from Admin Interface
183179
/*-----------------------------------------------------------------------------------*/
184180
public function settings_form() {
185-
global ${$this->plugin_prefix.'admin_interface'};
186181

187182
$output = '';
188-
$output .= ${$this->plugin_prefix.'admin_interface'}->admin_forms( $this->form_fields, $this->form_key, $this->option_name, $this->form_messages );
183+
$output .= $GLOBALS[$this->plugin_prefix.'admin_interface']->admin_forms( $this->form_fields, $this->form_key, $this->option_name, $this->form_messages );
189184

190185
return $output;
191186
}

admin/tabs/template-settings/global-settings-tab.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,7 @@ public function tab_manager() {
123123
$a3_lazy_load_global_settings_panel->settings_form();
124124
$this->plugin_extension_end();
125125

126-
//global ${$this->plugin_prefix.'admin_init'};
127-
128-
//${$this->plugin_prefix.'admin_init'}->admin_settings_tab( $this->parent_page, $this->tab_data() );
126+
//$GLOBALS[$this->plugin_prefix.'admin_init']->admin_settings_tab( $this->parent_page, $this->tab_data() );
129127

130128
}
131129
}

readme.txt

+11-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Contributors: a3rev, a3rev Software, nguyencongtuan
33
Tags: a3 lazy load, Lazy Loading, image lazy load, lazyload
44
Requires at least: 4.9
55
Tested up to: 5.3.2
6-
Stable tag: 2.3.0
6+
Stable tag: 2.3.1
77
License: GPLv3
88
License URI: http://www.gnu.org/licenses/gpl-3.0.html
99

@@ -204,6 +204,13 @@ Filter tags to add to class name of theme to exclude lazy load on images or vide
204204

205205
== Changelog ==
206206

207+
= 2.3.1 - 2020/02/29 =
208+
* This maintenance release contains various PHP code updates to resolve PHP warnings and depreciations in PHP 7.0 to 7.4
209+
* Fix - Update global ${$this- to $GLOBALS[$this to resolve 7.0+ PHP warnings
210+
* Fix - Update global ${$option} to $GLOBALS[$option] to resolve 7.0+ PHP warnings
211+
* Fix - Update less PHP lib that use square brackets [] instead of curly braces {} for Array , depreciated in PHP 7.4
212+
* Fix - Validate for do not use get_magic_quotes_gpc function for PHP 7.4
213+
207214
= 2.3.0 - 2020/02/25 =
208215
* This feature release adds support for horizontal scroll images plus a bug fix for compatibility with Revolution Slider
209216
* Feature - Add support for lazy loading images in a container that have horizontal scroll
@@ -480,6 +487,9 @@ Filter tags to add to class name of theme to exclude lazy load on images or vide
480487

481488
== Upgrade Notice ==
482489

490+
= 2.3.1 =
491+
This maintenance release contains various PHP code updates to resolve PHP warnings and depreciations in PHP 7.0 to 7.4
492+
483493
= 2.3.0 =
484494
This feature release adds support for horizontal scroll images plus a bug fix for compatibility with Revolution Slider
485495

0 commit comments

Comments
 (0)