fine tune of logs + fail in php < 5.2

This commit is contained in:
Peter Molnar 2016-01-05 22:56:51 +00:00
parent cda95507ce
commit d3fdd18810
2 changed files with 14 additions and 11 deletions

View file

@ -19,7 +19,7 @@ It's strictly only using resized images to maintain compatibility in case access
== Installation == == 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 2. Activate the plugin through the `Plugins` menu in WordPress
== Frequently Asked Questions == == Frequently Asked Questions ==

View file

@ -32,10 +32,19 @@ class WP_FEATURED2RSS {
const expire = 30; const expire = 30;
public function __construct () { public function __construct () {
register_activation_hook( __FILE__ , array( &$this, 'plugin_activate' ) );
add_action( 'rss2_item', array(&$this,'insert_enclosure_image') ); 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(); $post = static::fix_post();
static::debug('insterting featured image to rss'); //static::debug('insterting featured image to rss');
if ($post === false ) if ($post === false )
return false; return false;
@ -55,12 +64,6 @@ class WP_FEATURED2RSS {
if ( $cached = wp_cache_get ( $thid, __CLASS__ . __FUNCTION__ ) ) if ( $cached = wp_cache_get ( $thid, __CLASS__ . __FUNCTION__ ) )
return $cached; return $cached;
$sizes = array (
0 => 'large',
1 => 'medium',
2 => 'thumbnail'
);
$asize = false; $asize = false;
$meta = wp_get_attachment_metadata($thid); $meta = wp_get_attachment_metadata($thid);
@ -76,10 +79,10 @@ class WP_FEATURED2RSS {
arsort($candidates); arsort($candidates);
foreach ($candidates as $potential => $maxsize ) { 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']) { 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; $asize = $potential;
$img = wp_get_attachment_image_src( $thid, $potential ); $img = wp_get_attachment_image_src( $thid, $potential );
break; break;