| 1 |
<?php |
| 2 |
|
| 3 |
class Error_Action extends Red_Action { |
| 4 |
function process_before( $code, $target ) { |
| 5 |
$this->code = $code; |
| 6 |
|
| 7 |
wp_reset_query(); |
| 8 |
set_query_var( 'is_404', true ); |
| 9 |
|
| 10 |
add_filter( 'template_include', array( $this, 'template_include' ) ); |
| 11 |
add_filter( 'pre_handle_404', array( $this, 'pre_handle_404' ) ); |
| 12 |
add_action( 'wp', array( $this, 'wp' ) ); |
| 13 |
|
| 14 |
return true; |
| 15 |
} |
| 16 |
|
| 17 |
public function wp() { |
| 18 |
status_header( $this->code ); |
| 19 |
nocache_headers(); |
| 20 |
header( 'X-Redirect-Agent: redirection' ); |
| 21 |
} |
| 22 |
|
| 23 |
public function pre_handle_404() { |
| 24 |
global $wp_query; |
| 25 |
|
| 26 |
// Page comments plugin interferes with this |
| 27 |
$wp_query->posts = array(); |
| 28 |
return false; |
| 29 |
} |
| 30 |
|
| 31 |
public function template_include() { |
| 32 |
return get_404_template(); |
| 33 |
} |
| 34 |
} |
| 35 |
|