From 5a4f19f0853922ced2c0cbd8a05bb8f7781cae63 Mon Sep 17 00:00:00 2001 From: Ian Svoboda Date: Fri, 6 Dec 2024 13:12:20 -0500 Subject: [PATCH] Allow meta handler to properly handle non-single meta --- includes/class-meta-handler.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/class-meta-handler.php b/includes/class-meta-handler.php index 413787da8..8c4da5878 100644 --- a/includes/class-meta-handler.php +++ b/includes/class-meta-handler.php @@ -207,7 +207,12 @@ public static function get_meta( $id, $key, $single_only = true, $callable = nul ); if ( is_numeric( $id ) ) { - $meta = $pre_value ? $pre_value : call_user_func( $callable, $id, $parent_name, true ); + $meta = $pre_value ? $pre_value : call_user_func( $callable, $id, $parent_name, $single_only ); + + // If it's an array with only one item, return it directly. + if ( is_array( $meta ) && 1 === count( $meta ) ) { + $meta = $meta[0]; + } } else { $meta = $pre_value ? $pre_value : call_user_func( $callable, $parent_name ); }