1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 22:57:14 +02:00

Issue #2902 Code simplification and cleanup. system_meta_pre event now sends the current meta list to the assigned function.

This commit is contained in:
Cameron
2017-12-09 10:36:00 -08:00
parent 9b061ed373
commit 8789ce6f1c
2 changed files with 25 additions and 25 deletions

View File

@@ -4307,7 +4307,7 @@ class eResponse
{ {
$attrData = ''; $attrData = '';
e107::getEvent()->trigger('system_meta_pre'); e107::getEvent()->trigger('system_meta_pre', $this->_meta);
foreach ($this->_meta as $attr) foreach ($this->_meta as $attr)
{ {

View File

@@ -30,41 +30,41 @@ class social_event
$event[] = array( $event[] = array(
'name' => "system_meta_pre", 'name' => "system_meta_pre",
'function' => "ogg_image_add", 'function' => "og_image_add",
); );
return $event; return $event;
} }
/** /**
* Callback function to add og:image if there is no any * Callback function to add og:image if there is no any
*/ */
function ogg_image_add() function og_image_add($meta)
{ {
$ogImage = e107::pref('social','og_image', false); $ogImage = e107::pref('social', 'og_image', false);
if(e_ADMIN_AREA !==true) { if(empty($ogImage) || empty($meta) || e_ADMIN_AREA === true)
$ogimgexist = FALSE; {
return null;
// check if we have og:image defined }
$response = e107::getSingleton('eResponse');
$data = $response->getMeta(); // check if we have og:image defined
foreach($data as $m) { foreach($meta as $m)
if($m['name'] == 'og:image') { {
$ogimgexist = TRUE; if($m['name'] === 'og:image')
} {
return null;
} }
}
if(!empty($ogImage) && !$ogimgexist) {
e107::meta('og:image',e107::getParser()->thumbUrl($ogImage,'w=500',false,true)); e107::meta('og:image', e107::getParser()->thumbUrl($ogImage, 'w=500', false, true));
unset($ogImage);
}
}
} }
} //end class } //end class
?>