-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMetaTags.php
63 lines (51 loc) · 1.66 KB
/
MetaTags.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace SocialMarkupTags;
include_once __DIR__ . "/OpenGraph.php";
include_once __DIR__ . "/TwitterCard.php";
class MetaTags extends \stdClass
{
public $og;
public $tc;
public function __construct($siteName, $title, $url, $type, $description)
{
$this->og = new OpenGraph($siteName, $title, $url, $type, $description);
$this->tc = TwitterCard::summary($title, $description, $url);
}
public function as_html_meta_tags()
{
return $this->og->as_html_meta_tags() . PHP_EOL . $this->tc->as_html_meta_tags();
}
public function article($pubDate = 'now', $updated = 'now', $expires = '+5 Years')
{
return new ArticleWrapper($this, $pubDate, $updated, $expires);
}
public function locale($locale)
{
$this->og->locale($locale);
}
}
class ArticleWrapper extends \stdClass
{
public function __construct($metaTags, $pubDate = 'now', $updated = 'now', $expires = '+5 Years')
{
$this->metaTags = $metaTags;
$this->article = $metaTags->og->article($pubDate, $updated, $expires);
}
public function authors($comma_separated_list_of_all_authors_url)
{
$this->article->authors(func_get_args());
}
public function image($url, $width = 0, $height = 0, $type='', $secure_url = null)
{
$this->metaTags->og->image($url, $width, $height, $type, $secure_url);
$this->metaTags->tc->image( $url, $width, $height);
}
public function section($section_name)
{
$this->article->section($section_name);
}
public function tags($comma_separated_list_of_all_tags)
{
$this->article->tags(func_get_args());
}
}