Fix possible foreach on null errors
This commit is contained in:
parent
82e0ca5216
commit
90128f4946
28
lib/Pico.php
28
lib/Pico.php
@ -812,14 +812,16 @@ class Pico
|
|||||||
$content = str_replace('%theme_url%', $themeUrl, $content);
|
$content = str_replace('%theme_url%', $themeUrl, $content);
|
||||||
|
|
||||||
// replace %meta.*%
|
// replace %meta.*%
|
||||||
$metaKeys = $metaValues = array();
|
if (!empty($this->meta)) {
|
||||||
foreach ($this->meta as $metaKey => $metaValue) {
|
$metaKeys = $metaValues = array();
|
||||||
if (is_scalar($metaValue) || ($metaValue === null)) {
|
foreach ($this->meta as $metaKey => $metaValue) {
|
||||||
$metaKeys[] = '%meta.' . $metaKey . '%';
|
if (is_scalar($metaValue) || ($metaValue === null)) {
|
||||||
$metaValues[] = strval($metaValue);
|
$metaKeys[] = '%meta.' . $metaKey . '%';
|
||||||
|
$metaValues[] = strval($metaValue);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
$content = str_replace($metaKeys, $metaValues, $content);
|
||||||
}
|
}
|
||||||
$content = str_replace($metaKeys, $metaValues, $content);
|
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
@ -1240,12 +1242,14 @@ class Pico
|
|||||||
*/
|
*/
|
||||||
protected function triggerEvent($eventName, array $params = array())
|
protected function triggerEvent($eventName, array $params = array())
|
||||||
{
|
{
|
||||||
foreach ($this->plugins as $plugin) {
|
if (!empty($this->plugins)) {
|
||||||
// only trigger events for plugins that implement PicoPluginInterface
|
foreach ($this->plugins as $plugin) {
|
||||||
// deprecated events (plugins for Pico 0.9 and older) will be
|
// only trigger events for plugins that implement PicoPluginInterface
|
||||||
// triggered by the `PicoPluginDeprecated` plugin
|
// deprecated events (plugins for Pico 0.9 and older) will be
|
||||||
if (is_a($plugin, 'PicoPluginInterface')) {
|
// triggered by the `PicoPluginDeprecated` plugin
|
||||||
$plugin->handleEvent($eventName, $params);
|
if (is_a($plugin, 'PicoPluginInterface')) {
|
||||||
|
$plugin->handleEvent($eventName, $params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user