mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 21:57:51 +02:00
Set og:url and twitter:url when e107::canonical is called. Twitter card meta added to news posts and pages.
This commit is contained in:
@@ -4013,11 +4013,15 @@ class eResponse
|
|||||||
protected $_META_KEYWORDS = array();
|
protected $_META_KEYWORDS = array();
|
||||||
protected $_render_mod = array('default' => 'default');
|
protected $_render_mod = array('default' => 'default');
|
||||||
protected $_meta_title_separator = ' - ';
|
protected $_meta_title_separator = ' - ';
|
||||||
protected $_meta_name_only = array('keywords', 'viewport', 'robots'); // Keep FB happy.
|
protected $_meta_name_only = array(
|
||||||
|
'keywords', 'viewport', 'robots', 'twitter:url', 'twitter:title', 'twitter:card',
|
||||||
|
'twitter:image', 'twitter:description',
|
||||||
|
); // Keep FB happy.
|
||||||
protected $_meta_property_only = array( // Keep FB happy.
|
protected $_meta_property_only = array( // Keep FB happy.
|
||||||
'article:section', 'article:tag', 'article:modified_time',
|
'article:section', 'article:tag', 'article:published_time', 'article:modified_time',
|
||||||
'og:description', 'og:image', 'og:title', 'og:updated_time',
|
'og:description', 'og:image', 'og:title', 'og:updated_time','og:url'
|
||||||
);
|
);
|
||||||
|
protected $_meta_multiple = array('og:image', 'og:image:width','twitter:image');
|
||||||
protected $_meta = array();
|
protected $_meta = array();
|
||||||
protected $_meta_robot_types = array('noindex'=>'NoIndex', 'nofollow'=>'NoFollow','noarchive'=>'NoArchive','noimageindex'=>'NoImageIndex' );
|
protected $_meta_robot_types = array('noindex'=>'NoIndex', 'nofollow'=>'NoFollow','noarchive'=>'NoArchive','noimageindex'=>'NoImageIndex' );
|
||||||
protected $_title_separator = ' » ';
|
protected $_title_separator = ' » ';
|
||||||
@@ -4404,11 +4408,11 @@ class eResponse
|
|||||||
|
|
||||||
if(!empty($attr))
|
if(!empty($attr))
|
||||||
{
|
{
|
||||||
if($name === 'keywords' || $name === 'og:title') // prevent multiple keyword tags.
|
if(!in_array($name, $this->_meta_multiple)) // prevent multiple keyword tags.
|
||||||
{
|
{
|
||||||
$this->_meta[$name] = $attr;
|
$this->_meta[$name] = $attr;
|
||||||
}
|
}
|
||||||
else
|
else // multiple allowed.
|
||||||
{
|
{
|
||||||
$this->_meta[] = $attr;
|
$this->_meta[] = $attr;
|
||||||
}
|
}
|
||||||
|
@@ -4004,11 +4004,11 @@ class e107
|
|||||||
{
|
{
|
||||||
if($plugin === '_RESET_') // for testing only, may be removed in future.
|
if($plugin === '_RESET_') // for testing only, may be removed in future.
|
||||||
{
|
{
|
||||||
e107::setRegistry('core/e107/canonical');
|
self::setRegistry('core/e107/canonical');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$alreadyDone = e107::getRegistry('core/e107/canonical');
|
$alreadyDone = self::getRegistry('core/e107/canonical');
|
||||||
|
|
||||||
if(empty($plugin))
|
if(empty($plugin))
|
||||||
{
|
{
|
||||||
@@ -4023,13 +4023,15 @@ class e107
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$url = e107::url($plugin, $key, $row, array('mode' => 'full'));
|
$url = self::url($plugin, $key, $row, array('mode' => 'full'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($url))
|
if(!empty($url))
|
||||||
{
|
{
|
||||||
self::getJs()->addLink(array('rel'=>"canonical", "href" => $url));
|
self::getJs()->addLink(array('rel'=>"canonical", "href" => $url));
|
||||||
e107::setRegistry('core/e107/canonical', $url);
|
self::meta('og:url', $url);
|
||||||
|
self::meta('twitter:url', $url);
|
||||||
|
self::setRegistry('core/e107/canonical', $url);
|
||||||
$message = "Debug: Setting Canonical URL: <b><a href='".$url."'>".$url."</a></b>";
|
$message = "Debug: Setting Canonical URL: <b><a href='".$url."'>".$url."</a></b>";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4059,13 +4061,13 @@ class e107
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$addon = e107::getAddon($plugin,'e_url'))
|
if(!$addon = self::getAddon($plugin,'e_url'))
|
||||||
{
|
{
|
||||||
trigger_error("Couldn't load e_url for ".$plugin);
|
trigger_error("Couldn't load e_url for ".$plugin);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$result = e107::callMethod($addon, 'config'))
|
if(!$result = self::callMethod($addon, 'config'))
|
||||||
{
|
{
|
||||||
trigger_error($plugin.' - e_url::config() method returned nothing');
|
trigger_error($plugin.' - e_url::config() method returned nothing');
|
||||||
return null;
|
return null;
|
||||||
|
@@ -654,11 +654,13 @@ class news_front
|
|||||||
{
|
{
|
||||||
e107::meta('description',$news['news_meta_description']);
|
e107::meta('description',$news['news_meta_description']);
|
||||||
e107::meta('og:description',$news['news_meta_description']);
|
e107::meta('og:description',$news['news_meta_description']);
|
||||||
|
e107::meta('twitter:description',$news['news_meta_description']);
|
||||||
//define('META_DESCRIPTION', $news['news_meta_description']); // deprecated
|
//define('META_DESCRIPTION', $news['news_meta_description']); // deprecated
|
||||||
}
|
}
|
||||||
elseif($news['news_summary']) // BC compatibility
|
elseif($news['news_summary']) // BC compatibility
|
||||||
{
|
{
|
||||||
e107::meta('og:description',$news['news_summary']);
|
e107::meta('og:description', $news['news_summary']);
|
||||||
|
e107::meta('twitter:description', $news['news_summary']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// include news-thumbnail/image in meta. - always put this one first.
|
// include news-thumbnail/image in meta. - always put this one first.
|
||||||
@@ -672,8 +674,11 @@ class news_front
|
|||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
e107::meta('og:image',$tp->thumbUrl($mimg,'w=1200',false,true) );
|
$metaImg = $tp->thumbUrl($mimg,'w=1200',false,true) ;
|
||||||
|
e107::meta('og:image',$metaImg);
|
||||||
e107::meta('og:image:width', 1200);
|
e107::meta('og:image:width', 1200);
|
||||||
|
e107::meta('twitter:image', $metaImg);
|
||||||
|
e107::meta('twitter:card', 'summary_large_image');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -700,10 +705,6 @@ class news_front
|
|||||||
$c++;
|
$c++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$url = e107::getUrl()->create('news/view/item', $news,'full=1');
|
|
||||||
e107::meta('og:url',$url);
|
|
||||||
$modifiedTime = strtotime('30 minutes ago');
|
$modifiedTime = strtotime('30 minutes ago');
|
||||||
e107::meta('og:updated_time', $modifiedTime);
|
e107::meta('og:updated_time', $modifiedTime);
|
||||||
|
|
||||||
|
12
page.php
12
page.php
@@ -735,9 +735,9 @@ class pageClass
|
|||||||
$this->batch->setVars($this->page);
|
$this->batch->setVars($this->page);
|
||||||
$this->batch->breadcrumb();
|
$this->batch->breadcrumb();
|
||||||
|
|
||||||
|
$metaTitle = eHelper::formatMetaTitle($this->page['page_title']);
|
||||||
e107::title(eHelper::formatMetaTitle($this->page['page_title']));
|
e107::title($metaTitle);
|
||||||
|
e107::meta('twitter:title', $metaTitle);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -757,6 +757,7 @@ class pageClass
|
|||||||
$metaDiz = eHelper::formatMetaDescription($this->page['page_metadscr']);
|
$metaDiz = eHelper::formatMetaDescription($this->page['page_metadscr']);
|
||||||
define('META_DESCRIPTION', $metaDiz);
|
define('META_DESCRIPTION', $metaDiz);
|
||||||
e107::meta('og:description', $metaDiz);
|
e107::meta('og:description', $metaDiz);
|
||||||
|
e107::meta('twitter:description', $metaDiz);
|
||||||
}
|
}
|
||||||
|
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
@@ -765,11 +766,15 @@ class pageClass
|
|||||||
{
|
{
|
||||||
$mimg = $tp->thumbUrl($this->page['page_metaimage'],'w=1200', false, true);
|
$mimg = $tp->thumbUrl($this->page['page_metaimage'],'w=1200', false, true);
|
||||||
e107::meta('og:image',$mimg);
|
e107::meta('og:image',$mimg);
|
||||||
|
e107::meta('twitter:image', $mimg);
|
||||||
|
e107::meta('twitter:card', 'summary_large_image');
|
||||||
}
|
}
|
||||||
elseif($tp->isImage($this->page['menu_image']))
|
elseif($tp->isImage($this->page['menu_image']))
|
||||||
{
|
{
|
||||||
$mimg = $tp->thumbUrl($this->page['menu_image'],'w=1200', false, true);
|
$mimg = $tp->thumbUrl($this->page['menu_image'],'w=1200', false, true);
|
||||||
e107::meta('og:image',$mimg);
|
e107::meta('og:image',$mimg);
|
||||||
|
e107::meta('twitter:image', $mimg);
|
||||||
|
e107::meta('twitter:card', 'summary_large_image');
|
||||||
}
|
}
|
||||||
|
|
||||||
$images = e107::getBB()->getContent('img',$this->pageText);
|
$images = e107::getBB()->getContent('img',$this->pageText);
|
||||||
@@ -777,6 +782,7 @@ class pageClass
|
|||||||
{
|
{
|
||||||
$im = $tp->ampEncode($im);
|
$im = $tp->ampEncode($im);
|
||||||
e107::meta('og:image',($im));
|
e107::meta('og:image',($im));
|
||||||
|
e107::meta('twitter:image', $im);
|
||||||
}
|
}
|
||||||
|
|
||||||
e107::meta('og:updated_time', strtotime('10 minutes ago'));
|
e107::meta('og:updated_time', strtotime('10 minutes ago'));
|
||||||
|
Reference in New Issue
Block a user