Skip to content

Commit

Permalink
Update social-meta-tags.php
Browse files Browse the repository at this point in the history
- Modify code in order to use AboutMe plugin or Values from plugin according configuration
- Use summary for description meta-tags instead content
  • Loading branch information
clemdesign authored Jun 3, 2017
1 parent 3e3859b commit 81cb88c
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions social-meta-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private function getTwitterCardMetatags($meta){
if (!isset($meta['twitter:description'])) {
$meta['twitter:description']['name'] = 'twitter:description';
$meta['twitter:description']['property'] = 'twitter:description';
$meta['twitter:description']['content'] = $this->sanitizeMarkdowns($this->grav['page']->value('content'));
$meta['twitter:description']['content'] = $this->sanitizeMarkdowns(strip_tags($this->grav['page']->summary()));
}

if (!isset($meta['twitter:image'])) {
Expand All @@ -88,14 +88,28 @@ private function getTwitterCardMetatags($meta){
}

if (!isset($meta['twitter:site'])) {
if ($this->grav['config']->get('plugins.aboutme.social_pages.enabled')
and $this->grav['config']->get('plugins.aboutme.social_pages.pages.twitter.url')
) {
$user = preg_replace('((http|https)://twitter.com/)', '@', $this->grav['config']->get('plugins.aboutme.social_pages.pages.twitter.url'));
$meta['twitter:site']['name'] = 'twitter:site';
$meta['twitter:site']['property'] = 'twitter:site';
$meta['twitter:site']['content'] = $user;
//Use AboutMe plugin configuration
if ($this->grav['config']->get('plugins.social-meta-tags.social_pages.pages.twitter.aboutme'))
{
if ($this->grav['config']->get('plugins.aboutme.social_pages.enabled')
and $this->grav['config']->get('plugins.aboutme.social_pages.pages.twitter.url'))
{
$user = preg_replace('((http|https)://twitter.com/)', '@', $this->grav['config']->get('plugins.aboutme.social_pages.pages.twitter.url'));
}
else
{
$user = "";
}
}
//Use plugin self-configuration
else
{
$user = "@".$this->grav['config']->get('plugins.social-meta-tags.social_pages.pages.twitter.username');
}
//Update data
$meta['twitter:site']['name'] = 'twitter:site';
$meta['twitter:site']['property'] = 'twitter:site';
$meta['twitter:site']['content'] = $user;
}
}
return $meta;
Expand All @@ -115,7 +129,7 @@ private function getFacebookMetatags($meta){

$meta['og:description']['name'] = 'og:description';
$meta['og:description']['property'] = 'og:description';
$meta['og:description']['content'] = $this->sanitizeMarkdowns($this->grav['page']->value('content'));
$meta['og:description']['content'] = $this->sanitizeMarkdowns(strip_tags($this->grav['page']->summary()));

$meta['og:type']['name'] = 'og:type';
$meta['og:type']['property'] = 'og:type';
Expand Down

0 comments on commit 81cb88c

Please sign in to comment.