@@ -31,13 +31,13 @@ discard block |
||
31 | 31 | * @package Subway |
32 | 32 | */ |
33 | 33 | |
34 | -if ( ! defined( 'ABSPATH' ) ) { |
|
34 | +if ( ! defined('ABSPATH')) { |
|
35 | 35 | return; |
36 | 36 | } |
37 | 37 | |
38 | 38 | // Terminate Subway for PHP version 5.3.0 and below. |
39 | -if ( version_compare( PHP_VERSION, '5.3.0', '<' ) ) { |
|
40 | - add_action( 'admin_notices', 'subway_admin_notice' ); |
|
39 | +if (version_compare(PHP_VERSION, '5.3.0', '<')) { |
|
40 | + add_action('admin_notices', 'subway_admin_notice'); |
|
41 | 41 | /** |
42 | 42 | * Displays admin notifications if the installed PHP version is less than 5.3.0 |
43 | 43 | * |
@@ -48,10 +48,10 @@ discard block |
||
48 | 48 | <div class="notice notice-error is-dismissible"> |
49 | 49 | <p> |
50 | 50 | <strong> |
51 | - <?php esc_html_e( 'Notice: Subway uses PHP Class Namespaces |
|
51 | + <?php esc_html_e('Notice: Subway uses PHP Class Namespaces |
|
52 | 52 | which is only available in servers with PHP 5.3.0 version and above. |
53 | 53 | Update your server\'s PHP version. You can deactivate |
54 | - Subway in the meantime.', 'subway' ); ?> |
|
54 | + Subway in the meantime.', 'subway'); ?> |
|
55 | 55 | </strong> |
56 | 56 | </p> |
57 | 57 | </div> |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | // Define Subway Plugin Version. |
63 | -define( 'SUBWAY_VERSION', '2.0' ); |
|
63 | +define('SUBWAY_VERSION', '2.0'); |
|
64 | 64 | |
65 | 65 | // Define Subway Directory Path. |
66 | -define( 'SUBWAY_DIR_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) ); |
|
66 | +define('SUBWAY_DIR_PATH', trailingslashit(plugin_dir_path(__FILE__))); |
|
67 | 67 | |
68 | 68 | // Define Subway URL Path. |
69 | -define( 'SUBWAY_DIR_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) ); |
|
69 | +define('SUBWAY_DIR_URL', trailingslashit(plugin_dir_url(__FILE__))); |
|
70 | 70 | |
71 | 71 | // Include Subway i18n. |
72 | 72 | require_once SUBWAY_DIR_PATH . 'i18.php'; |
@@ -93,20 +93,20 @@ discard block |
||
93 | 93 | require_once SUBWAY_DIR_PATH . 'shortcodes/subway-shortcodes.php'; |
94 | 94 | |
95 | 95 | // Redirect (302) all front-end request to the login page. |
96 | -add_action( 'wp', array( 'Subway\PageRedirect', 'index' ) ); |
|
96 | +add_action('wp', array('Subway\PageRedirect', 'index')); |
|
97 | 97 | |
98 | 98 | // Redirect (302) invalid login request to the login page. |
99 | -add_action( 'wp_ajax_nopriv_subway_logging_in', array( 'Subway\AuthRedirect', 'handleAuthentication' ) ); |
|
99 | +add_action('wp_ajax_nopriv_subway_logging_in', array('Subway\AuthRedirect', 'handleAuthentication')); |
|
100 | 100 | |
101 | 101 | // Load our JS and CSS files. |
102 | -add_action( 'wp_enqueue_scripts', array( 'Subway\Enqueue', 'registerJs' ) ); |
|
102 | +add_action('wp_enqueue_scripts', array('Subway\Enqueue', 'registerJs')); |
|
103 | 103 | |
104 | 104 | // Change the default login url to our sign-in page. |
105 | -add_filter( 'login_url', array( 'Subway\AuthRedirect', 'loginUrl' ), 10, 3 ); |
|
105 | +add_filter('login_url', array('Subway\AuthRedirect', 'loginUrl'), 10, 3); |
|
106 | 106 | |
107 | 107 | // Redirect the user after successful logged in to the right page. |
108 | 108 | // Does not trigger when using ajax form. Only on default wp-login.php and wp_login_form(). |
109 | -add_filter( 'login_redirect', array( 'Subway\AuthRedirect', 'getLoginRedirectUrl' ), 10, 3 ); |
|
109 | +add_filter('login_redirect', array('Subway\AuthRedirect', 'getLoginRedirectUrl'), 10, 3); |
|
110 | 110 | |
111 | 111 | // Change the default logout url to our sign-in page. |
112 | -add_action( 'wp_logout', array( 'Subway\AuthRedirect', 'logoutUrl' ), 10, 3 ); |
|
112 | +add_action('wp_logout', array('Subway\AuthRedirect', 'logoutUrl'), 10, 3); |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | namespace Subway; |
21 | 21 | |
22 | -if (! defined('ABSPATH') ) { |
|
22 | +if ( ! defined('ABSPATH')) { |
|
23 | 23 | return; |
24 | 24 | } |
25 | 25 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | private function __construct() |
45 | 45 | { |
46 | 46 | |
47 | - add_action('init', array( $this, 'register')); |
|
47 | + add_action('init', array($this, 'register')); |
|
48 | 48 | |
49 | 49 | return $this; |
50 | 50 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | static $instance = null; |
62 | 62 | |
63 | - if (null === $instance ) { |
|
63 | + if (null === $instance) { |
|
64 | 64 | |
65 | 65 | $instance = new Shortcodes(); |
66 | 66 | |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | public function register() |
79 | 79 | { |
80 | 80 | |
81 | - add_shortcode('subway_login', array( $this, 'loginForm' )); |
|
81 | + add_shortcode('subway_login', array($this, 'loginForm')); |
|
82 | 82 | |
83 | - add_action('login_form_middle', array( $this, 'loginFormAction' ), 10, 2); |
|
83 | + add_action('login_form_middle', array($this, 'loginFormAction'), 10, 2); |
|
84 | 84 | |
85 | - add_action('login_form_middle', array( $this, 'lostPasswordLink' ), 10, 2); |
|
85 | + add_action('login_form_middle', array($this, 'lostPasswordLink'), 10, 2); |
|
86 | 86 | |
87 | 87 | return; |
88 | 88 | |
@@ -93,15 +93,15 @@ discard block |
||
93 | 93 | * |
94 | 94 | * @return void |
95 | 95 | */ |
96 | - public function loginForm( $atts ) |
|
96 | + public function loginForm($atts) |
|
97 | 97 | { |
98 | - $atts = shortcode_atts( array( |
|
98 | + $atts = shortcode_atts(array( |
|
99 | 99 | 'echo' => true, |
100 | 100 | 'form_id' => 'loginform', |
101 | - 'label_username' => __( 'Username', 'subway' ), |
|
102 | - 'label_password' => __( 'Password', 'subway' ), |
|
103 | - 'label_remember' => __( 'Remember Me', 'subway' ), |
|
104 | - 'label_log_in' => __( 'Log In', 'subway' ), |
|
101 | + 'label_username' => __('Username', 'subway'), |
|
102 | + 'label_password' => __('Password', 'subway'), |
|
103 | + 'label_remember' => __('Remember Me', 'subway'), |
|
104 | + 'label_log_in' => __('Log In', 'subway'), |
|
105 | 105 | 'id_username' => 'user_login', |
106 | 106 | 'id_password' => 'user_pass', |
107 | 107 | 'id_remember' => 'rememberme', |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | 'value_username' => '', |
111 | 111 | 'value_remember' => false, |
112 | 112 | 'redirect' => home_url(), |
113 | - ), $atts ); |
|
113 | + ), $atts); |
|
114 | 114 | |
115 | 115 | return $this->renderTemplate($atts, 'login-form.php'); |
116 | 116 | } |
@@ -123,22 +123,22 @@ discard block |
||
123 | 123 | * |
124 | 124 | * @return string The html template content. |
125 | 125 | */ |
126 | - protected function renderTemplate( $atts, $file = '' ) |
|
126 | + protected function renderTemplate($atts, $file = '') |
|
127 | 127 | { |
128 | 128 | |
129 | 129 | ob_start(); |
130 | 130 | |
131 | - if (empty($file) ) { |
|
131 | + if (empty($file)) { |
|
132 | 132 | |
133 | 133 | return; |
134 | 134 | |
135 | 135 | } |
136 | 136 | |
137 | - $template = SUBWAY_DIR_PATH . 'templates/'.$file; |
|
137 | + $template = SUBWAY_DIR_PATH . 'templates/' . $file; |
|
138 | 138 | |
139 | - if (file_exists($template) ) { |
|
139 | + if (file_exists($template)) { |
|
140 | 140 | |
141 | - $theme_template = locate_template(array('gears/shortcodes/'.$file )); |
|
141 | + $theme_template = locate_template(array('gears/shortcodes/' . $file)); |
|
142 | 142 | |
143 | 143 | if ($theme_template) { |
144 | 144 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @return string The content of our login form action. |
171 | 171 | */ |
172 | - public function loginFormAction( $__content ) |
|
172 | + public function loginFormAction($__content) |
|
173 | 173 | { |
174 | 174 | |
175 | 175 | ob_start(); |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @return string The content of our lost password link. |
189 | 189 | */ |
190 | - public function lostPasswordLink( $content ) |
|
190 | + public function lostPasswordLink($content) |
|
191 | 191 | { |
192 | 192 | |
193 | 193 | return $content . $this->renderTemplate( |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | namespace Subway; |
21 | 21 | |
22 | -if (! defined('ABSPATH') ) { |
|
22 | +if ( ! defined('ABSPATH')) { |
|
23 | 23 | return; |
24 | 24 | } |
25 | 25 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | public function __construct() |
45 | 45 | { |
46 | 46 | |
47 | - add_action('plugins_loaded', array( $this, 'subwayLocalizePlugin' )); |
|
47 | + add_action('plugins_loaded', array($this, 'subwayLocalizePlugin')); |
|
48 | 48 | |
49 | 49 | return; |
50 | 50 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | public function subwayLocalizePlugin() |
58 | 58 | { |
59 | 59 | |
60 | - load_plugin_textdomain('subway', false, basename( dirname( __FILE__ ) ) . '/languages' ); |
|
60 | + load_plugin_textdomain('subway', false, basename(dirname(__FILE__)) . '/languages'); |
|
61 | 61 | |
62 | 62 | return; |
63 | 63 |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | * @link github.com/codehaiku/subway The Plugin Repository |
18 | 18 | */ |
19 | 19 | |
20 | -if ( ! defined( 'ABSPATH' ) ) { |
|
20 | +if ( ! defined('ABSPATH')) { |
|
21 | 21 | return; |
22 | 22 | } |
23 | 23 | |
@@ -25,100 +25,100 @@ discard block |
||
25 | 25 | |
26 | 26 | $message_types = array(); |
27 | 27 | |
28 | -$http_request_login = filter_input( INPUT_GET, 'login', FILTER_SANITIZE_SPECIAL_CHARS ); |
|
28 | +$http_request_login = filter_input(INPUT_GET, 'login', FILTER_SANITIZE_SPECIAL_CHARS); |
|
29 | 29 | |
30 | -$http_request_type = filter_input( INPUT_GET, 'type', FILTER_SANITIZE_SPECIAL_CHARS ); |
|
30 | +$http_request_type = filter_input(INPUT_GET, 'type', FILTER_SANITIZE_SPECIAL_CHARS); |
|
31 | 31 | |
32 | -$http_request_logout = filter_input( INPUT_GET, 'loggedout', FILTER_SANITIZE_SPECIAL_CHARS ); |
|
32 | +$http_request_logout = filter_input(INPUT_GET, 'loggedout', FILTER_SANITIZE_SPECIAL_CHARS); |
|
33 | 33 | |
34 | -if ( isset( $http_request_login ) ) { |
|
34 | +if (isset($http_request_login)) { |
|
35 | 35 | |
36 | - if ( 'failed' === $http_request_login ) { |
|
36 | + if ('failed' === $http_request_login) { |
|
37 | 37 | |
38 | - if ( isset( $http_request_type ) ) { |
|
38 | + if (isset($http_request_type)) { |
|
39 | 39 | |
40 | 40 | $message_types = array( |
41 | 41 | |
42 | 42 | 'default' => array( |
43 | - 'message' => __( 'There was an error trying to sign-in to your account. Make sure the credentials below are correct.', 'subway' ), |
|
43 | + 'message' => __('There was an error trying to sign-in to your account. Make sure the credentials below are correct.', 'subway'), |
|
44 | 44 | ), |
45 | 45 | '__blank' => array( |
46 | - 'message' => __( 'Required: Username and Password cannot be empty.', 'subway' ), |
|
46 | + 'message' => __('Required: Username and Password cannot be empty.', 'subway'), |
|
47 | 47 | ), |
48 | 48 | '__userempty' => array( |
49 | - 'message' => __( 'Required: Username cannot be empty.', 'subway' ), |
|
49 | + 'message' => __('Required: Username cannot be empty.', 'subway'), |
|
50 | 50 | ), |
51 | 51 | '__passempty' => array( |
52 | - 'message' => __( 'Required: Password cannot be empty.', 'subway' ), |
|
52 | + 'message' => __('Required: Password cannot be empty.', 'subway'), |
|
53 | 53 | ), |
54 | 54 | 'fb_invalid_email' => array( |
55 | - 'message' => __( 'Facebook email address is invalid or is not yet verified.', 'subway' ), |
|
55 | + 'message' => __('Facebook email address is invalid or is not yet verified.', 'subway'), |
|
56 | 56 | ), |
57 | 57 | 'fb_error' => array( |
58 | - 'message' => __( 'Facebook Application Error. Misconfigured or App is rejected.', 'subway' ), |
|
58 | + 'message' => __('Facebook Application Error. Misconfigured or App is rejected.', 'subway'), |
|
59 | 59 | ), |
60 | 60 | 'app_not_live' => array( |
61 | - 'message' => __( 'Unable to fetch your Facebook Profile.', 'subway' ), |
|
61 | + 'message' => __('Unable to fetch your Facebook Profile.', 'subway'), |
|
62 | 62 | ), |
63 | 63 | 'gears_username_or_email_exists' => array( |
64 | - 'message' => __( 'Username or email address already exists', 'subway' ), |
|
64 | + 'message' => __('Username or email address already exists', 'subway'), |
|
65 | 65 | ), |
66 | 66 | 'gp_error_authentication' => array( |
67 | - 'message' => __( 'Google Plus Authentication Error. Invalid Client ID or Secret.', 'subway' ), |
|
67 | + 'message' => __('Google Plus Authentication Error. Invalid Client ID or Secret.', 'subway'), |
|
68 | 68 | ), |
69 | 69 | ); |
70 | 70 | |
71 | 71 | $message = $message_types['default']['message']; |
72 | 72 | |
73 | - if ( array_key_exists( $http_request_type, $message_types ) ) { |
|
73 | + if (array_key_exists($http_request_type, $message_types)) { |
|
74 | 74 | |
75 | - $message = $message_types[ $http_request_type ]['message']; |
|
75 | + $message = $message_types[$http_request_type]['message']; |
|
76 | 76 | |
77 | 77 | } |
78 | 78 | |
79 | - $error_login_message = '<div id="message" class="error">' . esc_html( $message ) . '</div>'; |
|
79 | + $error_login_message = '<div id="message" class="error">' . esc_html($message) . '</div>'; |
|
80 | 80 | |
81 | 81 | } else { |
82 | 82 | |
83 | - $error_login_message = '<div id="message" class="error">' . esc_html__( 'Error: Invalid username and password combination.', 'subway' ) . '</div>'; |
|
83 | + $error_login_message = '<div id="message" class="error">' . esc_html__('Error: Invalid username and password combination.', 'subway') . '</div>'; |
|
84 | 84 | |
85 | 85 | } |
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | -if ( isset( $http_request_logout ) ) { |
|
90 | - $error_login_message = '<div id="message" class="success">' . esc_html__( 'You have logged out successfully.', 'subway' ) . '</div>'; |
|
89 | +if (isset($http_request_logout)) { |
|
90 | + $error_login_message = '<div id="message" class="success">' . esc_html__('You have logged out successfully.', 'subway') . '</div>'; |
|
91 | 91 | } |
92 | 92 | |
93 | -$http_request_redirected = filter_input( INPUT_GET, '_redirected', FILTER_SANITIZE_SPECIAL_CHARS ); |
|
93 | +$http_request_redirected = filter_input(INPUT_GET, '_redirected', FILTER_SANITIZE_SPECIAL_CHARS); |
|
94 | 94 | |
95 | -if ( isset( $http_request_redirected ) ) { |
|
96 | - $error_login_message = '<div id="message" class="success">' . esc_html__( 'Members only page. Please use the login form below to access the page.', 'subway' ) . '</div>'; |
|
95 | +if (isset($http_request_redirected)) { |
|
96 | + $error_login_message = '<div id="message" class="success">' . esc_html__('Members only page. Please use the login form below to access the page.', 'subway') . '</div>'; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | ?> |
100 | -<?php if ( ! is_user_logged_in() ) { ?> |
|
100 | +<?php if ( ! is_user_logged_in()) { ?> |
|
101 | 101 | <div class="mg-top-35 mg-bottom-35 subway-login-form"> |
102 | 102 | <div class="subway-login-form-form"> |
103 | 103 | <div class="subway-login-form__actions"> |
104 | 104 | <h3> |
105 | - <?php esc_html_e( 'Account Sign-in', 'subway' ); ?> |
|
105 | + <?php esc_html_e('Account Sign-in', 'subway'); ?> |
|
106 | 106 | </h3> |
107 | - <?php do_action( 'gears_login_form' ); ?> |
|
107 | + <?php do_action('gears_login_form'); ?> |
|
108 | 108 | </div> |
109 | 109 | <div class="subway-login-form-message"> |
110 | - <?php echo wp_kses_post( $error_login_message ); ?> |
|
110 | + <?php echo wp_kses_post($error_login_message); ?> |
|
111 | 111 | </div> |
112 | 112 | <div class="subway-login-form__form"> |
113 | - <?php echo wp_login_form( $atts ); ?> |
|
113 | + <?php echo wp_login_form($atts); ?> |
|
114 | 114 | </div> |
115 | 115 | </div> |
116 | 116 | </div> |
117 | 117 | <?php } else { ?> |
118 | 118 | <div class="mg-top-35 mg-bottom-35 subway-login-sucessfull" style="background: #CDDC39; padding: 15px 15px 15px 15px;border-radius: 4px;color: #616161;"> |
119 | 119 | <p style="margin-bottom: 0px;"> |
120 | - <?php $success_message = apply_filters( 'subway_login_message_success', esc_html__( 'Great! You have succesfully logged in.', 'subway' ) ); ?> |
|
121 | - <?php echo esc_html( $success_message ); ?> |
|
120 | + <?php $success_message = apply_filters('subway_login_message_success', esc_html__('Great! You have succesfully logged in.', 'subway')); ?> |
|
121 | + <?php echo esc_html($success_message); ?> |
|
122 | 122 | </p> |
123 | 123 | </div> |
124 | 124 | <?php } ?> |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | namespace Subway; |
21 | 21 | |
22 | -if (! defined('ABSPATH') ) { |
|
22 | +if ( ! defined('ABSPATH')) { |
|
23 | 23 | return; |
24 | 24 | } |
25 | 25 | |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | |
52 | 52 | $pwd = filter_input(INPUT_POST, 'pwd', FILTER_SANITIZE_STRING); |
53 | 53 | |
54 | - if (empty($log) && empty($pwd) ) { |
|
54 | + if (empty($log) && empty($pwd)) { |
|
55 | 55 | |
56 | 56 | $response['type'] = 'error'; |
57 | 57 | |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | $response = array(); |
68 | 68 | |
69 | - if (is_wp_error($is_signin) ) { |
|
69 | + if (is_wp_error($is_signin)) { |
|
70 | 70 | |
71 | 71 | $response['type'] = 'error'; |
72 | 72 | |
@@ -105,24 +105,24 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @return string The final redirect url. |
107 | 107 | */ |
108 | - public static function getLoginRedirectUrl( $redirect_to, $user ) |
|
108 | + public static function getLoginRedirectUrl($redirect_to, $user) |
|
109 | 109 | { |
110 | 110 | |
111 | 111 | $subway_redirect_type = get_option('subway_redirect_type'); |
112 | 112 | |
113 | 113 | // Redirect the user to default behaviour. |
114 | 114 | // If there are no redirect type option saved. |
115 | - if (empty($subway_redirect_type) ) { |
|
115 | + if (empty($subway_redirect_type)) { |
|
116 | 116 | |
117 | 117 | return $redirect_to; |
118 | 118 | |
119 | 119 | } |
120 | 120 | |
121 | - if ('default' === $subway_redirect_type ) { |
|
121 | + if ('default' === $subway_redirect_type) { |
|
122 | 122 | return $redirect_to; |
123 | 123 | } |
124 | 124 | |
125 | - if ('page' === $subway_redirect_type ) { |
|
125 | + if ('page' === $subway_redirect_type) { |
|
126 | 126 | |
127 | 127 | // Get the page url of the selected page. |
128 | 128 | // If the admin selected 'Custom Page' in the redirect type settings. |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | |
131 | 131 | // Redirect to default WordPress behaviour. |
132 | 132 | // If the user did not select page. |
133 | - if (empty($selected_redirect_page) ) { |
|
133 | + if (empty($selected_redirect_page)) { |
|
134 | 134 | |
135 | 135 | return $redirect_to; |
136 | 136 | } |
@@ -139,14 +139,14 @@ discard block |
||
139 | 139 | // and let the user go into that page. |
140 | 140 | return get_permalink($selected_redirect_page); |
141 | 141 | |
142 | - } elseif ('custom_url' === $subway_redirect_type ) { |
|
142 | + } elseif ('custom_url' === $subway_redirect_type) { |
|
143 | 143 | |
144 | 144 | // Get the custom url saved in the redirect type settings. |
145 | 145 | $entered_custom_url = get_option('subway_redirect_custom_url'); |
146 | 146 | |
147 | 147 | // Redirect to default WordPress behaviour |
148 | 148 | // if the user did enter a custom url. |
149 | - if (empty($entered_custom_url) ) { |
|
149 | + if (empty($entered_custom_url)) { |
|
150 | 150 | |
151 | 151 | return $redirect_to; |
152 | 152 | |
@@ -154,14 +154,14 @@ discard block |
||
154 | 154 | |
155 | 155 | // Otherwise, get the custom url saved |
156 | 156 | // and let the user go into that page. |
157 | - if (! empty($user->ID) ) { |
|
157 | + if ( ! empty($user->ID)) { |
|
158 | 158 | $entered_custom_url = str_replace( |
159 | 159 | '%user_id%', $user->ID, |
160 | 160 | $entered_custom_url |
161 | 161 | ); |
162 | 162 | } |
163 | 163 | |
164 | - if (! empty($user->user_login) ) { |
|
164 | + if ( ! empty($user->user_login)) { |
|
165 | 165 | $entered_custom_url = str_replace( |
166 | 166 | '%user_name%', $user->user_login, |
167 | 167 | $entered_custom_url |
@@ -183,13 +183,13 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return string The final login url. |
185 | 185 | */ |
186 | - public static function loginUrl( $login_url ) |
|
186 | + public static function loginUrl($login_url) |
|
187 | 187 | { |
188 | 188 | |
189 | 189 | $subway_login_page = Options::getRedirectPageUrl(); |
190 | 190 | |
191 | 191 | // Return the default login url if there is no log-in page defined. |
192 | - if (empty($subway_login_page) ) { |
|
192 | + if (empty($subway_login_page)) { |
|
193 | 193 | return $login_url; |
194 | 194 | } |
195 | 195 |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | |
20 | 20 | namespace Subway; |
21 | 21 | |
22 | -if (! defined('ABSPATH') ) { |
|
22 | +if ( ! defined('ABSPATH')) { |
|
23 | 23 | return; |
24 | 24 | } |
25 | 25 | |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | |
47 | 47 | // Additional filter for custom pages, taxonomy, links, parameterized urls, etc. |
48 | 48 | // Callback function/method must return true (boolean) to disable redirect. |
49 | - $should_exit = apply_filters( 'subway/classes/subway-page-redirect/index/before-page-redirect', false ); |
|
49 | + $should_exit = apply_filters('subway/classes/subway-page-redirect/index/before-page-redirect', false); |
|
50 | 50 | |
51 | - if ( $should_exit ) { |
|
51 | + if ($should_exit) { |
|
52 | 52 | return; |
53 | 53 | } |
54 | 54 | |
55 | 55 | // Only execute for non logged in users. |
56 | - if (is_user_logged_in() ) { |
|
56 | + if (is_user_logged_in()) { |
|
57 | 57 | return; |
58 | 58 | } |
59 | 59 | |
@@ -71,44 +71,44 @@ discard block |
||
71 | 71 | // do_action( 'subway/classes/subway-page-redirect/index/before_page_redirect' ); |
72 | 72 | |
73 | 73 | // Turn off if is in 'wc-ajax' (woocommerce) |
74 | - if ( function_exists( 'is_ajax') ) { |
|
75 | - if ( is_ajax() ) { |
|
74 | + if (function_exists('is_ajax')) { |
|
75 | + if (is_ajax()) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | 80 | // Same for normal ajax requests. |
81 | - if ( is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX ) { |
|
81 | + if (is_admin() && defined('DOING_AJAX') && DOING_AJAX) { |
|
82 | 82 | return; |
83 | 83 | } |
84 | 84 | |
85 | 85 | // Exit if site is public. |
86 | - if (Options::isPublicSite() ) { |
|
86 | + if (Options::isPublicSite()) { |
|
87 | 87 | return; |
88 | 88 | } |
89 | 89 | |
90 | 90 | // Check if redirect page is empty or not. |
91 | - if (empty($redirect_page) ) { |
|
91 | + if (empty($redirect_page)) { |
|
92 | 92 | return; |
93 | 93 | } |
94 | 94 | |
95 | 95 | // Check if buddypress activate page. |
96 | - if (function_exists('bp_is_activation_page') ) { |
|
97 | - if (bp_is_activation_page() ) { |
|
96 | + if (function_exists('bp_is_activation_page')) { |
|
97 | + if (bp_is_activation_page()) { |
|
98 | 98 | return; |
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | 102 | // Check if buddypress registration page. |
103 | - if (function_exists('bp_is_register_page') ) { |
|
104 | - if (bp_is_register_page() ) { |
|
103 | + if (function_exists('bp_is_register_page')) { |
|
104 | + if (bp_is_register_page()) { |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | } |
108 | 108 | |
109 | 109 | // Assign 0 value to empty $post->ID to prevent exception. |
110 | 110 | // This applies to custom WordPress pages such as BP Members Page and Groups. |
111 | - if (empty($current_post) ) { |
|
111 | + if (empty($current_post)) { |
|
112 | 112 | $current_post = new \stdclass; |
113 | 113 | $current_post->ID = 0; |
114 | 114 | } |
@@ -120,22 +120,22 @@ discard block |
||
120 | 120 | // The ID of the first post object inside the loop is not correct. |
121 | 121 | $blog_id = absint(get_option('page_for_posts')); |
122 | 122 | |
123 | - if (is_home() ) { |
|
124 | - if ($blog_id === $login_page_id ) { |
|
123 | + if (is_home()) { |
|
124 | + if ($blog_id === $login_page_id) { |
|
125 | 125 | $current_page_id = $blog_id; |
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | 129 | // Only execute the script for non-loggedin visitors. |
130 | - if (! is_user_logged_in() ) { |
|
130 | + if ( ! is_user_logged_in()) { |
|
131 | 131 | |
132 | - if ($current_page_id !== $login_page_id ) { |
|
132 | + if ($current_page_id !== $login_page_id) { |
|
133 | 133 | |
134 | - if (! in_array($current_page_id, $excluded_page, true) ) { |
|
134 | + if ( ! in_array($current_page_id, $excluded_page, true)) { |
|
135 | 135 | |
136 | 136 | wp_safe_redirect( |
137 | 137 | add_query_arg( |
138 | - array( '_redirected' => 'yes' ), |
|
138 | + array('_redirected' => 'yes'), |
|
139 | 139 | $redirect_page |
140 | 140 | ) |
141 | 141 | ); |