From b46481d78f45318d4032e4f57c1cda0067799486 Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Tue, 5 Jan 2016 22:58:44 +0000 Subject: [PATCH] cleanup + fail in php < 5.2 + log tune --- composer.json | 4 ++-- readme.txt | 2 +- wp-resited2cache.php | 18 ++++++++++++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 0bb7166..63f62e0 100644 --- a/composer.json +++ b/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 @@ { "name": "Peter Molnar", "email": "hello@petermolnar.eu", - "homepage": "https://petermolnar.eu" + "homepage": "https://petermolnar.eu" } ] } diff --git a/readme.txt b/readme.txt index 66364b9..45434d4 100644 --- a/readme.txt +++ b/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 diff --git a/wp-resited2cache.php b/wp-resited2cache.php index 59a43a7..5c47316 100644 --- a/wp-resited2cache.php +++ b/wp-resited2cache.php @@ -33,6 +33,8 @@ class WP_RESIZED2CACHE { 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); @@ -53,6 +55,16 @@ class WP_RESIZED2CACHE { } + /** + * 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 @@ class WP_RESIZED2CACHE { $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 @@ class WP_RESIZED2CACHE { $WP_RESIZED2CACHE = new WP_RESIZED2CACHE(); -endif; \ No newline at end of file +endif;