Make WordPress Core

Ticket #9886: apply_filters_ref_array.test.2.php

File apply_filters_ref_array.test.2.php, 516 bytes (added by scribu, 15 years ago)

Test filters in query.php

Line 
1<?php
2/*
3Plugin name: apply_filters_ref_array tests
4Author: scribu
5Version: 1.1
6*/
7
8// A filter that applies only on secondary loops
9function test_func_query($where, $query) {
10        global $wp_query;
11
12        if ( $query != $wp_query )
13                $query->test = 'pass';
14
15        return $where;
16}
17add_filter('posts_where', 'test_func_query', 10, 2);
18
19function do_test() {
20        $q = new WP_Query('posts_per_page=10');
21        global $wp_query;
22
23        var_dump('pass' == $q->test);
24        var_dump('pass' != $wp_query->test);
25        die;
26}
27add_action('wp_head', 'do_test');
28