From 60fe77cc9f15de09dd305e84cf46a26df5d03e6c Mon Sep 17 00:00:00 2001 From: savvasha Date: Wed, 28 Apr 2021 08:09:35 +0300 Subject: [PATCH] Create a function to support custom flags --- includes/sp-core-functions.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index cad4706c..68039349 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -1715,3 +1715,22 @@ function sp_has_shortcodes( $content, $tags ) { } return false; } + +/** + * Check if a custom flag was uploaded from the user + * @return bool + */ +function sp_flags( $nationality ) { + $nationality = strtolower( $nationality ); + $flag = ''; + global $wpdb; + $flag_post_id = intval( $wpdb->get_var( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value LIKE '%/$nationality'" ) ); + if ( $flag_post_id ) { + $flag_src = wp_get_attachment_image_url( $flag_post_id, 'thumbnail', false ); + $flag = '' . $nationality . ''; + }else{ + $flag = '' . $nationality . ''; + } + + return $flag; +}