PluginProbe
Redirection / 4.4
Redirection v4.4
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
redirection / actions / error.php

error.php in Redirection 4.4, at actions/error.php

44 lines 845 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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', [ $this, 'template_include' ] );
11 add_filter( 'pre_handle_404', [ $this, 'pre_handle_404' ] );
12 add_action( 'wp', [ $this, 'wp' ] );
13
14 return true;
15 }
16
17 public function wp() {
18 status_header( $this->code );
19 nocache_headers();
20
21 global $wp_version;
22
23 if ( version_compare( $wp_version, '5.1', '<' ) ) {
24 header( 'X-Redirect-Agent: redirection' );
25 }
26 }
27
28 public function pre_handle_404() {
29 global $wp_query;
30
31 // Page comments plugin interferes with this
32 $wp_query->posts = [];
33 return false;
34 }
35
36 public function template_include() {
37 return get_404_template();
38 }
39
40 public function needs_target() {
41 return false;
42 }
43 }
44