PluginProbe
Redirection / 3.7
Redirection v3.7
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 / login.php

login.php in Redirection 3.7, at matches/login.php

51 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Login_Match extends Red_Match {
4 public $logged_in;
5 public $logged_out;
6
7 public function name() {
8 return __( 'URL and login status', 'redirection' );
9 }
10
11 public function save( array $details, $no_target_url = false ) {
12 if ( $no_target_url ) {
13 return null;
14 }
15
16 return array(
17 'logged_in' => isset( $details['logged_in'] ) ? $this->sanitize_url( $details['logged_in'] ) : '',
18 'logged_out' => isset( $details['logged_out'] ) ? $this->sanitize_url( $details['logged_out'] ) : '',
19 );
20 }
21
22 function get_target( $url, $matched_url, $regex ) {
23 $target = false;
24
25 if ( is_user_logged_in() && $this->logged_in !== '' ) {
26 $target = $this->logged_in;
27 } elseif ( ! is_user_logged_in() && $this->logged_out !== '' ) {
28 $target = $this->logged_out;
29 }
30
31 if ( $regex && $target ) {
32 $target = $this->get_target_regex_url( $matched_url, $target, $url );
33 }
34
35 return $target;
36 }
37
38 public function get_data() {
39 return array(
40 'logged_in' => $this->logged_in,
41 'logged_out' => $this->logged_out,
42 );
43 }
44
45 public function load( $values ) {
46 $values = unserialize( $values );
47 $this->logged_in = isset( $values['logged_in'] ) ? $values['logged_in'] : '';
48 $this->logged_out = isset( $values['logged_out'] ) ? $values['logged_out'] : '';
49 }
50 }
51