Meta data (OpenGraph) toegevoegd.
This commit is contained in:
35
common/classes/MetaData.php
Normal file
35
common/classes/MetaData.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace Model;
|
||||
|
||||
class MetaData {
|
||||
private $data = ['type' => 'article', 'locale' => 'nl-nl'];
|
||||
|
||||
public function set($prop, $val) {
|
||||
if($val) {
|
||||
$this->data[$prop] = $val;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function append($prop, $val) {
|
||||
if(array_key_exists($prop, $this->data)) {
|
||||
$this->data[$prop] .= $val;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function prepend($prop, $val) {
|
||||
if(array_key_exists($prop, $this->data)) {
|
||||
$this->data[$prop] = $val . $this->data[$prop];
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function metaTags() {
|
||||
foreach($this->data as $prop => $val) {
|
||||
if($val) {
|
||||
echo "<meta property=\"og:$prop\" content=\"" . htmlentities($val) . "\" />\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user