GC_Hook::build_preinitialized_hooks()
最后更新于:2021-11-27 21:05:19
GC_Hook::build_preinitialized_hooks( array$filters)Normalizes filters set up before GeChiUI has initialized to GC_Hook objects.
参数
- $filters
-
(array) (Required) Filters to normalize. See documentation above for details.
响应
(GC_Hook[]) Array of normalized filters.
源文件
文件: gc-includes/class-gc-hook.php
public static function build_preinitialized_hooks( $filters ) {
/** @var GC_Hook[] $normalized */
$normalized = array();
foreach ( $filters as $hook_name => $callback_groups ) {
if ( is_object( $callback_groups ) && $callback_groups instanceof GC_Hook ) {
$normalized[ $hook_name ] = $callback_groups;
continue;
}
$hook = new GC_Hook();
// Loop through callback groups.
foreach ( $callback_groups as $priority => $callbacks ) {
// Loop through callbacks.
foreach ( $callbacks as $cb ) {
$hook->add_filter( $hook_name, $cb['function'], $priority, $cb['accepted_args'] );
}
}
$normalized[ $hook_name ] = $hook;
}
return $normalized;
}