a3 Lazy Load - Version 1.2.2

Version Description

Important Maintenance Upgrade. 2 x major a3rev Plugin Framework Security Hardening Tweaks

Download this release

Release Info

Developer a3rev
Plugin Icon 128x128 a3 Lazy Load
Version 1.2.2
Comparing to
See all releases

Code changes from version 1.2.1 to 1.2.2

a3-lazy-load.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: a3 Lazy Load
4
  Description: Speed up your site and enhance frontend user's visual experience in PC's, Tablets and mobile with a3 Lazy Load.
5
- Version: 1.2.1
6
  Author: a3 Revolution
7
  Author URI: http://www.a3rev.com/
8
  Requires at least: 3.8
2
  /*
3
  Plugin Name: a3 Lazy Load
4
  Description: Speed up your site and enhance frontend user's visual experience in PC's, Tablets and mobile with a3 Lazy Load.
5
+ Version: 1.2.2
6
  Author: a3 Revolution
7
  Author URI: http://www.a3rev.com/
8
  Requires at least: 3.8
admin/a3-lazy-load-admin.php CHANGED
@@ -2,7 +2,7 @@
2
  update_option('a3rev_lazy_load_plugin', 'a3_lazy_load');
3
 
4
  function a3_lazy_load_activated(){
5
- update_option('a3_lazy_load_version', '1.2.1');
6
 
7
  // Set Settings Default from Admin Init
8
  global $a3_lazy_load_admin_init;
@@ -51,6 +51,6 @@ function a3_lazy_load_upgrade_plugin() {
51
  update_option('a3_lazy_load_version', '1.1.0');
52
  }
53
 
54
- update_option('a3_lazy_load_version', '1.2.1');
55
  }
56
  ?>
2
  update_option('a3rev_lazy_load_plugin', 'a3_lazy_load');
3
 
4
  function a3_lazy_load_activated(){
5
+ update_option('a3_lazy_load_version', '1.2.2');
6
 
7
  // Set Settings Default from Admin Init
8
  global $a3_lazy_load_admin_init;
51
  update_option('a3_lazy_load_version', '1.1.0');
52
  }
53
 
54
+ update_option('a3_lazy_load_version', '1.2.2');
55
  }
56
  ?>
admin/less/compile_less_sass_class.php CHANGED
@@ -8,6 +8,7 @@ class Compile_Less_Sass {
8
  }
9
 
10
  public function compileLessFile( $less_file = '', $css_file = '', $css_min_file = '' ){
 
11
 
12
  if( empty( $less_file ) )
13
  $less_file = dirname( __FILE__ ) . '/assets/css/style.less';
@@ -16,9 +17,6 @@ class Compile_Less_Sass {
16
  if( empty( $css_min_file ) )
17
  $css_min_file = dirname( __FILE__ ) . '/assets/css/style.min.css';
18
 
19
- //@chmod( $css_file, 0777 );
20
- //@chmod( $css_min_file, 0777 );
21
-
22
  // Write less file
23
  if ( is_writable( $css_file ) && is_writable( $css_min_file ) ) {
24
 
@@ -36,11 +34,11 @@ class Compile_Less_Sass {
36
  $compiled_css = $less->compileFile( $less_file );
37
 
38
  if ( $compiled_css != '' ){
39
- file_put_contents( $css_file, $compiled_css );
40
-
41
  $compiled_css_min = CssMin::minify( $compiled_css );
42
  if ( $compiled_css_min != '' )
43
- file_put_contents( $css_min_file, $compiled_css_min );
44
  }
45
 
46
  } catch ( exception $ex ) {
8
  }
9
 
10
  public function compileLessFile( $less_file = '', $css_file = '', $css_min_file = '' ){
11
+ global $wp_filesystem;
12
 
13
  if( empty( $less_file ) )
14
  $less_file = dirname( __FILE__ ) . '/assets/css/style.less';
17
  if( empty( $css_min_file ) )
18
  $css_min_file = dirname( __FILE__ ) . '/assets/css/style.min.css';
19
 
 
 
 
20
  // Write less file
21
  if ( is_writable( $css_file ) && is_writable( $css_min_file ) ) {
22
 
34
  $compiled_css = $less->compileFile( $less_file );
35
 
36
  if ( $compiled_css != '' ){
37
+ $wp_filesystem->put_contents( $css_file, $compiled_css );
38
+
39
  $compiled_css_min = CssMin::minify( $compiled_css );
40
  if ( $compiled_css_min != '' )
41
+ $wp_filesystem->put_contents( $css_min_file, $compiled_css_min );
42
  }
43
 
44
  } catch ( exception $ex ) {
admin/less/index.php DELETED
@@ -1,27 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml">
3
- <head>
4
- <?php
5
- function sass_compile_less_mincss(){
6
-
7
- include( dirname( __FILE__ ) . '/compile_less_sass_class.php' );
8
-
9
- $less_file = dirname( __FILE__ ) . '/assets/css/style.less';
10
- $css_file = dirname( __FILE__ ) . '/assets/css/style.css';
11
- $css_min_file = dirname( __FILE__ ) . '/assets/css/style.min.css';
12
-
13
- $compile = new Compile_Less_Sass;
14
-
15
- $compile->compileLessFile( $less_file, $css_file, $css_min_file );
16
- }
17
- sass_compile_less_mincss();
18
- ?>
19
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
20
- <title>SASS PHP</title>
21
- <link media="screen" href="./assets/css/style.min.css" type="text/css" rel="stylesheet">
22
- </head>
23
-
24
- <body>
25
- <p element-id="3466" class="pvc_stats pvc_load_by_ajax_update" id="pvc_stats_3466">3,894&nbsp;total views, 1&nbsp;views today</p>
26
- </body>
27
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
admin/less/lib/lessc.inc.php CHANGED
@@ -1814,6 +1814,7 @@ class lessc {
1814
  }
1815
 
1816
  public function compileFile($fname, $outFname = null) {
 
1817
  if (!is_readable($fname)) {
1818
  throw new Exception('load error: failed to find '.$fname);
1819
  }
@@ -1832,7 +1833,7 @@ class lessc {
1832
  $this->importDir = $oldImport;
1833
 
1834
  if ($outFname !== null) {
1835
- return file_put_contents($outFname, $out);
1836
  }
1837
 
1838
  return $out;
1814
  }
1815
 
1816
  public function compileFile($fname, $outFname = null) {
1817
+ global $wp_filesystem;
1818
  if (!is_readable($fname)) {
1819
  throw new Exception('load error: failed to find '.$fname);
1820
  }
1833
  $this->importDir = $oldImport;
1834
 
1835
  if ($outFname !== null) {
1836
+ return $wp_filesystem->put_contents($outFname, $out);
1837
  }
1838
 
1839
  return $out;
admin/less/sass.php CHANGED
@@ -31,16 +31,36 @@ class A3_Lazy_Load_Less
31
  $sass = $this->sass_content_data();
32
  $this->plugin_compile_less_mincss( $sass );
33
  }
 
 
 
34
 
35
  public function plugin_compile_less_mincss( $sass, $css_file_name = '' )
36
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  @ini_set( 'display_errors', false );
38
  $_upload_dir = wp_upload_dir();
39
- @chmod($_upload_dir['basedir'], 0755);
40
- if (!is_dir($_upload_dir['basedir'] . '/sass')) {
41
- @mkdir($_upload_dir['basedir'] . '/sass', 0755);
42
  } else {
43
- @chmod($_upload_dir['basedir'] . '/sass', 0755);
44
  }
45
 
46
  if ( trim( $css_file_name ) == '' ) $css_file_name = $this->css_file_name;
@@ -54,16 +74,16 @@ class A3_Lazy_Load_Less
54
  $filename = $css_file_name;
55
 
56
  if (!file_exists($_upload_dir['basedir'] . '/sass/' . $filename . '.less')) {
57
- @file_put_contents($_upload_dir['basedir'] . '/sass/' . $filename . '.less', '');
58
- @file_put_contents($_upload_dir['basedir'] . '/sass/' . $filename . '.css', '');
59
- @file_put_contents($_upload_dir['basedir'] . '/sass/' . $filename . '.min.css', '');
60
  }
61
 
62
  $mixins = $this->css_file_name . '_mixins';
63
  if( !file_exists( $_upload_dir['basedir'].'/sass/'.$mixins.'.less' ) ){
64
  $mixinsless = $this->plugin_dir.'/admin/less/assets/css/mixins.less';
65
  $a3rev_mixins_less = $_upload_dir['basedir'].'/sass/'.$mixins.'.less';
66
- @copy($mixinsless, $a3rev_mixins_less);
67
  }
68
 
69
  $files = array_diff(scandir($_upload_dir['basedir'] . '/sass'), array(
@@ -72,7 +92,7 @@ class A3_Lazy_Load_Less
72
  ));
73
  if ($files) {
74
  foreach ($files as $file) {
75
- @chmod($_upload_dir['basedir'] . '/sass/' . $file, 0644);
76
  }
77
  }
78
 
@@ -95,7 +115,7 @@ class A3_Lazy_Load_Less
95
 
96
  if (!class_exists('Compile_Less_Sass'))
97
  include( dirname( __FILE__ ) . '/compile_less_sass_class.php');
98
- file_put_contents($less_file, $sass_data);
99
  $css_file = $_upload_dir['basedir'] . '/sass/' . $filename . '.css';
100
  $css_min_file = $_upload_dir['basedir'] . '/sass/' . $filename . '.min.css';
101
  $compile = new Compile_Less_Sass;
31
  $sass = $this->sass_content_data();
32
  $this->plugin_compile_less_mincss( $sass );
33
  }
34
+ public function custom_filesystem_method( $method = '') {
35
+ return 'direct';
36
+ }
37
 
38
  public function plugin_compile_less_mincss( $sass, $css_file_name = '' )
39
  {
40
+ // just filter when compile less file
41
+ add_filter( 'filesystem_method', array( $this, 'custom_filesystem_method' ) );
42
+
43
+ $form_url = wp_nonce_url( esc_url( add_query_arg( 'compile-sass', 'true' ) ), 'compile-sass' );
44
+
45
+ if ( false === ( $creds = request_filesystem_credentials( $form_url, '', false, false, null ) ) ) {
46
+ return true;
47
+ }
48
+
49
+ if ( ! WP_Filesystem( $creds ) ) {
50
+ // our credentials were no good, ask the user for them again
51
+ request_filesystem_credentials( $form_url, '', true );
52
+ return true;
53
+ }
54
+
55
+ global $wp_filesystem;
56
+
57
  @ini_set( 'display_errors', false );
58
  $_upload_dir = wp_upload_dir();
59
+ $wp_filesystem->chmod($_upload_dir['basedir'], 0755);
60
+ if (! $wp_filesystem->is_dir($_upload_dir['basedir'] . '/sass')) {
61
+ $wp_filesystem->mkdir($_upload_dir['basedir'] . '/sass', 0755);
62
  } else {
63
+ $wp_filesystem->chmod($_upload_dir['basedir'] . '/sass', 0755);
64
  }
65
 
66
  if ( trim( $css_file_name ) == '' ) $css_file_name = $this->css_file_name;
74
  $filename = $css_file_name;
75
 
76
  if (!file_exists($_upload_dir['basedir'] . '/sass/' . $filename . '.less')) {
77
+ $wp_filesystem->put_contents($_upload_dir['basedir'] . '/sass/' . $filename . '.less', '', 0644 );
78
+ $wp_filesystem->put_contents($_upload_dir['basedir'] . '/sass/' . $filename . '.css', '', 0644);
79
+ $wp_filesystem->put_contents($_upload_dir['basedir'] . '/sass/' . $filename . '.min.css', '', 0644);
80
  }
81
 
82
  $mixins = $this->css_file_name . '_mixins';
83
  if( !file_exists( $_upload_dir['basedir'].'/sass/'.$mixins.'.less' ) ){
84
  $mixinsless = $this->plugin_dir.'/admin/less/assets/css/mixins.less';
85
  $a3rev_mixins_less = $_upload_dir['basedir'].'/sass/'.$mixins.'.less';
86
+ $wp_filesystem->copy($mixinsless, $a3rev_mixins_less, true );
87
  }
88
 
89
  $files = array_diff(scandir($_upload_dir['basedir'] . '/sass'), array(
92
  ));
93
  if ($files) {
94
  foreach ($files as $file) {
95
+ $wp_filesystem->chmod($_upload_dir['basedir'] . '/sass/' . $file, 0644);
96
  }
97
  }
98
 
115
 
116
  if (!class_exists('Compile_Less_Sass'))
117
  include( dirname( __FILE__ ) . '/compile_less_sass_class.php');
118
+ $wp_filesystem->put_contents($less_file, $sass_data, 0644);
119
  $css_file = $_upload_dir['basedir'] . '/sass/' . $filename . '.css';
120
  $css_min_file = $_upload_dir['basedir'] . '/sass/' . $filename . '.min.css';
121
  $compile = new Compile_Less_Sass;
readme.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: a3rev, A3 Revolution Software Development team
4
  Tags: a3 lazy load, Lazy Loading , image lazy load, lazyload
5
  Requires at least: 4.0
6
  Tested up to: 4.2.2
7
- Stable tag: 1.2.1
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -144,6 +144,10 @@ Automatic installation is the easiest option as WordPress handles the file trans
144
 
145
  == Changelog ==
146
 
 
 
 
 
147
  = 1.2.1 - 2015/05/26 =
148
  * Fix - Update url of dynamic stylesheet in uploads folder to the format <code>//domain.com/</code> so it's always is correct when loaded as <code>http</code> or <code>https</code>
149
  * Credit - Thanks to WordPress member hero12 for bringing the matter [to our attention](https://wordpress.org/support/topic/css-is-not-loaded-properly-on-https?replies=1).
@@ -195,6 +199,9 @@ Automatic installation is the easiest option as WordPress handles the file trans
195
 
196
  == Upgrade Notice ==
197
 
 
 
 
198
  = 1.2.1 =
199
  Maintenance Upgrade. 1 bug fix for dynamic stylesheets loaded over secure https protocol.
200
 
4
  Tags: a3 lazy load, Lazy Loading , image lazy load, lazyload
5
  Requires at least: 4.0
6
  Tested up to: 4.2.2
7
+ Stable tag: 1.2.2
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
144
 
145
  == Changelog ==
146
 
147
+ = 1.2.2 - 2015/06/03 =
148
+ * Tweak - Security Hardening. Removed all php file_put_contents functions in the plugin framework and replace with the WP_Filesystem API
149
+ * Tweak - Security Hardening. Removed all php file_get_contents functions in the plugin framework and replace with the WP_Filesystem API
150
+
151
  = 1.2.1 - 2015/05/26 =
152
  * Fix - Update url of dynamic stylesheet in uploads folder to the format <code>//domain.com/</code> so it's always is correct when loaded as <code>http</code> or <code>https</code>
153
  * Credit - Thanks to WordPress member hero12 for bringing the matter [to our attention](https://wordpress.org/support/topic/css-is-not-loaded-properly-on-https?replies=1).
199
 
200
  == Upgrade Notice ==
201
 
202
+ = 1.2.2 =
203
+ Important Maintenance Upgrade. 2 x major a3rev Plugin Framework Security Hardening Tweaks
204
+
205
  = 1.2.1 =
206
  Maintenance Upgrade. 1 bug fix for dynamic stylesheets loaded over secure https protocol.
207