From 061ee89f293d368156e34236281dfd6a05712bd6 Mon Sep 17 00:00:00 2001 From: Ralf Albert Date: Thu, 16 May 2013 00:21:59 +0200 Subject: [PATCH] fix issue with post ID --- gallery-zip.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/gallery-zip.php b/gallery-zip.php index 60650ec..6abc48a 100644 --- a/gallery-zip.php +++ b/gallery-zip.php @@ -118,27 +118,28 @@ public static function gallery_zip_shortcode( $atts ) { self::get_gallery_images_from_shortcode( $post->ID, $atts ); $output = gallery_shortcode( $post->ID, $atts ); - $gallery_id = count( self::$images[$post->ID] ) - 1; + $gallery_id = ( isset( self::$images[$post->ID] ) ) ? + count( self::$images[$post->ID] ) - 1 : 0; $output .= sprintf( '
%s
', $gallery_id, $post->ID, __( 'Get as Zip' ) ); return $output; } - protected static function get_gallery_images_from_shortcode( $id, $atts ) { + protected static function get_gallery_images_from_shortcode( $post_id, $atts ) { // use the post ID if the attribute 'ids' is not set or empty $id = ( ! isset( $atts['ids'] ) || empty( $atts['ids'] ) ) ? - (int) $id : $atts['ids']; + (int) $post_id : $atts['ids']; $exclude = ( isset( $atts['exclude'] ) && ! empty( $atts['exclude'] ) ) ? $atts['exclude'] : ''; - if ( ! isset( self::$images[$id] ) || ! is_array( self::$images[$id] ) ) - self::$images[$id] = array(); + if ( ! isset( self::$images[$post_id] ) || ! is_array( self::$images[$post_id] ) ) + self::$images[$post_id] = array(); $images = self::get_gallery_images( $id, $exclude ); - array_push( self::$images[$id], $images ); + array_push( self::$images[$post_id], $images ); return $images; }