Skip to content

Commit

Permalink
Using 'break' outside of a loop or switch structure is invalid and wi…
Browse files Browse the repository at this point in the history
…ll throw a fatal error since PHP 7.0
  • Loading branch information
deeptiboddapati committed Feb 17, 2017
1 parent 10c729e commit ee7c615
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ function cfct_get_adjacent_image_link($prev = true) {

$attachments = array_values(get_children( array('post_parent' => $post->post_parent, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') ));

foreach ( $attachments as $k => $attachment )
if ( $attachment->ID == $post->ID )
foreach ( $attachments as $k => $attachment ) {
if ( $attachment->ID == $post->ID ) {
break;
}


$k = $prev ? $k - 1 : $k + 1;

if ( isset($attachments[$k]) )
return wp_get_attachment_link($attachments[$k]->ID, 'thumbnail', true);
}
}

/**
Expand Down

0 comments on commit ee7c615

Please sign in to comment.