-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmetatag_response.php
98 lines (85 loc) · 1.85 KB
/
metatag_response.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
if(!defined('e107_INIT'))
{
exit;
}
/**
* Extends core response handler class.
*/
class metatag_response extends eResponse
{
/**
* Mute method so that core and other plugins cannot add meta tag via e107::meta().
*/
public function addMeta($name = null, $content = null, $extended = array())
{
// Allow only if "metatag" plugin wants to add it.
if(isset($extended['plugin']) && $extended['plugin'] == 'metatag')
{
unset($extended['plugin']);
$this->_addMeta($name, $content, $extended);
}
return $this;
}
/**
* Generic meta information.
*
* Example usage:
* addMeta('og:title', 'My Title');
* addMeta(null, 30, array('http-equiv' => 'refresh'));
* addMeta(null, null, array('http-equiv' => 'refresh', 'content' => 30)); // same as above
*
* @param string $name
* 'name' attribute value, or null to avoid it
* @param string $content
* 'content' attribute value, or null to avoid it
* @param array $extended
* format 'attribute_name' => 'value'
* @return eResponse
*/
public function _addMeta($name = null, $content = null, $extended = array())
{
$attr = array();
if(null !== $name)
{
if(!in_array($name, $this->_meta_name_only))
{
// Giving both should be valid and avoid issues with FB and others.
$attr['property'] = $name;
}
if(!in_array($name, $this->_meta_property_only))
{
$attr['name'] = $name;
}
}
if(null !== $content)
{
$attr['content'] = $content;
}
if(!empty($extended))
{
if(!empty($attr))
{
$attr = array_merge($attr, $extended);
}
else
{
$attr = $extended;
}
}
if(!empty($attr))
{
// Prevent multiple keyword tags.
if($name && !in_array($name, $this->_meta_multiple))
{
$this->_meta[$name] = $attr;
}
// Multiple allowed.
else
{
$this->_meta[] = $attr;
}
}
return $this;
}
}