1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace XoopsModules\Publisher\Common; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class META TAGS |
7
|
|
|
* |
8
|
|
|
* @author Salih Andıç |
9
|
|
|
* @web http://www.salihandic.com/ |
10
|
|
|
* @mail [email protected] |
11
|
|
|
* @date 20 November 2018 |
12
|
|
|
*/ |
13
|
|
|
final class Meta |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @param string $locale_code |
17
|
|
|
* @return string |
18
|
|
|
*/ |
19
|
|
|
public static function getStatik($locale_code) |
20
|
|
|
{ |
21
|
|
|
return ' |
22
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> |
23
|
|
|
<meta charset="UTF-8"/> |
24
|
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> |
25
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/> |
26
|
|
|
<meta name="robots" content="index,follow"/> |
27
|
|
|
<meta name="revisit-after" content="1 days"/> |
28
|
|
|
<meta name="referrer" content="origin-when-cross-origin"/> |
29
|
|
|
<meta name="locale" content="' . $locale_code . '">'; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return string |
34
|
|
|
*/ |
35
|
|
|
public static function getRobot() |
36
|
|
|
{ |
37
|
|
|
return ' |
38
|
|
|
<meta name="robots" content="all"/> |
39
|
|
|
<meta name="googlebot" content="snippet"/> |
40
|
|
|
<meta name="googlebot" content="index, follow"/> |
41
|
|
|
<meta name="robots" content="index, follow"/>'; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @return string |
46
|
|
|
*/ |
47
|
|
|
public static function getNorobot() |
48
|
|
|
{ |
49
|
|
|
return ' |
50
|
|
|
<meta name="googlebot" content="noindex, nofollow"/> |
51
|
|
|
<meta name="robots" content="noindex, nofollow"/>'; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @param $title |
56
|
|
|
* @return string |
57
|
|
|
*/ |
58
|
|
|
public static function getTitle($title) |
59
|
|
|
{ |
60
|
|
|
return '<title>' . $title . '</title>'; |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @param $desc |
65
|
|
|
* @return string |
66
|
|
|
*/ |
67
|
|
|
public static function getDescription($desc) |
68
|
|
|
{ |
69
|
|
|
return '<meta itemprop="description" name="description" content="' . $desc . '"/>'; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @param $langList |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
public static function getAlternate($langList) |
77
|
|
|
{ |
78
|
|
|
$LL = ''; |
79
|
|
|
if (count($langList) > 1): |
80
|
|
|
foreach ($langList as $lang): |
81
|
|
|
$LL .= ' |
82
|
|
|
<link rel="alternate" hreflang="' . $lang['hreflang'] . '" href="' . home('?lang=' . $lang['code']) . '"/>'; |
|
|
|
|
83
|
|
|
endforeach; else: |
84
|
|
|
$LL = ' |
85
|
|
|
<link rel="alternate" hreflang="' . $lang['hreflang'] . '" href="' . home('?lang=' . $lang['code']) . '"/>'; |
|
|
|
|
86
|
|
|
endif; |
87
|
|
|
return $LL; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* @param $fb |
92
|
|
|
* @return string |
93
|
|
|
*/ |
94
|
|
|
public static function getFacebook($fb) |
95
|
|
|
{ |
96
|
|
|
$fbh = ''; |
97
|
|
|
if (is_array($fb)): |
98
|
|
|
foreach ($fb as $fbkey => $fbrow): |
99
|
|
|
$fbh .= ' |
100
|
|
|
<meta property="og:' . $fbkey . '" content="' . $fbrow . '"/>'; |
101
|
|
|
endforeach; |
102
|
|
|
endif; |
103
|
|
|
return $fbh; |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* @param $tw |
108
|
|
|
* @return string |
109
|
|
|
*/ |
110
|
|
|
public static function getTwitter($tw) |
111
|
|
|
{ |
112
|
|
|
$twh = ''; |
113
|
|
|
if (is_array($tw)): |
114
|
|
|
foreach ($tw as $twkey => $twrow): |
115
|
|
|
$twh .= '<meta name="twitter:' . $twkey . '" content="' . $twrow . '"/>'; |
116
|
|
|
endforeach; |
117
|
|
|
endif; |
118
|
|
|
return $twh; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param $icon |
123
|
|
|
* @return string |
124
|
|
|
*/ |
125
|
|
|
public static function getIcon($icon) |
126
|
|
|
{ |
127
|
|
|
$iconh = ''; |
128
|
|
|
if (is_array($icon)): |
129
|
|
|
foreach ($icon as $iconkey => $iconrow): |
130
|
|
|
$iconh .= '<meta name="' . $iconkey . '" href="' . $iconrow . '"/>'; |
131
|
|
|
endforeach; |
132
|
|
|
endif; |
133
|
|
|
return $iconh; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @param $author |
138
|
|
|
* @return string |
139
|
|
|
*/ |
140
|
|
|
public static function getAuthor($author) |
141
|
|
|
{ |
142
|
|
|
return '<meta name="author" itemprop="author" content="' . $author . '"/>'; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @param $canonical |
147
|
|
|
* @return string |
148
|
|
|
*/ |
149
|
|
|
public static function getCanonical($canonical) |
150
|
|
|
{ |
151
|
|
|
return '<link rel="canonical" itemprop="url" type="text/html" href="' . $canonical . '"/>'; |
152
|
|
|
} |
153
|
|
|
|
154
|
|
|
/** |
155
|
|
|
* @param $manifest |
156
|
|
|
* @return string |
157
|
|
|
*/ |
158
|
|
|
public static function getManifest($manifest) |
159
|
|
|
{ |
160
|
|
|
return '<link rel="manifest" href="' . $manifest . '"/>'; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* @param $google |
165
|
|
|
* @return string |
166
|
|
|
*/ |
167
|
|
|
public static function getGoogle($google) |
168
|
|
|
{ |
169
|
|
|
return '<meta name="google-site-verification" content="' . $google . '"/>'; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
/** |
173
|
|
|
* @param $bing |
174
|
|
|
* @return string |
175
|
|
|
*/ |
176
|
|
|
public static function getBing($bing) |
177
|
|
|
{ |
178
|
|
|
return ' |
179
|
|
|
<meta name="msvalidate.01" content="' . $bing . '"/>'; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
/** |
183
|
|
|
* @param $yandex |
184
|
|
|
* @return string |
185
|
|
|
*/ |
186
|
|
|
public static function getgetYandex($yandex) |
187
|
|
|
{ |
188
|
|
|
return '<meta name="yandex-verification" content="' . $yandex . '"/>'; |
189
|
|
|
} |
190
|
|
|
|
191
|
|
|
/** |
192
|
|
|
* @param $amp |
193
|
|
|
* @return string |
194
|
|
|
*/ |
195
|
|
|
public static function getAmp($amp) |
196
|
|
|
{ |
197
|
|
|
return '<meta rel="amphtml" content="' . $amp . '"/>'; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
/** |
201
|
|
|
* @param $crumb |
202
|
|
|
* @return string |
203
|
|
|
*/ |
204
|
|
|
public static function getBreadcrumb($crumb) |
205
|
|
|
{ |
206
|
|
|
$h = ''; |
207
|
|
|
$count = 0; |
208
|
|
|
$bcount = count($crumb); |
209
|
|
|
if (is_array($crumb)): |
210
|
|
|
$h .= '<script type="application/ld+json">{ |
211
|
|
|
"@context": "http://schema.org", |
212
|
|
|
"@type": "BreadcrumbList", |
213
|
|
|
"itemListElement":['; |
214
|
|
|
foreach ($crumb as $crumbrow): |
215
|
|
|
++$count; |
216
|
|
|
$h .= ' |
217
|
|
|
{ |
218
|
|
|
"@type": "ListItem", |
219
|
|
|
"position":"' . $crumbrow['position'] . '", |
220
|
|
|
"item": { |
221
|
|
|
"@id":"' . $crumbrow['id'] . '", |
222
|
|
|
"name": "' . $crumbrow['name'] . '" |
223
|
|
|
} |
224
|
|
|
}'; |
225
|
|
|
$h .= $count == $bcount ? '' : ','; |
226
|
|
|
endforeach; |
227
|
|
|
$h .= ']} |
228
|
|
|
</script>'; |
229
|
|
|
endif; |
230
|
|
|
return $h; |
231
|
|
|
} |
232
|
|
|
} |
233
|
|
|
|