Fix Twitter:card conflict with OpenGraph meta in user badge page - Refs #10992

1.10.x
José Loguercio 10 years ago
parent 7df8f87875
commit 9554dbf76f
  1. 7
      main/badge/issued.php
  2. 43
      main/inc/lib/template.lib.php
  3. 8
      main/newscorm/learnpath.class.php
  4. 4
      main/newscorm/lp_final_item.php

@ -59,8 +59,15 @@ $skillInfo = [
'courses' => []
];
// Open Graph Markup
$htmlHeadXtra[] = "
<script>
$(document).ready(function () {
$('meta[name=description]').remove();
});
</script>
<meta property='og:type' content='article' />
<meta property='og:title' content='".sprintf(get_lang('IHaveObtainedSkillXOnY'), $skillInfo['name'], api_get_setting('siteName'))."' />
<meta property='og:url' content='".api_get_path(WEB_PATH)."badge/".$skillId."/user/".$userId."' />

@ -976,25 +976,32 @@ class Template
$metaTitle = api_get_setting('meta_title');
if (!empty($metaTitle)) {
$socialMeta .= '<meta name="twitter:card" content="summary" />' . "\n";
$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";
// The following code is for user badge page if the twitter:card is enable
$userId = isset($_GET['user']) ? intval($_GET['user']) : 0;
$skillId = isset($_GET['skill']) ? intval($_GET['skill']) : 0;
if (!$userId && !$skillId) {
$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";
}
}
$metaImage = api_get_setting('meta_image_path');
if (!empty($metaImage)) {
if (is_file(api_get_path(SYS_PATH) . $metaImage)) {
$path = api_get_path(WEB_PATH) . $metaImage;
$socialMeta .= '<meta property="og:image" content="' . $path . '" />' . "\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)) {
$path = api_get_path(WEB_PATH) . $metaImage;
$socialMeta .= '<meta property="og:image" content="' . $path . '" />' . "\n";
}
}
}
}

@ -5603,9 +5603,6 @@ class learnpath
$_SESSION['pathItem'] = $arrLP[$i]['path'];
}
if (($i % 2) == 0) {
$oddClass = 'row_odd';
} else {
@ -6386,12 +6383,13 @@ class learnpath
// Get all the links.
$links = $this->get_links();
// Get al the student publications.
// Get all the student publications.
$works = $this->get_student_publications();
// Get al the forums.
// Get all the forums.
$forums = $this->get_forums(null, $course_code);
// Get the final item form (see BT#11048) .
$finish = $this->getFinalItemForm();
$headers = array(

@ -9,8 +9,8 @@ api_protect_course_script(true);
$courseCode = api_get_course_id();
$userId = api_get_user_id();
$sessionId = api_get_session_id();
$id = isset($_GET['id']) ? $_GET['id'] : 0;
$lpId = isset($_GET['lp_id']) ? $_GET['lp_id'] : 0;
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$lpId = isset($_GET['lp_id']) ? intval($_GET['lp_id']) : 0;
if (!$id && !$lpId) {
Display::display_warning_message(get_lang('FileNotFound'));

Loading…
Cancel
Save