From 8510c6e8a6b2199651d8b9705a587fd5b77e87de Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Tue, 8 Mar 2016 13:45:02 +0000 Subject: [PATCH] name fix + better debugging --- readme.txt | 9 +++++-- wp-resited2cache.php => wp-resized2cache.php | 26 ++++++++++---------- 2 files changed, 20 insertions(+), 15 deletions(-) rename wp-resited2cache.php => wp-resized2cache.php (90%) diff --git a/readme.txt b/readme.txt index 715c07e..330903d 100644 --- a/readme.txt +++ b/readme.txt @@ -3,8 +3,8 @@ Contributors: cadeyrn Donate link: https://paypal.me/petermolnar/3 Tags: image, cache, image quality, Requires at least: 3.0 -Tested up to: 4.4 -Stable tag: 0.2 +Tested up to: 4.4.2 +Stable tag: 0.2.1 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html Required minimum PHP version: 5.3 @@ -40,6 +40,11 @@ Version numbering logic: * every .B version indicates new features. * every ..C indicates bugfixes for A.B version. += 0.2.1 = +*2016-03-08* + +* better debugging + = 0.2 = *2016-03-01* diff --git a/wp-resited2cache.php b/wp-resized2cache.php similarity index 90% rename from wp-resited2cache.php rename to wp-resized2cache.php index 4fc172e..cde4b52 100644 --- a/wp-resited2cache.php +++ b/wp-resized2cache.php @@ -3,7 +3,7 @@ Plugin Name: wp-resized2cache Plugin URI: https://github.com/petermolnar/wp-resized2cache Description: Sharpen, enchance and move resized images to cache folder -Version: 0.2 +Version: 0.2.1 Author: Peter Molnar Author URI: http://petermolnar.eu/ License: GPLv3 @@ -37,7 +37,7 @@ class WP_RESIZED2CACHE { if (!is_dir(static::cachedir)) { if (!mkdir(static::cachedir)) { - static::debug('failed to create ' . static::cachedir); + static::debug('failed to create ' . static::cachedir, 4); } } @@ -70,7 +70,7 @@ class WP_RESIZED2CACHE { * */ public static function delete_from_cache ( $aid = null ) { - static::debug( "DELETE is called and aid is: " . $aid ); + static::debug( "DELETE is called and aid is: " . $aid, 5 ); if ($aid === null) return false; @@ -83,7 +83,7 @@ class WP_RESIZED2CACHE { foreach ( $meta['sizes'] as $size => $data ) { $file = static::cachedir . DIRECTORY_SEPARATOR . $data['file']; if ( isset($data['file']) && is_file($file)) { - static::debug( " removing " . $file ); + static::debug( " removing " . $file, 5 ); unlink ($file); } } @@ -107,7 +107,7 @@ class WP_RESIZED2CACHE { static public function sharpen( $resized ) { if (!class_exists('Imagick')) { - static::debug('Please install Imagick extension; otherwise this plugin will not work as well as it should.'); + static::debug('Please install Imagick extension; otherwise this plugin will not work as well as it should.', 4); } /* @@ -123,7 +123,7 @@ class WP_RESIZED2CACHE { $size = @getimagesize($resized); if ( !$size ) { - static::debug("Unable to get size"); + static::debug("Unable to get size for: {$resized}", 4); return $resized; } @@ -133,7 +133,7 @@ class WP_RESIZED2CACHE { $cached = static::cachedir . DIRECTORY_SEPARATOR . $fname; if ( $size[2] == IMAGETYPE_JPEG && class_exists('Imagick')) { - static::debug( "adaptive sharpen " . $resized ); + static::debug( "adaptive sharpen " . $resized, 6 ); try { $imagick = new Imagick($resized); $imagick->unsharpMaskImage(0,0.5,1,0); @@ -145,22 +145,22 @@ class WP_RESIZED2CACHE { $imagick->destroy(); } catch (Exception $e) { - static::debug( 'something went wrong with imagemagick: ', $e->getMessage() ); + static::debug( 'something went wrong with imagemagick: ', $e->getMessage(), 4 ); return $resized; } - static::debug( "removing " . $resized ); + static::debug( "removing " . $resized, 5 ); unlink ($resized); } else { - static::debug( "moving " . $cached ); + static::debug( "moving " . $cached, 5 ); if (copy( $resized, $cached)) { - static::debug( "removing " . $resized ); + static::debug( "removing " . $resized, 5 ); unlink( $resized ); } else { - static::debug( "\tmove failed, passing on this" ); + static::debug( "\tmove failed, passing on this", 4 ); } } @@ -203,7 +203,7 @@ class WP_RESIZED2CACHE { // in case WordPress debug log has a minimum level if ( defined ( 'WP_DEBUG_LEVEL' ) ) { $wp_level = $levels [ WP_DEBUG_LEVEL ]; - if ( $level_ < $wp_level ) { + if ( $level_ > $wp_level ) { return false; } }