Browse Source

Move code block placed in the wrong condition in previous commit - Fix twitter:site meta not appearing in badges page - refs BT#11048

Yannick Warnier 9 years ago
parent
commit
658fb16d41
1 changed files with 14 additions and 9 deletions
  1. 14 9
      main/inc/lib/template.lib.php

+ 14 - 9
main/inc/lib/template.lib.php

@@ -976,26 +976,31 @@ class Template
         $metaTitle = api_get_setting('meta_title');
         if (!empty($metaTitle)) {
             $socialMeta .= '<meta name="twitter:card" content="summary" />' . "\n";
+            $metaSite = api_get_setting('meta_twitter_site');
+            if (!empty($metaSite)) {
+                $socialMeta .= '<meta name="twitter:site" content="' . $metaSite . '" />' . "\n";
+                $metaCreator = api_get_setting('meta_twitter_creator');
+                if (!empty($metaCreator)) {
+                    $socialMeta .= '<meta name="twitter:creator" content="' . $metaCreator . '" />' . "\n";
+                }
+            }
 
-            // The following code is for user badge page if the twitter:card is enable
+            // The user badge page emits its own meta tags, so if this is
+            // enabled, ignore the global ones
             $userId = isset($_GET['user']) ? intval($_GET['user']) : 0;
             $skillId = isset($_GET['skill']) ? intval($_GET['skill']) : 0;
 
             if (!$userId && !$skillId) {
+                // no combination of user and skill ID has been defined,
+                // so print the normal OpenGraph meta tags
                 $socialMeta .= '<meta property="og:title" content="' . $metaTitle . '" />' . "\n";
                 $socialMeta .= '<meta property="og:url" content="' . api_get_path(WEB_PATH) . '" />' . "\n";
+
                 $metaDescription = api_get_setting('meta_description');
                 if (!empty($metaDescription)) {
                     $socialMeta .= '<meta property="og:description" content="' . $metaDescription . '" />' . "\n";
                 }
-                $metaSite = api_get_setting('meta_twitter_site');
-                if (!empty($metaSite)) {
-                    $socialMeta .= '<meta name="twitter:site" content="' . $metaSite . '" />' . "\n";
-                    $metaCreator = api_get_setting('meta_twitter_creator');
-                    if (!empty($metaCreator)) {
-                        $socialMeta .= '<meta name="twitter:creator" content="' . $metaCreator . '" />' . "\n";
-                    }
-                }
+
                 $metaImage = api_get_setting('meta_image_path');
                 if (!empty($metaImage)) {
                     if (is_file(api_get_path(SYS_PATH) . $metaImage)) {