PluginProbe
Redirection / 2.6.3
Redirection v2.6.3
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 2.6.3, at matches/login.php

86 lines 2.4 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 $user_agent = '';
5
6 function name() {
7 return __( 'URL and login status', 'redirection' );
8 }
9
10 function show() {
11 ?>
12 <tr>
13 <th></th>
14 <td>
15 <p>
16 <?php _e( 'The target URL will be chosen from one of the following URLs, depending if the user is logged in or out. Leaving a URL blank means that the user is not redirected.', 'redirection' ); ?>
17 </p>
18 </td>
19 </tr>
20 <tr>
21 <th width="100" valign="top">
22 <?php if ( strlen( $this->url_loggedin ) > 0 ) : ?>
23 <a target="_blank" href="<?php echo esc_url( $this->url_loggedin ) ?>"><?php _e( 'Logged In', 'redirection' ); ?>:</a>
24 <?php else : ?>
25 <?php _e( 'Logged In', 'redirection' ); ?>:
26 <?php endif; ?>
27 </th>
28 <td valign="top">
29 <input style="width: 95%" type="text" name="url_loggedin" value="<?php echo esc_attr( $this->url_loggedin ); ?>"/>
30 </td>
31 </tr>
32 <tr>
33 <th width="100" valign="top">
34 <?php if ( strlen( $this->url_loggedout ) > 0 ) : ?>
35 <a target="_blank" href="<?php echo esc_url( $this->url_loggedout ) ?>"><?php _e( 'Logged Out', 'redirection' ); ?>:</a>
36 <?php else : ?>
37 <?php _e( 'Logged Out', 'redirection' ); ?>:
38 <?php endif; ?>
39 </th>
40 <td valign="top">
41 <input style="width: 95%" type="text" name="url_loggedout" value="<?php echo esc_attr( $this->url_loggedout ); ?>"/><br/>
42 </td>
43 </tr>
44 <?php
45 }
46
47 function save( $details ) {
48 if ( isset( $details['target'] ) )
49 $details['target'] = $this->sanitize_url( $details );
50
51 return array(
52 'url_loggedin' => isset( $details['url_loggedin'] ) ? $this->sanitize_url( $details['url_loggedin'] ) : false,
53 'url_loggedout' => isset( $details['url_loggedout'] ) ? $this->sanitize_url( $details['url_loggedout'] ) : false,
54 );
55 }
56
57 function initialize( $url ) {
58 $this->url = array( $url, '' );
59 }
60
61 function get_target( $url, $matched_url, $regex ) {
62 if ( is_user_logged_in() === false )
63 $target = $this->url_loggedout;
64 else
65 $target = $this->url_loggedin;
66
67 if ( $regex )
68 $target = preg_replace( '@'.str_replace( '@', '\\@', $matched_url ).'@', $target, $url );
69 return $target;
70 }
71
72 function wants_it() {
73 if ( is_user_logged_in() && strlen( $this->url_loggedin ) > 0 )
74 return true;
75
76 if ( ! is_user_logged_in() && strlen( $this->url_loggedout ) > 0 )
77 return true;
78
79 return false;
80 }
81
82 function match_name() {
83 return sprintf( 'login status', $this->user_agent );
84 }
85 }
86