From: Laury GvR Date: Wed, 12 Apr 2017 13:17:36 +0000 (-0400) Subject: Added Files container to fronthooks markup X-Git-Tag: v1.0.0^2~29 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=ea900fc7ea3f0516efc2897b0c2bf970d0fdf2e9;p=WP-Plugins%2Fglm-member-db-fields.git Added Files container to fronthooks markup The Files container div to be displayed on the member detail page is now a part of the filter created in fronthooks to allow us to only show it if there are indeed any files associated with this member. --- diff --git a/setup/frontHooks.php b/setup/frontHooks.php index 7621148..c88e399 100644 --- a/setup/frontHooks.php +++ b/setup/frontHooks.php @@ -46,11 +46,19 @@ add_filter('glm-member-db-front-members-detail-files', function( $content, $id) $file_path =GLM_MEMBERS_PLUGIN_MEDIA_URL. "/files/"; $sql = "SELECT name, file_name,caption FROM " . GLM_MEMBERS_PLUGIN_DB_PREFIX ."files WHERE ref_dest = $id;"; $results = $this->wpdb->get_results($sql); - - foreach($results as $result){ - $caption = ($result->caption !== '' ? $result->caption : $result->name); - $file = "" .$caption .''; - $content .= $file; + if ($results) { + $content .= "
Files
+
"; + foreach($results as $result){ + $caption = ($result->caption !== '' ? $result->caption : $result->name); + $file = "" .$caption .''; + $content .= $file; + } + $content .= ""; + $content .= "
"; } return $content;