mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Don't overwrite OpenGraph tags already set by user
This commit is contained in:
parent
be1fbc9d65
commit
367e7440be
2 changed files with 40 additions and 23 deletions
|
|
@ -2764,6 +2764,7 @@ class Context
|
|||
public static function setCanonicalURL($url)
|
||||
{
|
||||
self::$_instance->canonical_url = escape($url, false);
|
||||
self::addOpenGraphData('og:url', self::$_instance->canonical_url);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -457,40 +457,56 @@ class HTMLDisplayHandler
|
|||
}
|
||||
}
|
||||
|
||||
// Get existing metadata.
|
||||
$og_data = array();
|
||||
foreach (Context::getOpenGraphData() as $val)
|
||||
{
|
||||
$og_data[$val['property']] = $val['content'];
|
||||
}
|
||||
|
||||
// Add basic metadata.
|
||||
Context::addOpenGraphData('og:title', $permitted ? Context::getBrowserTitle() : lang('msg_not_permitted'));
|
||||
Context::addOpenGraphData('og:site_name', Context::getSiteTitle());
|
||||
if ($page_type === 'article' && $permitted && config('seo.og_extract_description'))
|
||||
if (!isset($og_data['og:description']) || !Context::getMetaTag('description'))
|
||||
{
|
||||
$description = trim(utf8_normalize_spaces($oDocument->getContentText(200)));
|
||||
if ($page_type === 'article' && $permitted && config('seo.og_extract_description'))
|
||||
{
|
||||
$description = trim(utf8_normalize_spaces($oDocument->getContentText(200)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$description = Context::getMetaTag('description');
|
||||
}
|
||||
Context::addOpenGraphData('og:description', $description);
|
||||
Context::addMetaTag('description', $description);
|
||||
}
|
||||
else
|
||||
{
|
||||
$description = Context::getMetaTag('description');
|
||||
}
|
||||
Context::addOpenGraphData('og:description', $description);
|
||||
Context::addMetaTag('description', $description);
|
||||
|
||||
// Add metadata about this page.
|
||||
Context::addOpenGraphData('og:type', $page_type);
|
||||
if ($page_type === 'article')
|
||||
if (!isset($og_data['og:type']))
|
||||
{
|
||||
$canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'document_srl', $document_srl);
|
||||
Context::addOpenGraphData('og:type', $page_type);
|
||||
}
|
||||
elseif (($page = Context::get('page')) > 1)
|
||||
if (!isset($og_data['og:url']) || !Context::getCanonicalURL())
|
||||
{
|
||||
$canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'page', $page);
|
||||
if ($page_type === 'article')
|
||||
{
|
||||
$canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'document_srl', $document_srl);
|
||||
}
|
||||
elseif (($page = Context::get('page')) > 1)
|
||||
{
|
||||
$canonical_url = getFullUrl('', 'mid', $current_module_info->mid, 'page', $page);
|
||||
}
|
||||
elseif ($current_module_info->module_srl == $site_module_info->module_srl)
|
||||
{
|
||||
$canonical_url = getFullUrl('');
|
||||
}
|
||||
else
|
||||
{
|
||||
$canonical_url = getFullUrl('', 'mid', $current_module_info->mid);
|
||||
}
|
||||
Context::addOpenGraphData('og:url', $canonical_url);
|
||||
Context::setCanonicalURL($canonical_url);
|
||||
}
|
||||
elseif ($current_module_info->module_srl == $site_module_info->module_srl)
|
||||
{
|
||||
$canonical_url = getFullUrl('');
|
||||
}
|
||||
else
|
||||
{
|
||||
$canonical_url = getFullUrl('', 'mid', $current_module_info->mid);
|
||||
}
|
||||
Context::addOpenGraphData('og:url', $canonical_url);
|
||||
Context::setCanonicalURL($canonical_url);
|
||||
|
||||
// Add metadata about the locale.
|
||||
$lang_type = Context::getLangType();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue