From d3fdd1881079170c04e27664925d4c7857f45862 Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Tue, 5 Jan 2016 22:56:51 +0000 Subject: [PATCH] fine tune of logs + fail in php < 5.2 --- readme.txt | 2 +- wp-featured2rss.php | 23 +++++++++++++---------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/readme.txt b/readme.txt index 2bc493f..f8dadc4 100644 --- a/readme.txt +++ b/readme.txt @@ -19,7 +19,7 @@ It's strictly only using resized images to maintain compatibility in case access == Installation == -1. Upload contents of `wp-featured2rss` to the `/wp-content/plugins/` directory +1. Upload contents of `wp-featured2rss.zip` to the `/wp-content/plugins/` directory 2. Activate the plugin through the `Plugins` menu in WordPress == Frequently Asked Questions == diff --git a/wp-featured2rss.php b/wp-featured2rss.php index b394065..3600df9 100644 --- a/wp-featured2rss.php +++ b/wp-featured2rss.php @@ -32,10 +32,19 @@ class WP_FEATURED2RSS { const expire = 30; public function __construct () { - + register_activation_hook( __FILE__ , array( &$this, 'plugin_activate' ) ); add_action( 'rss2_item', array(&$this,'insert_enclosure_image') ); } + /** + * 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' ); + } + } + /** * */ @@ -43,7 +52,7 @@ class WP_FEATURED2RSS { $post = static::fix_post(); - static::debug('insterting featured image to rss'); + //static::debug('insterting featured image to rss'); if ($post === false ) return false; @@ -55,12 +64,6 @@ class WP_FEATURED2RSS { if ( $cached = wp_cache_get ( $thid, __CLASS__ . __FUNCTION__ ) ) return $cached; - $sizes = array ( - 0 => 'large', - 1 => 'medium', - 2 => 'thumbnail' - ); - $asize = false; $meta = wp_get_attachment_metadata($thid); @@ -76,10 +79,10 @@ class WP_FEATURED2RSS { arsort($candidates); foreach ($candidates as $potential => $maxsize ) { - static::debug('checking size ' . $potential . ': ' . $meta['sizes'][$potential]['file'] . ' vs ' .$meta['file'] ); + //static::debug('checking size ' . $potential . ': ' . $meta['sizes'][$potential]['file'] . ' vs ' .$meta['file'] ); if (isset($meta['sizes'][$potential]) && isset($meta['sizes'][$potential]['file']) && $meta['sizes'][$potential]['file'] != $meta['file']) { - static::debug( $meta['sizes'][$potential]['file'] . ' look like a resized file, using it'); + //static::debug( $meta['sizes'][$potential]['file'] . ' look like a resized file, using it'); $asize = $potential; $img = wp_get_attachment_image_src( $thid, $potential ); break;