cleanup + fail in php < 5.2 + log tune
This commit is contained in:
parent
03d5b738a7
commit
b46481d78f
3 changed files with 19 additions and 5 deletions
|
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
endif;
|
||||
|
|
Loading…
Reference in a new issue