Skip to content

Commit

Permalink
Properly handle when $GLOBALS['post'] isn't set.
Browse files Browse the repository at this point in the history
  • Loading branch information
georgestephanis committed Apr 21, 2017
1 parent a185020 commit 834df00
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions class.jetpack-post-images.php
Expand Up @@ -109,10 +109,16 @@ static function from_gallery( $post_id ) {
* See core ticket:
* https://core.trac.wordpress.org/ticket/39304
*/
$juggle_post = $GLOBALS['post'];
$GLOBALS['post'] = $post;
$galleries = get_post_galleries( $post->ID, false );
$GLOBALS['post'] = $juggle_post;
if ( isset( $GLOBALS['post'] ) ) {
$juggle_post = $GLOBALS['post'];
$GLOBALS['post'] = $post;
$galleries = get_post_galleries( $post->ID, false );
$GLOBALS['post'] = $juggle_post;
} else {
$GLOBALS['post'] = $post;
$galleries = get_post_galleries( $post->ID, false );
unset( $GLOBALS['post'] );
}

foreach ( $galleries as $gallery ) {
if ( isset( $gallery['type'] ) && 'slideshow' === $gallery['type'] && ! empty( $gallery['ids'] ) ) {
Expand Down

0 comments on commit 834df00

Please sign in to comment.