fine tune of logs + fail in php < 5.2
Peter Molnar hello@petermolnar.eu
Tue, 05 Jan 2016 22:56:51 +0000
2 files changed,
14 insertions(+),
11 deletions(-)
M
readme.txt
→
readme.txt
@@ -19,7 +19,7 @@ It's strictly only using resized images to maintain compatibility in case access to the full size image is blocked for various reasons (like not wanting people to be able to access it).
== 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 ==
M
wp-featured2rss.php
→
wp-featured2rss.php
@@ -32,18 +32,27 @@ 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' ); + } + } + + /** * */ public static function insert_enclosure_image ( ) { $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 @@
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 @@ }
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;