Make WordPress Core

Ticket #17817: 17817.25.diff

File 17817.25.diff, 1.1 KB (added by boonebgorges, 8 years ago)
  • tests/phpunit/includes/functions.php

    diff --git tests/phpunit/includes/functions.php tests/phpunit/includes/functions.php
    index ce8ea69..a7ccb3a 100644
    function tests_reset__SERVER() { 
    2323function tests_add_filter($tag, $function_to_add, $priority = 10, $accepted_args = 1) {
    2424        global $wp_filter;
    2525
    26         $idx = _test_filter_build_unique_id($tag, $function_to_add, $priority);
    27         $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
     26        $idx = _test_filter_build_unique_id( $tag, $function_to_add, $priority );
     27
     28        if ( class_exists( 'WP_Hook' ) ) {
     29                if ( ! isset( $wp_filter[ $tag ] ) ) {
     30                        $wp_filter[ $tag ] = new WP_Hook();
     31                }
     32
     33                $wp_filter[ $tag ]->callbacks[ $priority ][ $idx ] = array(
     34                        'function' => $function_to_add,
     35                        'accepted_args' => $accepted_args,
     36                );
     37        } else {
     38                // WP has not loaded yet. Hook will be normalized on WP bootstrap.
     39                $wp_filter[$tag][$priority][$idx] = array('function' => $function_to_add, 'accepted_args' => $accepted_args);
     40        }
     41
    2842        return true;
    2943}
    3044