@@ -78,8 +78,6 @@ |
||
78 | 78 | * Returns the filtered redirect url for the current user. |
79 | 79 | * |
80 | 80 | * @param string $redirect_to The default redirect callback argument. |
81 | - * @param string $request The default redirect request callback argument. |
|
82 | - * @param integer $user The current user logging in. |
|
83 | 81 | * @return string The final redirect url. |
84 | 82 | */ |
85 | 83 | public static function get_login_redirect_url( $redirect_to ) { |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace Subway; |
14 | 14 | |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | return; |
17 | 17 | } |
18 | 18 | |
@@ -31,17 +31,17 @@ discard block |
||
31 | 31 | public static function handle_authentication() { |
32 | 32 | |
33 | 33 | // Set the header type to json. |
34 | - header( 'Content-Type: application/json' ); |
|
34 | + header('Content-Type: application/json'); |
|
35 | 35 | |
36 | - $log = filter_input( INPUT_POST, 'log', FILTER_SANITIZE_STRING ); |
|
36 | + $log = filter_input(INPUT_POST, 'log', FILTER_SANITIZE_STRING); |
|
37 | 37 | |
38 | - $pwd = filter_input( INPUT_POST, 'pwd', FILTER_SANITIZE_STRING ); |
|
38 | + $pwd = filter_input(INPUT_POST, 'pwd', FILTER_SANITIZE_STRING); |
|
39 | 39 | |
40 | - if ( empty( $log ) && empty( $pwd ) ) { |
|
40 | + if (empty($log) && empty($pwd)) { |
|
41 | 41 | |
42 | 42 | $response['type'] = 'error'; |
43 | 43 | |
44 | - $response['message'] = esc_html__( 'Username and Password cannot be empty.', 'subway' ); |
|
44 | + $response['message'] = esc_html__('Username and Password cannot be empty.', 'subway'); |
|
45 | 45 | |
46 | 46 | } else { |
47 | 47 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | $response = array(); |
51 | 51 | |
52 | - if ( is_wp_error( $is_signin ) ) { |
|
52 | + if (is_wp_error($is_signin)) { |
|
53 | 53 | |
54 | 54 | $response['type'] = 'error'; |
55 | 55 | |
@@ -59,16 +59,16 @@ discard block |
||
59 | 59 | |
60 | 60 | $response['type'] = 'success'; |
61 | 61 | |
62 | - $response['message'] = esc_html__( 'You have successfully logged-in. Redirecting you in few seconds...' ); |
|
62 | + $response['message'] = esc_html__('You have successfully logged-in. Redirecting you in few seconds...'); |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | - $subway_redirect_url = Auth_Redirect::get_login_redirect_url( '', '' ); |
|
67 | + $subway_redirect_url = Auth_Redirect::get_login_redirect_url('', ''); |
|
68 | 68 | |
69 | - $response['redirect_url'] = apply_filters( 'subway_login_redirect', $subway_redirect_url ); |
|
69 | + $response['redirect_url'] = apply_filters('subway_login_redirect', $subway_redirect_url); |
|
70 | 70 | |
71 | - echo wp_json_encode( $response ); |
|
71 | + echo wp_json_encode($response); |
|
72 | 72 | |
73 | 73 | wp_die(); |
74 | 74 | |
@@ -82,42 +82,42 @@ discard block |
||
82 | 82 | * @param integer $user The current user logging in. |
83 | 83 | * @return string The final redirect url. |
84 | 84 | */ |
85 | - public static function get_login_redirect_url( $redirect_to ) { |
|
85 | + public static function get_login_redirect_url($redirect_to) { |
|
86 | 86 | |
87 | - $subway_redirect_type = get_option( 'subway_redirect_type' ); |
|
87 | + $subway_redirect_type = get_option('subway_redirect_type'); |
|
88 | 88 | |
89 | 89 | // Redirect the user to default behaviour if there are no redirect type option saved. |
90 | - if ( empty( $subway_redirect_type ) ) { |
|
90 | + if (empty($subway_redirect_type)) { |
|
91 | 91 | |
92 | 92 | return $redirect_to; |
93 | 93 | |
94 | 94 | } |
95 | 95 | |
96 | - if ( 'default' === $subway_redirect_type ) { |
|
96 | + if ('default' === $subway_redirect_type) { |
|
97 | 97 | return $redirect_to; |
98 | 98 | } |
99 | 99 | |
100 | - if ( 'page' === $subway_redirect_type ) { |
|
100 | + if ('page' === $subway_redirect_type) { |
|
101 | 101 | |
102 | 102 | // Get the page url of the selected page if the admin selected 'Custom Page' in the redirect type settings. |
103 | - $selected_redirect_page = intval( get_option( 'subway_redirect_page_id' ) ); |
|
103 | + $selected_redirect_page = intval(get_option('subway_redirect_page_id')); |
|
104 | 104 | |
105 | 105 | // Redirect to default WordPress behaviour if the user did not select page. |
106 | - if ( empty( $selected_redirect_page ) ) { |
|
106 | + if (empty($selected_redirect_page)) { |
|
107 | 107 | |
108 | 108 | return $redirect_to; |
109 | 109 | } |
110 | 110 | |
111 | 111 | // Otherwise, get the permalink of the saved page and let the user go into that page. |
112 | - return get_permalink( $selected_redirect_page ); |
|
112 | + return get_permalink($selected_redirect_page); |
|
113 | 113 | |
114 | - } elseif ( 'custom_url' === $subway_redirect_type ) { |
|
114 | + } elseif ('custom_url' === $subway_redirect_type) { |
|
115 | 115 | |
116 | 116 | // Get the custom url saved in the redirect type settings. |
117 | - $entered_custom_url = get_option( 'subway_redirect_custom_url' ); |
|
117 | + $entered_custom_url = get_option('subway_redirect_custom_url'); |
|
118 | 118 | |
119 | 119 | // Redirect to default WordPress behaviour if the user did enter a custom url. |
120 | - if ( empty( $entered_custom_url ) ) { |
|
120 | + if (empty($entered_custom_url)) { |
|
121 | 121 | |
122 | 122 | return $redirect_to; |
123 | 123 | |
@@ -126,12 +126,12 @@ discard block |
||
126 | 126 | // Otherwise, get the custom url saved and let the user go into that page. |
127 | 127 | $current_user = wp_get_current_user(); |
128 | 128 | |
129 | - if ( ! empty( $current_user->ID ) ) { |
|
130 | - $entered_custom_url = str_replace( '%user_id%', $current_user->ID, $entered_custom_url ); |
|
129 | + if ( ! empty($current_user->ID)) { |
|
130 | + $entered_custom_url = str_replace('%user_id%', $current_user->ID, $entered_custom_url); |
|
131 | 131 | } |
132 | 132 | |
133 | - if ( ! empty( $current_user->user_login ) ) { |
|
134 | - $entered_custom_url = str_replace( '%user_name%', $current_user->user_login, $entered_custom_url ); |
|
133 | + if ( ! empty($current_user->user_login)) { |
|
134 | + $entered_custom_url = str_replace('%user_name%', $current_user->user_login, $entered_custom_url); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | return $entered_custom_url; |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | * @param string $login_url The login url. |
149 | 149 | * @return string The final login url. |
150 | 150 | */ |
151 | - public static function login_url( $login_url ) { |
|
151 | + public static function login_url($login_url) { |
|
152 | 152 | |
153 | 153 | $subway_login_page = Options::get_redirect_page_url(); |
154 | 154 | |
155 | 155 | // Return the default login url if there is no log-in page defined. |
156 | - if ( empty( $subway_login_page ) ) { |
|
156 | + if (empty($subway_login_page)) { |
|
157 | 157 | return $login_url; |
158 | 158 | } |
159 | 159 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | $subway_login_page = Options::get_redirect_page_url(); |
173 | 173 | |
174 | - wp_safe_redirect( esc_url( $subway_login_page . '?loggedout=true' ) ); |
|
174 | + wp_safe_redirect(esc_url($subway_login_page . '?loggedout=true')); |
|
175 | 175 | |
176 | 176 | Helpers::close(); |
177 | 177 |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | namespace Subway; |
13 | 13 | |
14 | -if ( ! defined( 'ABSPATH' ) ) { |
|
14 | +if ( ! defined('ABSPATH')) { |
|
15 | 15 | return; |
16 | 16 | } |
17 | 17 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | private function __construct() { |
21 | 21 | |
22 | - add_action( 'init', array( $this, 'register') ); |
|
22 | + add_action('init', array($this, 'register')); |
|
23 | 23 | |
24 | 24 | return $this; |
25 | 25 | |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | static $instance = null; |
31 | 31 | |
32 | - if ( null === $instance ) { |
|
32 | + if (null === $instance) { |
|
33 | 33 | |
34 | 34 | $instance = new Shortcodes(); |
35 | 35 | |
@@ -42,11 +42,11 @@ discard block |
||
42 | 42 | |
43 | 43 | function register() { |
44 | 44 | |
45 | - add_shortcode( 'subway_login', array( $this, 'wp_login' ) ); |
|
45 | + add_shortcode('subway_login', array($this, 'wp_login')); |
|
46 | 46 | |
47 | - add_action( 'login_form_middle', array( $this, 'login_form_action' ), 10, 2 ); |
|
47 | + add_action('login_form_middle', array($this, 'login_form_action'), 10, 2); |
|
48 | 48 | |
49 | - add_action( 'login_form_middle', array( $this, '__action_lost_password_link' ), 10, 2 ); |
|
49 | + add_action('login_form_middle', array($this, '__action_lost_password_link'), 10, 2); |
|
50 | 50 | |
51 | 51 | return null; |
52 | 52 | |
@@ -56,26 +56,26 @@ discard block |
||
56 | 56 | |
57 | 57 | $atts = array(); |
58 | 58 | |
59 | - echo $this->get_template_file( $atts, 'login-form.php', null ); |
|
59 | + echo $this->get_template_file($atts, 'login-form.php', null); |
|
60 | 60 | |
61 | 61 | return; |
62 | 62 | } |
63 | 63 | |
64 | - protected function get_template_file( $atts, $file = '', $content = null ) { |
|
64 | + protected function get_template_file($atts, $file = '', $content = null) { |
|
65 | 65 | |
66 | 66 | ob_start(); |
67 | 67 | |
68 | - if ( empty( $file ) ) { |
|
68 | + if (empty($file)) { |
|
69 | 69 | |
70 | 70 | return; |
71 | 71 | |
72 | 72 | } |
73 | 73 | |
74 | - $template = SUBWAY_DIR_PATH . 'templates/'.$file; |
|
74 | + $template = SUBWAY_DIR_PATH . 'templates/' . $file; |
|
75 | 75 | |
76 | - if ( file_exists( $template ) ) { |
|
76 | + if (file_exists($template)) { |
|
77 | 77 | |
78 | - if ( $theme_template = locate_template( array('gears/shortcodes/'.$file ) ) ) { |
|
78 | + if ($theme_template = locate_template(array('gears/shortcodes/' . $file))) { |
|
79 | 79 | |
80 | 80 | $template = $theme_template; |
81 | 81 | |
@@ -85,26 +85,26 @@ discard block |
||
85 | 85 | |
86 | 86 | } else { |
87 | 87 | |
88 | - echo sprintf( esc_html_e( 'Subway Error: Unable to find template file in: %1s', 'subway' ), $template ); |
|
88 | + echo sprintf(esc_html_e('Subway Error: Unable to find template file in: %1s', 'subway'), $template); |
|
89 | 89 | |
90 | 90 | } |
91 | 91 | |
92 | 92 | return ob_get_clean(); |
93 | 93 | } |
94 | 94 | |
95 | - public function login_form_action( $__content ) { |
|
95 | + public function login_form_action($__content) { |
|
96 | 96 | |
97 | 97 | ob_start(); |
98 | 98 | |
99 | - do_action( 'login_form' ); |
|
99 | + do_action('login_form'); |
|
100 | 100 | |
101 | 101 | return $__content . ob_get_clean(); |
102 | 102 | |
103 | 103 | } |
104 | 104 | |
105 | - public function __action_lost_password_link( $__content ) { |
|
105 | + public function __action_lost_password_link($__content) { |
|
106 | 106 | |
107 | - return $__content . $this->get_template_file( array(), 'login-form-lost-password.php', null ); |
|
107 | + return $__content . $this->get_template_file(array(), 'login-form-lost-password.php', null); |
|
108 | 108 | |
109 | 109 | } |
110 | 110 |