| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | Plugin name: apply_filters_ref_array tests |
|---|
| 4 | Author: scribu |
|---|
| 5 | Version: 1.1 |
|---|
| 6 | */ |
|---|
| 7 | |
|---|
| 8 | // A filter that applies only on secondary loops |
|---|
| 9 | function test_func_query($where, $query) { |
|---|
| 10 | global $wp_query; |
|---|
| 11 | |
|---|
| 12 | if ( $query != $wp_query ) |
|---|
| 13 | $query->test = 'pass'; |
|---|
| 14 | |
|---|
| 15 | return $where; |
|---|
| 16 | } |
|---|
| 17 | add_filter('posts_where', 'test_func_query', 10, 2); |
|---|
| 18 | |
|---|
| 19 | function 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 | } |
|---|
| 27 | add_action('wp_head', 'do_test'); |
|---|
| 28 | |
|---|