Fixed error when formatting empty hook.

Prop @kellymears Closes #30
This commit is contained in:
Andrey Savchenko committed 2019-03-24 19:52:42 +02:00
1 parent 739ed7dd90
commit ba72763486
3 files changed
+11

No files matched your search

+6
View File
@@ -16,6 +16,7 @@ class Hook_Formatter {
*/
public function __construct() {
// TODO inject paths instead of reaching for global constants.
$this->truncate_paths = [
wp_normalize_path( WP_CONTENT_DIR ),
wp_normalize_path( ABSPATH ),
@@ -35,6 +36,11 @@ class Hook_Formatter {
if ( $hook instanceof \WP_Hook ) {
$hook = $hook->callbacks;
}
if ( empty( $hook ) ) {
return $callbacks;
}
ksort( $hook );
$functions = array_merge( ...$hook );