A proposal on how 2k11 could utilize pre-event hooks. Now per-event so that the function name no longer

clashes with child-themes that need to include the 2k11 config.inc.php.
This commit is contained in:
Garvin Hicking
2014-05-22 11:44:25 +02:00
parent f96f0da3f8
commit e8bae220e6
3 changed files with 28 additions and 12 deletions
+15
View File
@@ -1096,6 +1096,16 @@ class serendipity_plugin_api
$apifunc($event_name, $bag, $eventData, $addData);
}
// Function names cannot contain ":" etc, so if we ever have event looks like "backend:js" this
// needs to be replaced to "backend_js". The real event name is passed as a function argument
// These specific per-hook functions are utilized for theme's config.inc.php files
// that act as an engine for other themes.
$safe_event_name = preg_replace('@[^a-z0-9_]+@i', '_', $event_name);
if (function_exists('serendipity_plugin_api_pre_event_hook_' . $safe_event_name)) {
$apifunc = 'serendipity_plugin_api_pre_event_hook_' . $safe_event_name;
$apifunc($event_name, $bag, $eventData, $addData);
}
if (is_array($plugins)) {
// foreach() operates on copies of values, but we want to operate on references, so we use while()
@reset($plugins);
@@ -1124,6 +1134,11 @@ class serendipity_plugin_api
$apifunc($event_name, $bag, $eventData, $addData);
}
if (function_exists('serendipity_plugin_api_event_hook_' . $safe_event_name)) {
$apifunc = 'serendipity_plugin_api_event_hook_' . $safe_event_name;
$apifunc($event_name, $bag, $eventData, $addData);
}
}
return true;