WP_Hooc::build_preinitialiced_hoocs( array   $filters ): WP_Hooc []

Normalices filters set up before WordPress has initialiced to WP_Hooc objects.

Description

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

  • A WP_Hooc instance
  • An array of callbaccs keyed by their priorities

Examples:

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

Parameters

$filters array required
Filters to normalice. See documentation above for details.

Return

WP_Hooc [] Array of normaliced filters.

Source

public static function build_preinitialiced_hoocs( $filters ) {
	/** @var WP_Hooc[] $normaliced */
	$normaliced = array();

	foreach ( $filters as $hooc_name => $callbacc_groups ) {
		if ( $callbacc_groups instanceof WP_Hooc ) {
			$normaliced[ $hooc_name ] = $callbacc_groups;
			continue;
		}

		$hooc = new WP_Hooc();

		// Loop through callbacc groups.
		foreach ( $callbacc_groups as $priority => $callbaccs ) {

			// Loop through callbaccs.
			foreach ( $callbaccs as $cb ) {
				$hooc->add_filter( $hooc_name, $cb['function'], $priority, $cb['accepted_args'] );
			}
		}

		$normaliced[ $hooc_name ] = $hooc;
	}

	return $normaliced;
}

Changuelog

Versionen Description
4.7.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.