Title: WP_Hook::build_preinitialized_hooks
Published: December 6, 2016
Last modified: February 24, 2026

---

# WP_Hook::build_preinitialized_hooks( array $filters ): 󠀁[WP_Hook](https://developer.wordpress.org/reference/classes/wp_hook/)󠁿[]

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_hook/build_preinitialized_hooks/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_hook/build_preinitialized_hooks/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_hook/build_preinitialized_hooks/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_hook/build_preinitialized_hooks/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_hook/build_preinitialized_hooks/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_hook/build_preinitialized_hooks/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_hook/build_preinitialized_hooks/?output_format=md#wp--skip-link--target)

Normalizes filters set up before WordPress has initialized to [WP_Hook](https://developer.wordpress.org/reference/classes/wp_hook/)
objects.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_hook/build_preinitialized_hooks/?output_format=md#description)󠁿

The `$filters` parameter should be an array keyed by hook name, with values containing
either:

 * A `WP_Hook` instance
 * An array of callbacks keyed by their priorities

Examples:

    ```php
    $filters = array(
        'wp_fatal_error_handler_enabled' => array(
            10 => array(
                array(
                    'accepted_args' => 0,
                    'function'      => function() {
                        return false;
                    },
                ),
            ),
        ),
    );
    ```

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_hook/build_preinitialized_hooks/?output_format=md#parameters)󠁿

 `$filters`arrayrequired

Filters to normalize. See documentation above for details.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_hook/build_preinitialized_hooks/?output_format=md#return)󠁿

 [WP_Hook](https://developer.wordpress.org/reference/classes/wp_hook/)[] Array of
normalized filters.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_hook/build_preinitialized_hooks/?output_format=md#source)󠁿

    ```php
    public static function build_preinitialized_hooks( $filters ) {
    	/** @var WP_Hook[] $normalized */
    	$normalized = array();

    	foreach ( $filters as $hook_name => $callback_groups ) {
    		if ( $callback_groups instanceof WP_Hook ) {
    			$normalized[ $hook_name ] = $callback_groups;
    			continue;
    		}

    		$hook = new WP_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;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-hook.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-hook.php#L441)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-hook.php#L441-L466)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_hook/build_preinitialized_hooks/?output_format=md#related)󠁿

| Used by | Description | 
| [wp_start_object_cache()](https://developer.wordpress.org/reference/functions/wp_start_object_cache/)`wp-includes/load.php` |

Starts the WordPress object cache.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_hook/build_preinitialized_hooks/?output_format=md#changelog)󠁿

| Version | Description | 
| [4.7.0](https://developer.wordpress.org/reference/since/4.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_hook%2Fbuild_preinitialized_hooks%2F)
before being able to contribute a note or feedback.