Passed
Push — master ( 54f7d9...dbb97a )
by Joseph
20s
created
subway.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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';
@@ -96,23 +96,23 @@  discard block
 block discarded – undo
96 96
 require_once SUBWAY_DIR_PATH . 'shortcodes/subway-shortcodes.php';
97 97
 
98 98
 // Redirect (302) all front-end request to the login page.
99
-add_action( 'wp', array( 'Subway\PageRedirect', 'index' ) );
99
+add_action('wp', array('Subway\PageRedirect', 'index'));
100 100
 
101 101
 // Redirect (302) invalid login request to the login page.
102
-add_action( 'wp_ajax_nopriv_subway_logging_in', array( 'Subway\AuthRedirect', 'handleAuthentication' ) );
102
+add_action('wp_ajax_nopriv_subway_logging_in', array('Subway\AuthRedirect', 'handleAuthentication'));
103 103
 
104 104
 // Load our JS and CSS files.
105
-add_action( 'wp_enqueue_scripts', array( 'Subway\Enqueue', 'registerJs' ) );
105
+add_action('wp_enqueue_scripts', array('Subway\Enqueue', 'registerJs'));
106 106
 
107 107
 // Change the default login url to our sign-in page.
108
-add_filter( 'login_url', array( 'Subway\AuthRedirect', 'loginUrl' ), 10, 3 );
108
+add_filter('login_url', array('Subway\AuthRedirect', 'loginUrl'), 10, 3);
109 109
 
110 110
 // Redirect the user after successful logged in to the right page.
111 111
 // Does not trigger when using ajax form. Only on default wp-login.php and wp_login_form().
112
-add_filter( 'login_redirect', array( 'Subway\AuthRedirect', 'getLoginRedirectUrl' ), 10, 3 );
112
+add_filter('login_redirect', array('Subway\AuthRedirect', 'getLoginRedirectUrl'), 10, 3);
113 113
 
114 114
 // Change the default logout url to our sign-in page.
115
-add_action( 'wp_logout', array( 'Subway\AuthRedirect', 'logoutUrl' ), 10, 3 );
115
+add_action('wp_logout', array('Subway\AuthRedirect', 'logoutUrl'), 10, 3);
116 116
 
117 117
 // Adds the Subvway metabox.
118
-add_action( 'plugins_loaded', array( 'Subway\Metabox', 'initMetabox' ) );
118
+add_action('plugins_loaded', array('Subway\Metabox', 'initMetabox'));
Please login to merge, or discard this patch.
admin-settings.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
 namespace Subway;
21 21
 
22
-if (! defined('ABSPATH') ) {
22
+if ( ! defined('ABSPATH')) {
23 23
     return;
24 24
 }
25 25
 
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
     public function __construct()
43 43
     {
44 44
 
45
-        add_action('admin_menu', array( $this, 'adminMenu' ));
45
+        add_action('admin_menu', array($this, 'adminMenu'));
46 46
 
47
-        add_action('admin_init', array( $this, 'registerSettings' ));
47
+        add_action('admin_init', array($this, 'registerSettings'));
48 48
 
49 49
     }
50 50
 
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 
59 59
         add_options_page(
60 60
             'Subway Settings', 'Subway', 'manage_options',
61
-            'subway', array( $this, 'optionsPage' )
61
+            'subway', array($this, 'optionsPage')
62 62
         );
63 63
 
64
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueueSettingsScripts' ) );
64
+		add_action('admin_enqueue_scripts', array($this, 'enqueueSettingsScripts'));
65 65
 
66 66
         return;
67 67
     }
@@ -77,19 +77,19 @@  discard block
 block discarded – undo
77 77
         // Register our settings section.
78 78
         add_settings_section(
79 79
             'subway-page-visibility-section', __('Pages Visibility', 'subway'),
80
-            array( $this, 'sectionCallback' ), 'subway-settings-section'
80
+            array($this, 'sectionCallback'), 'subway-settings-section'
81 81
         );
82 82
 
83 83
         // Register Redirect Options pages.
84 84
         add_settings_section(
85 85
             'subway-redirect-section', __('Redirect Options', 'subway'),
86
-            array( $this, 'redirectCallback' ), 'subway-settings-section'
86
+            array($this, 'redirectCallback'), 'subway-settings-section'
87 87
         );
88 88
 
89 89
 		$is_public_site = Options::isPublicSite();
90 90
 		$hidden_class = '';
91 91
 
92
-		if ( $is_public_site ) {
92
+		if ($is_public_site) {
93 93
 			$hidden_class = 'hidden';
94 94
 		}
95 95
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             ),
155 155
         );
156 156
 
157
-        foreach ( $fields as $field ) {
157
+        foreach ($fields as $field) {
158 158
 
159 159
             add_settings_field(
160 160
                 $field['id'], $field['label'],
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
 	public function registerSettingsScripts() {
240 240
 
241 241
 		// Registers the Subway settings Javascript.
242
-	    wp_register_script( 'subway-settings-script', plugins_url('/assets/js/settings.js', __FILE__) );
243
-	    wp_register_style( 'subway-settings-style', plugins_url('/assets/css/settings.css', __FILE__) );
242
+	    wp_register_script('subway-settings-script', plugins_url('/assets/js/settings.js', __FILE__));
243
+	    wp_register_style('subway-settings-style', plugins_url('/assets/css/settings.css', __FILE__));
244 244
 	 }
245 245
 
246 246
 	/**
@@ -251,12 +251,12 @@  discard block
 block discarded – undo
251 251
      * @return void
252 252
      * @return void
253 253
      */
254
-	public function enqueueSettingsScripts( $hook ) {
254
+	public function enqueueSettingsScripts($hook) {
255 255
 		// Checks if page hook is Subway settings page.
256
-		if ( 'settings_page_subway' === $hook ) {
256
+		if ('settings_page_subway' === $hook) {
257 257
 			// Enqueues the script only on the Subway Settings page.
258
-			wp_enqueue_script( 'subway-settings-script' );
259
-			wp_enqueue_style( 'subway-settings-style' );
258
+			wp_enqueue_script('subway-settings-script');
259
+			wp_enqueue_style('subway-settings-style');
260 260
 		}
261 261
 	}
262 262
 }
Please login to merge, or discard this patch.
settings-fields/field-subway-login-page-form.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @package Subway
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	return;
15 15
 }
16 16
 
@@ -21,24 +21,24 @@  discard block
 block discarded – undo
21 21
  */
22 22
 function subway_login_page_form() {
23 23
 
24
-	$subway_login_page_id = intval( get_option( 'subway_login_page' ) );
24
+	$subway_login_page_id = intval(get_option('subway_login_page'));
25 25
 
26
-	if ( ! empty( $subway_login_page_id ) ) {
26
+	if ( ! empty($subway_login_page_id)) {
27 27
 
28
-		$login_page_object = get_post( $subway_login_page_id );
28
+		$login_page_object = get_post($subway_login_page_id);
29 29
 
30
-		if ( ! empty( $login_page_object )  && isset( $login_page_object->post_content ) ) {
30
+		if ( ! empty($login_page_object) && isset($login_page_object->post_content)) {
31 31
 
32 32
 			// Automatically prepend the login shortcode if no
33 33
 			// Shortcode exists in the selected login page.
34
-			if ( ! has_shortcode( $login_page_object->post_content, 'subway_login' ) ) {
34
+			if ( ! has_shortcode($login_page_object->post_content, 'subway_login')) {
35 35
 
36 36
 				$new_post_object = array(
37 37
 				  'ID' => $login_page_object->ID,
38
-				  'post_content' => '[subway_login] ' . $login_page_object->post_content,// Prepend Only.
38
+				  'post_content' => '[subway_login] ' . $login_page_object->post_content, // Prepend Only.
39 39
 				 );
40 40
 
41
-				wp_update_post( $new_post_object );
41
+				wp_update_post($new_post_object);
42 42
 			}
43 43
 		}
44 44
 	}
@@ -46,12 +46,12 @@  discard block
 block discarded – undo
46 46
 	wp_dropdown_pages(
47 47
 		array(
48 48
 		'name' => 'subway_login_page',
49
-		'selected' => intval( $subway_login_page_id ),
50
-		'show_option_none' => esc_html__( '---', 'subway' ),
49
+		'selected' => intval($subway_login_page_id),
50
+		'show_option_none' => esc_html__('---', 'subway'),
51 51
 		)
52 52
 	);
53 53
 
54
-	echo '<p class="description">' . sprintf( esc_html__( 'Select a login page and save the changes to make your site private. Selecting "---" (blank) will make your site public. %1$s.', 'subway' ), '<span class="subway-settings-notice">' . esc_html__( 'You need to add "[subway_login]" shortcode in the selected page to show the login form (this will be done automatically after saving)', 'subway' ) ) . '</span></p>';
54
+	echo '<p class="description">' . sprintf(esc_html__('Select a login page and save the changes to make your site private. Selecting "---" (blank) will make your site public. %1$s.', 'subway'), '<span class="subway-settings-notice">' . esc_html__('You need to add "[subway_login]" shortcode in the selected page to show the login form (this will be done automatically after saving)', 'subway')) . '</span></p>';
55 55
 
56 56
 	return;
57 57
 }
Please login to merge, or discard this patch.
settings-fields/field-subway-is-public-form.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @package Subway
11 11
  */
12 12
 
13
-if ( ! defined( 'ABSPATH' ) ) {
13
+if ( ! defined('ABSPATH')) {
14 14
 	return;
15 15
 }
16 16
 
@@ -21,8 +21,8 @@  discard block
 block discarded – undo
21 21
  */
22 22
 function subway_is_public_form() {
23 23
 
24
-	echo '<label for="subway_is_public"><input ' . checked( 1, get_option( 'subway_is_public' ), false ) . ' value="1" name="subway_is_public" id="subway_is_public" type="checkbox" class="code" /> Check to make all of your posts and pages visible to public.</label>';
25
-	echo '<p class="description">' . esc_html__( 'Check to ignore all private options and make your site return to its original state (public) without uninstalling Subway. All settings here and in the individual posts or pages will be ignored. Uncheck to make your site accessible to members only', 'subway' ) . '</p>';
24
+	echo '<label for="subway_is_public"><input ' . checked(1, get_option('subway_is_public'), false) . ' value="1" name="subway_is_public" id="subway_is_public" type="checkbox" class="code" /> Check to make all of your posts and pages visible to public.</label>';
25
+	echo '<p class="description">' . esc_html__('Check to ignore all private options and make your site return to its original state (public) without uninstalling Subway. All settings here and in the individual posts or pages will be ignored. Uncheck to make your site accessible to members only', 'subway') . '</p>';
26 26
 
27 27
 	return;
28 28
 }
Please login to merge, or discard this patch.
classes/subway-metabox.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 
21 21
 namespace Subway;
22 22
 
23
-if (! defined('ABSPATH') ) {
23
+if ( ! defined('ABSPATH')) {
24 24
     return;
25 25
 }
26 26
 
@@ -92,11 +92,11 @@  discard block
 block discarded – undo
92 92
     {
93 93
         $post_types = $this->getPostTypes();
94 94
 
95
-        foreach ( $post_types as $post_type => $value ) {
95
+        foreach ($post_types as $post_type => $value) {
96 96
             add_meta_box(
97 97
                 'subway_visibility_metabox',
98 98
                 esc_html__('Subway: Visibility Option', 'subway'),
99
-                array( $this, 'visibilityMetabox' ),
99
+                array($this, 'visibilityMetabox'),
100 100
                 $post_type,
101 101
                 'side',
102 102
                 'low'
@@ -113,37 +113,37 @@  discard block
 block discarded – undo
113 113
      * @access public
114 114
      * @return void
115 115
      */
116
-    public function visibilityMetabox( $post )
116
+    public function visibilityMetabox($post)
117 117
     {
118 118
         $howto = __(
119 119
             'Choose the accessibility of this page from the options above.',
120 120
             'subway'
121 121
         );
122 122
       
123
-        $private_setting_label = __( 'Members Only', 'subway'  );
123
+        $private_setting_label = __('Members Only', 'subway');
124 124
 
125 125
         $is_post_public          = self::isPostPublic($post->ID);
126 126
         $is_post_private         = self::isPostPrivate($post->ID);
127 127
 
128 128
         // Make sure the form request comes from WordPress
129
-        wp_nonce_field(  basename(__FILE__),  'subway_post_visibility_nonce' );
129
+        wp_nonce_field(basename(__FILE__), 'subway_post_visibility_nonce');
130 130
 
131 131
         // Disable the options (radio) when site is selected as public
132 132
         ?>
133 133
         
134
-        <?php if ( ! Options::isPublicSite() ):  ?>
134
+        <?php if ( ! Options::isPublicSite()):  ?>
135 135
         <?php // Site is private. Give them some Beer! ?>
136 136
             <p>
137 137
                 <label class="subway-visibility-settings-checkbox-label" for="subway-visibility-public">
138
-                    <input type="radio" class="subway-visibility-settings-radio" id="subway-visibility-public" name="subway-visibility-settings" value="public" <?php echo checked( false, $is_post_private, false); ?>>
139
-                    <?php esc_html_e( 'Public','subway') ?>
138
+                    <input type="radio" class="subway-visibility-settings-radio" id="subway-visibility-public" name="subway-visibility-settings" value="public" <?php echo checked(false, $is_post_private, false); ?>>
139
+                    <?php esc_html_e('Public', 'subway') ?>
140 140
                 </label>
141 141
             </p>
142 142
             <p>
143 143
                 <label class="subway-visibility-settings-checkbox-label" for="subway-visibility-private">
144 144
                     <input type="radio" class="subway-visibility-settings-radio" id="subway-visibility-private" name="subway-visibility-settings"
145
-                    value="private" <?php echo checked( true, $is_post_private, false); ?>>
146
-                    <?php esc_html_e( 'Members Only','subway') ?>
145
+                    value="private" <?php echo checked(true, $is_post_private, false); ?>>
146
+                    <?php esc_html_e('Members Only', 'subway') ?>
147 147
                  </label>
148 148
             </p>
149 149
             <p class="howto"><?php echo esc_html($howto); ?></p>
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
      * @access public
167 167
      * @return boolean false Returns false if nonce is not valid.
168 168
      */
169
-    public function saveVisibilityMetabox( $post_id = '' )
169
+    public function saveVisibilityMetabox($post_id = '')
170 170
     {
171 171
 
172 172
         $public_posts     = Options::getPublicPostsIdentifiers();
@@ -192,29 +192,29 @@  discard block
 block discarded – undo
192 192
         );
193 193
 
194 194
         // verify taxonomies meta box nonce
195
-        if (false === $is_valid_visibility_nonce ) {
195
+        if (false === $is_valid_visibility_nonce) {
196 196
             return;
197 197
         }
198 198
 
199
-        if (! empty($post_visibility) ) {
200
-            if (! empty($post_id) ) {
201
-                if ('public' === $post_visibility ) {
202
-                    if (! in_array($post_id, $public_posts) ) {
199
+        if ( ! empty($post_visibility)) {
200
+            if ( ! empty($post_id)) {
201
+                if ('public' === $post_visibility) {
202
+                    if ( ! in_array($post_id, $public_posts)) {
203 203
                         array_push($public_posts, $post_id);
204 204
                     }
205 205
                 }
206
-                if ('private' === $post_visibility ) {
207
-                    unset($public_posts[ array_search($post_id, $public_posts) ]);
206
+                if ('private' === $post_visibility) {
207
+                    unset($public_posts[array_search($post_id, $public_posts)]);
208 208
                 }
209 209
             }
210 210
         }
211 211
 
212
-        if (! empty($post_id) ) {
212
+        if ( ! empty($post_id)) {
213 213
             $posts_implode = implode(", ", $public_posts);
214 214
 
215
-            if ('inherit' !== get_post_status($post_id) ) {
215
+            if ('inherit' !== get_post_status($post_id)) {
216 216
 
217
-                if (true === $is_valid_visibility_nonce ) {
217
+                if (true === $is_valid_visibility_nonce) {
218 218
                     update_option('subway_public_post', $posts_implode);
219 219
                     update_post_meta(
220 220
                         $post_id,
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
      * @access public
237 237
      * @return boolean false Returns false if nonce is not valid.
238 238
      */
239
-    public function saveMetaboxValues( $post_id )
239
+    public function saveMetaboxValues($post_id)
240 240
     {
241 241
         $this->saveVisibilityMetabox($post_id);
242 242
         return;
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
      * @access public
253 253
      * @return void
254 254
      */
255
-    public static function getPostTypes( $args = '', $output = '' )
255
+    public static function getPostTypes($args = '', $output = '')
256 256
     {
257
-        if (empty($args) ) {
257
+        if (empty($args)) {
258 258
             $args = array(
259 259
             'public'   => true,
260 260
             );
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
      * @access public
276 276
      * @return boolean true Returns true if nonce is valid.
277 277
      */
278
-    public function isNonceValid( $nonce )
278
+    public function isNonceValid($nonce)
279 279
     {
280
-        if (!isset($nonce) || !wp_verify_nonce($nonce, basename(__FILE__)) ) {
280
+        if ( ! isset($nonce) || ! wp_verify_nonce($nonce, basename(__FILE__))) {
281 281
             return;
282 282
         }
283 283
 
@@ -293,23 +293,23 @@  discard block
 block discarded – undo
293 293
      * @access public
294 294
      * @return boolean true Returns true if post is private. Otherwise false.
295 295
      */
296
-    public static function isPostPrivate( $post_id )
296
+    public static function isPostPrivate($post_id)
297 297
     {
298 298
         $meta_value = '';
299 299
 
300
-        if ( ! empty( $post_id ) ) {
300
+        if ( ! empty($post_id)) {
301 301
             $meta_value = get_post_meta($post_id, self::VISIBILITY_METAKEY, true);
302 302
 
303 303
             // New page or old pages that don't have Subway'\ Visibility Options
304
-            if ( empty ( $meta_value ) ) {
304
+            if (empty ($meta_value)) {
305 305
                 // Get the value from the general settings (Settings > Subway)
306 306
                 $is_site_public = Options::isPublicSite();
307
-                if ( ! $is_site_public ) {
307
+                if ( ! $is_site_public) {
308 308
                     // It's private.
309 309
                     return true;
310 310
                 }
311 311
             }
312
-            if ('private' === $meta_value ) {
312
+            if ('private' === $meta_value) {
313 313
                 return true;
314 314
             }
315 315
         }
@@ -326,12 +326,12 @@  discard block
 block discarded – undo
326 326
      * @access public
327 327
      * @return boolean true Returns true if post is public. Otherwise false.
328 328
      */
329
-    public static function isPostPublic( $post_id )
329
+    public static function isPostPublic($post_id)
330 330
     {
331 331
         $public_post = Options::getPublicPostsIdentifiers();
332 332
 
333
-        if (! empty($post_id) ) {
334
-            if (! in_array($post_id, $public_post, true) ) {
333
+        if ( ! empty($post_id)) {
334
+            if ( ! in_array($post_id, $public_post, true)) {
335 335
                 return true;
336 336
             }
337 337
         }
Please login to merge, or discard this patch.
classes/subway-auth-redirect.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
 
20 20
 namespace Subway;
21 21
 
22
-if (! defined('ABSPATH') ) {
22
+if ( ! defined('ABSPATH')) {
23 23
     return;
24 24
 }
25 25
 
@@ -47,13 +47,13 @@  discard block
 block discarded – undo
47 47
         // Set the header type to json.
48 48
         header('Content-Type: application/json');
49 49
 
50
-        $is_signin = new \WP_Error( 'broke', __( 'Unable to authenticate user', "subway" ) );
50
+        $is_signin = new \WP_Error('broke', __('Unable to authenticate user', "subway"));
51 51
 
52 52
         $log = filter_input(INPUT_POST, 'log', FILTER_SANITIZE_STRING);
53 53
 
54 54
         $pwd = filter_input(INPUT_POST, 'pwd', FILTER_SANITIZE_STRING);
55 55
 
56
-        if (empty($log) && empty($pwd) ) {
56
+        if (empty($log) && empty($pwd)) {
57 57
 
58 58
             $response['type'] = 'error';
59 59
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 
69 69
             $response = array();
70 70
 
71
-            if (is_wp_error($is_signin) ) {
71
+            if (is_wp_error($is_signin)) {
72 72
 
73 73
                 $response['type'] = 'error';
74 74
 
@@ -108,24 +108,24 @@  discard block
 block discarded – undo
108 108
      *
109 109
      * @return string             The final redirect url.
110 110
      */
111
-    public static function getLoginRedirectUrl( $redirect_to, $user )
111
+    public static function getLoginRedirectUrl($redirect_to, $user)
112 112
     {
113 113
 
114 114
         $subway_redirect_type = get_option('subway_redirect_type');
115 115
 
116 116
         // Redirect the user to default behaviour.
117 117
         // If there are no redirect type option saved.
118
-        if (empty($subway_redirect_type) ) {
118
+        if (empty($subway_redirect_type)) {
119 119
 
120 120
             return $redirect_to;
121 121
 
122 122
         }
123 123
 
124
-        if ('default' === $subway_redirect_type ) {
124
+        if ('default' === $subway_redirect_type) {
125 125
             return $redirect_to;
126 126
         }
127 127
 
128
-        if ('page' === $subway_redirect_type ) {
128
+        if ('page' === $subway_redirect_type) {
129 129
 
130 130
             // Get the page url of the selected page.
131 131
             // If the admin selected 'Custom Page' in the redirect type settings.
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
             // Redirect to default WordPress behaviour.
135 135
             // If the user did not select page.
136
-            if (empty($selected_redirect_page) ) {
136
+            if (empty($selected_redirect_page)) {
137 137
 
138 138
                 return $redirect_to;
139 139
             }
@@ -142,14 +142,14 @@  discard block
 block discarded – undo
142 142
             // and let the user go into that page.
143 143
             return get_permalink($selected_redirect_page);
144 144
 
145
-        } elseif ('custom_url' === $subway_redirect_type ) {
145
+        } elseif ('custom_url' === $subway_redirect_type) {
146 146
 
147 147
             // Get the custom url saved in the redirect type settings.
148 148
             $entered_custom_url = get_option('subway_redirect_custom_url');
149 149
 
150 150
             // Redirect to default WordPress behaviour
151 151
             // if the user did enter a custom url.
152
-            if (empty($entered_custom_url) ) {
152
+            if (empty($entered_custom_url)) {
153 153
 
154 154
                 return $redirect_to;
155 155
 
@@ -157,14 +157,14 @@  discard block
 block discarded – undo
157 157
 
158 158
             // Otherwise, get the custom url saved
159 159
             // and let the user go into that page.
160
-            if (! empty($user->ID) ) {
160
+            if ( ! empty($user->ID)) {
161 161
                 $entered_custom_url = str_replace(
162 162
                     '%user_id%', $user->ID,
163 163
                     $entered_custom_url
164 164
                 );
165 165
             }
166 166
 
167
-            if (! empty($user->user_login) ) {
167
+            if ( ! empty($user->user_login)) {
168 168
                 $entered_custom_url = str_replace(
169 169
                     '%user_name%', $user->user_login,
170 170
                     $entered_custom_url
@@ -186,13 +186,13 @@  discard block
 block discarded – undo
186 186
      *
187 187
      * @return string            The final login url.
188 188
      */
189
-    public static function loginUrl( $login_url  )
189
+    public static function loginUrl($login_url)
190 190
     {
191 191
 
192 192
         $subway_login_page = Options::getRedirectPageUrl();
193 193
 
194 194
         // Return the default login url if there is no log-in page defined.
195
-        if (empty($subway_login_page) ) {
195
+        if (empty($subway_login_page)) {
196 196
             return $login_url;
197 197
         }
198 198
 
Please login to merge, or discard this patch.
classes/subway-page-redirect.php 1 patch
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
         
@@ -70,51 +70,51 @@  discard block
 block discarded – undo
70 70
         // Already escaped inside 'subway_get_redirect_page_url'.
71 71
         $redirect_page = Options::getRedirectPageUrl(); // WPCS XSS OK.
72 72
 
73
-        if ( !empty( $current_post ) ) {
74
-		  $is_private = Metabox::isPostPrivate( $current_post->ID );
73
+        if ( ! empty($current_post)) {
74
+		  $is_private = Metabox::isPostPrivate($current_post->ID);
75 75
         }
76 76
 
77 77
         // do_action( 'subway/classes/subway-page-redirect/index/before_page_redirect' );
78 78
 
79 79
         // Turn off if is in 'wc-ajax' (woocommerce)
80
-        if ( function_exists( 'is_ajax') ) {
81
-            if ( is_ajax() ) {
80
+        if (function_exists('is_ajax')) {
81
+            if (is_ajax()) {
82 82
                return;
83 83
             }
84 84
         }
85 85
 
86 86
         // Same for normal ajax requests.
87
-        if ( is_admin() && defined( 'DOING_AJAX' ) && DOING_AJAX  ) {
87
+        if (is_admin() && defined('DOING_AJAX') && DOING_AJAX) {
88 88
             return;
89 89
         }
90 90
 
91 91
         // Exit if site is public.
92
-        if ( Options::isPublicSite() ) {
92
+        if (Options::isPublicSite()) {
93 93
             return;
94 94
         }
95 95
 
96 96
         // Check if redirect page is empty or not.
97
-        if ( empty( $redirect_page ) ) {
97
+        if (empty($redirect_page)) {
98 98
             return;
99 99
         }
100 100
 
101 101
         // Check if buddypress activate page.
102
-        if (function_exists('bp_is_activation_page') ) {
103
-            if (bp_is_activation_page() ) {
102
+        if (function_exists('bp_is_activation_page')) {
103
+            if (bp_is_activation_page()) {
104 104
                 return;
105 105
             }
106 106
         }
107 107
 
108 108
         // Check if buddypress registration page.
109
-        if (function_exists('bp_is_register_page') ) {
110
-            if (bp_is_register_page() ) {
109
+        if (function_exists('bp_is_register_page')) {
110
+            if (bp_is_register_page()) {
111 111
                 return;
112 112
             }
113 113
         }
114 114
 
115 115
         // Assign 0 value to empty $post->ID to prevent exception.
116 116
         // This applies to custom WordPress pages such as BP Members Page and Groups.
117
-        if (empty($current_post) ) {
117
+        if (empty($current_post)) {
118 118
             $current_post = new \stdclass;
119 119
             $current_post->ID = 0;
120 120
         }
@@ -126,22 +126,22 @@  discard block
 block discarded – undo
126 126
         // The ID of the first post object inside the loop is not correct.
127 127
         $blog_id = absint(get_option('page_for_posts'));
128 128
 
129
-        if (is_home() ) {
130
-            if ($blog_id === $login_page_id ) {
129
+        if (is_home()) {
130
+            if ($blog_id === $login_page_id) {
131 131
                 $current_page_id = $blog_id;
132 132
             }
133 133
         }
134 134
 
135 135
         // Only execute the script for non-loggedin visitors.
136
-        if ( ! is_user_logged_in() ) {
136
+        if ( ! is_user_logged_in()) {
137 137
 
138
-            if ($current_page_id !== $login_page_id ) {
138
+            if ($current_page_id !== $login_page_id) {
139 139
 
140
-                if ( ! in_array( $current_page_id, $excluded_page, true ) || in_array( $current_page_id, $excluded_page, true ) && true === $is_private ) {
140
+                if ( ! in_array($current_page_id, $excluded_page, true) || in_array($current_page_id, $excluded_page, true) && true === $is_private) {
141 141
 
142 142
                     wp_safe_redirect(
143 143
                         add_query_arg(
144
-                            array( '_redirected' => 'yes' ),
144
+                            array('_redirected' => 'yes'),
145 145
                             $redirect_page
146 146
                         )
147 147
                     );
Please login to merge, or discard this patch.