Allow twitter cards per page.
This commit is contained in:
parent
17d2c3cb08
commit
cb490c0eac
@ -734,6 +734,64 @@ function getStructuredData($type, $data = array())
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return HTML content to add as header card for an article, news or Blog Post or home page.
|
||||||
|
*
|
||||||
|
* @param array $params Array of parameters
|
||||||
|
* @return string HTML content
|
||||||
|
*/
|
||||||
|
function getSocialNetworkHeaderCards($params = null)
|
||||||
|
{
|
||||||
|
global $conf, $db, $hookmanager, $langs, $mysoc, $user, $website, $websitepage, $weblangs; // Very important. Required to have var available when running inluded containers.
|
||||||
|
|
||||||
|
$out = '';
|
||||||
|
|
||||||
|
if ($website->virtualhost) {
|
||||||
|
$pageurl = $websitepage->pageurl;
|
||||||
|
$title = $websitepage->title;
|
||||||
|
$image = $websitepage->image;
|
||||||
|
$companyname = $mysoc->name;
|
||||||
|
$description = $websitepage->description;
|
||||||
|
|
||||||
|
$pageurl = str_replace('__WEBSITE_KEY__', $website->ref, $pageurl);
|
||||||
|
$title = str_replace('__WEBSITE_KEY__', $website->ref, $title);
|
||||||
|
$image = '/medias'.(preg_match('/^\//', $image) ? '' : '/').str_replace('__WEBSITE_KEY__', $website->ref, $image);
|
||||||
|
$companyname = str_replace('__WEBSITE_KEY__', $website->ref, $companyname);
|
||||||
|
$description = str_replace('__WEBSITE_KEY__', $website->ref, $description);
|
||||||
|
|
||||||
|
$fullurl = $website->virtualhost.'/'.$websitepage->pageurl.'.php';
|
||||||
|
$hashtags = trim(join(' #', array_map('trim', explode(',', $websitepage->keywords))));
|
||||||
|
|
||||||
|
// Twitter
|
||||||
|
$out .= '<meta name="twitter:card" content="summary">'."\n";
|
||||||
|
if (!empty($params) && !empty($params['twitter_account'])) {
|
||||||
|
$out .= '<meta name="twitter:site" content="@'.$params['twitter_account'].'">'."\n";
|
||||||
|
$out .= '<meta name="twitter:creator" content="@'.$params['twitter_account'].'">'."\n";
|
||||||
|
}
|
||||||
|
$out .= '<meta name="twitter:title" content="'.$websitepage->title.'">'."\n";
|
||||||
|
if ($websitepage->description) {
|
||||||
|
$out .= '<meta name="twitter:description" content="'.$websitepage->description.'">'."\n";
|
||||||
|
}
|
||||||
|
if ($websitepage->image) {
|
||||||
|
$out .= '<meta name="twitter:image:src" content="'.$website->virtualhost.$image.'">'."\n";
|
||||||
|
}
|
||||||
|
//$out .= '<meta name="twitter:domain" content="'.getDomainFromURL($website->virtualhost, 1).'">';
|
||||||
|
/*
|
||||||
|
$out .= '<meta name="twitter:app:name:iphone" content="">';
|
||||||
|
$out .= '<meta name="twitter:app:name:ipad" content="">';
|
||||||
|
$out .= '<meta name="twitter:app:name:googleplay" content="">';
|
||||||
|
$out .= '<meta name="twitter:app:url:iphone" content="">';
|
||||||
|
$out .= '<meta name="twitter:app:url:ipad" content="">';
|
||||||
|
$out .= '<meta name="twitter:app:url:googleplay" content="">';
|
||||||
|
$out .= '<meta name="twitter:app:id:iphone" content="">';
|
||||||
|
$out .= '<meta name="twitter:app:id:ipad" content="">';
|
||||||
|
$out .= '<meta name="twitter:app:id:googleplay" content="">';
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return HTML content to add structured data for an article, news or Blog Post.
|
* Return HTML content to add structured data for an article, news or Blog Post.
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user