PluginProbe
Redirection / 5.1
Redirection v5.1
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 / matches / page.php

page.php in Redirection 5.1, at matches/page.php

51 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Match the WordPress page type
5 */
6 class Page_Match extends Red_Match {
7 use FromUrl_Match;
8
9 /**
10 * Page type
11 *
12 * @var String
13 */
14 public $page = '404';
15
16 public function name() {
17 return __( 'URL and WordPress page type', 'redirection' );
18 }
19
20 public function save( array $details, $no_target_url = false ) {
21 $data = array( 'page' => isset( $details['page'] ) ? $this->sanitize_page( $details['page'] ) : '404' );
22
23 return $this->save_data( $details, $no_target_url, $data );
24 }
25
26 private function sanitize_page( $page ) {
27 return '404';
28 }
29
30 public function is_match( $url ) {
31 return is_404();
32 }
33
34 public function get_data() {
35 return array_merge( array(
36 'page' => $this->page,
37 ), $this->get_from_data() );
38 }
39
40 /**
41 * Load the match data into this instance.
42 *
43 * @param String $values Match values, as read from the database (plain text or serialized PHP).
44 * @return void
45 */
46 public function load( $values ) {
47 $values = $this->load_data( $values );
48 $this->page = isset( $values['page'] ) ? $values['page'] : '404';
49 }
50 }
51