From ee7c61507359d008740c471d1c13a37fa0112578 Mon Sep 17 00:00:00 2001 From: deeptiboddapati Date: Fri, 17 Feb 2017 13:08:21 -0600 Subject: [PATCH] Using 'break' outside of a loop or switch structure is invalid and will throw a fatal error since PHP 7.0 --- attachment.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/attachment.php b/attachment.php index 6f4f103..3926d6c 100644 --- a/attachment.php +++ b/attachment.php @@ -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); + } } /**