cleanup + fail in php < 5.2 + log tune
Peter Molnar hello@petermolnar.eu
Tue, 05 Jan 2016 22:58:44 +0000
3 files changed,
19 insertions(+),
5 deletions(-)
M
composer.json
→
composer.json
@@ -2,7 +2,7 @@ {
"name": "petermolnar/wp-resized2cache", "description": "WordPress plugin to auto-move and enhance resized jpgs to cache folder", "require": { - "php": ">=5.3.0", + "php": ">=5.3.0", "ext-imagick": "^3.1" }, "license": "GPLv3",@@ -10,7 +10,7 @@ "authors": [
{ "name": "Peter Molnar", "email": "hello@petermolnar.eu", - "homepage": "https://petermolnar.eu" + "homepage": "https://petermolnar.eu" } ] }
M
readme.txt
→
readme.txt
@@ -1,6 +1,6 @@
=== wp-resized2cache === Contributors: cadeyrn -Donate link: +Donate link: https://paypal.me/petermolnar/3 Tags: image, cache, image quality, Requires at least: 3.0 Tested up to: 4.4
M
wp-resited2cache.php
→
wp-resited2cache.php
@@ -33,6 +33,8 @@
const cachedir = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'cache'; public function __construct () { + register_activation_hook( __FILE__ , array( &$this, 'plugin_activate' ) ); + if (!is_dir(static::cachedir)) { if (!mkdir(static::cachedir)) { static::debug('failed to create ' . static::cachedir);@@ -54,6 +56,16 @@
} /** + * activate hook + */ + public static function plugin_activate() { + if ( version_compare( phpversion(), 5.3, '<' ) ) { + die( 'The minimum PHP version required for this plugin is 5.3' ); + } + } + + + /** * called on attachment deletion and takes care of removing the moved files * */@@ -110,8 +122,10 @@ */
$size = @getimagesize($resized); - if ( !$size ) + if ( !$size ) { + static::debug("Unable to get size"); return $resized; + } //$cachedir = WP_CONTENT_DIR . DIRECTORY_SEPARATOR . 'cache';@@ -191,4 +205,4 @@ }
$WP_RESIZED2CACHE = new WP_RESIZED2CACHE(); -endif;+endif;