From 16d6927a9beea02c9925afc435526cd1ab313230 Mon Sep 17 00:00:00 2001 From: Dennis Ploetner Date: Fri, 16 Aug 2024 10:56:26 +0200 Subject: [PATCH] Use 'include' instead of 's' in case that the input is numeric --- includes/MslsMetaBox.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/includes/MslsMetaBox.php b/includes/MslsMetaBox.php index 48876498..701dcd0a 100644 --- a/includes/MslsMetaBox.php +++ b/includes/MslsMetaBox.php @@ -35,9 +35,14 @@ public static function suggest() { } if ( MslsRequest::has_var( MslsFields::FIELD_S, INPUT_POST ) ) { - $args['s'] = sanitize_text_field( + $value_s = sanitize_text_field( MslsRequest::get_var( MslsFields::FIELD_S, INPUT_POST ) ); + + /** + * If the value is numeric, we assume it is a post ID + */ + is_numeric( $value_s ) ? $args['include'] = array( $value_s ) : $args['s'] = $value_s; } $json = self::get_suggested_fields( $json, $args );