From cc8ca1f91a011c97fc8a53599a5a982a9423dd73 Mon Sep 17 00:00:00 2001 From: Fellan-91 Date: Tue, 16 Jul 2024 11:42:13 +0300 Subject: [PATCH] fixed gallery issue if image was removed from media library --- classes/class-get-portfolio.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/classes/class-get-portfolio.php b/classes/class-get-portfolio.php index ab1ad149..92bbfa55 100644 --- a/classes/class-get-portfolio.php +++ b/classes/class-get-portfolio.php @@ -1215,10 +1215,12 @@ public static function sort_array_by_field( $array, $field, $order = 'desc' ) { $array, function ( $a, $b ) use ( $field, $order ) { // Primary comparison by field values. - $comparsion = 'asc' === $order ? strcmp( $a[ $field ], $b[ $field ] ) : strcmp( $b[ $field ], $a[ $field ] ); + if ( isset( $a[ $field ] ) && isset( $b[ $field ] ) ) { + $comparsion = 'asc' === $order ? strcmp( $a[ $field ], $b[ $field ] ) : strcmp( $b[ $field ], $a[ $field ] ); - if ( 0 !== $comparsion ) { - return $comparsion; + if ( 0 !== $comparsion ) { + return $comparsion; + } } // Secondary comparison by keys when values are equal.