Passed
Pull Request — master (#19)
by
unknown
02:03
created
classes/subway-page-redirect.php 2 patches
Indentation   +89 added lines, -89 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 namespace Subway;
21 21
 
22 22
 if (! defined('ABSPATH') ) {
23
-    return;
23
+	return;
24 24
 }
25 25
 
26 26
 /**
@@ -36,94 +36,94 @@  discard block
 block discarded – undo
36 36
 final class PageRedirect
37 37
 {
38 38
 
39
-    /**
40
-     * Redirects pages into our login page.
41
-     *
42
-     * @return void.
43
-     */
44
-    public static function index() 
45
-    {
46
-
47
-        // Only execute for non logged in users.
48
-        if (is_user_logged_in() ) {
49
-            return;
50
-        }
51
-
52
-        $queried_id = get_queried_object_id();
53
-
54
-        $current_post = get_post(absint($queried_id));
55
-
56
-        $login_page_id = absint(get_option('subway_login_page'));
57
-
58
-        $excluded_page = Options::getPublicPostsIdentifiers();
59
-
60
-        // Already escaped inside 'subway_get_redirect_page_url'.
61
-        $redirect_page = Options::getRedirectPageUrl(); // WPCS XSS OK.
62
-
63
-        // Exit if site is public.
64
-        if (Options::isPublicSite() ) {
65
-            return;
66
-        }
67
-
68
-        // Check if redirect page is empty or not.
69
-        if (empty($redirect_page) ) {
70
-            return;
71
-        }
72
-
73
-        // Check if buddypress activate page.
74
-        if (function_exists('bp_is_activation_page') ) {
75
-            if (bp_is_activation_page() ) {
76
-                return;
77
-            }
78
-        }
79
-
80
-        // Check if buddypress registration page.
81
-        if (function_exists('bp_is_register_page') ) {
82
-            if (bp_is_register_page() ) {
83
-                return;
84
-            }
85
-        }
86
-
87
-        // Assign 0 value to empty $post->ID to prevent exception.
88
-        // This applies to custom WordPress pages such as BP Members Page and Groups.
89
-        if (empty($current_post) ) {
90
-            $current_post = new \stdclass;
91
-            $current_post->ID = 0;
92
-        }
93
-
94
-        $current_page_id = absint($current_post->ID);
95
-
96
-        // Check if $current_page_id && $selected_blog_id is equal to each other.
97
-        // Get the page ID instead of global $post->ID that the query returns.
98
-        // The ID of the first post object inside the loop is not correct.
99
-        $blog_id = absint(get_option('page_for_posts'));
100
-
101
-        if (is_home() ) {
102
-            if ($blog_id === $login_page_id ) {
103
-                $current_page_id = $blog_id;
104
-            }
105
-        }
106
-
107
-        // Only execute the script for non-loggedin visitors.
108
-        if (! is_user_logged_in() ) {
109
-
110
-            if ($current_page_id !== $login_page_id ) {
111
-                $excluded_page = apply_filters( 'subway_excluded_page', $excluded_page, $current_page_id );
112
-
113
-                if (! in_array($current_page_id, $excluded_page, true) ) {
114
-
115
-                    wp_safe_redirect(
116
-                        add_query_arg(
117
-                            array( '_redirected' => 'yes' ),
118
-                            $redirect_page
119
-                        )
120
-                    );
121
-
122
-                    Helpers::close();
123
-                }
124
-            }
125
-        }
126
-    }
39
+	/**
40
+	 * Redirects pages into our login page.
41
+	 *
42
+	 * @return void.
43
+	 */
44
+	public static function index() 
45
+	{
46
+
47
+		// Only execute for non logged in users.
48
+		if (is_user_logged_in() ) {
49
+			return;
50
+		}
51
+
52
+		$queried_id = get_queried_object_id();
53
+
54
+		$current_post = get_post(absint($queried_id));
55
+
56
+		$login_page_id = absint(get_option('subway_login_page'));
57
+
58
+		$excluded_page = Options::getPublicPostsIdentifiers();
59
+
60
+		// Already escaped inside 'subway_get_redirect_page_url'.
61
+		$redirect_page = Options::getRedirectPageUrl(); // WPCS XSS OK.
62
+
63
+		// Exit if site is public.
64
+		if (Options::isPublicSite() ) {
65
+			return;
66
+		}
67
+
68
+		// Check if redirect page is empty or not.
69
+		if (empty($redirect_page) ) {
70
+			return;
71
+		}
72
+
73
+		// Check if buddypress activate page.
74
+		if (function_exists('bp_is_activation_page') ) {
75
+			if (bp_is_activation_page() ) {
76
+				return;
77
+			}
78
+		}
79
+
80
+		// Check if buddypress registration page.
81
+		if (function_exists('bp_is_register_page') ) {
82
+			if (bp_is_register_page() ) {
83
+				return;
84
+			}
85
+		}
86
+
87
+		// Assign 0 value to empty $post->ID to prevent exception.
88
+		// This applies to custom WordPress pages such as BP Members Page and Groups.
89
+		if (empty($current_post) ) {
90
+			$current_post = new \stdclass;
91
+			$current_post->ID = 0;
92
+		}
93
+
94
+		$current_page_id = absint($current_post->ID);
95
+
96
+		// Check if $current_page_id && $selected_blog_id is equal to each other.
97
+		// Get the page ID instead of global $post->ID that the query returns.
98
+		// The ID of the first post object inside the loop is not correct.
99
+		$blog_id = absint(get_option('page_for_posts'));
100
+
101
+		if (is_home() ) {
102
+			if ($blog_id === $login_page_id ) {
103
+				$current_page_id = $blog_id;
104
+			}
105
+		}
106
+
107
+		// Only execute the script for non-loggedin visitors.
108
+		if (! is_user_logged_in() ) {
109
+
110
+			if ($current_page_id !== $login_page_id ) {
111
+				$excluded_page = apply_filters( 'subway_excluded_page', $excluded_page, $current_page_id );
112
+
113
+				if (! in_array($current_page_id, $excluded_page, true) ) {
114
+
115
+					wp_safe_redirect(
116
+						add_query_arg(
117
+							array( '_redirected' => 'yes' ),
118
+							$redirect_page
119
+						)
120
+					);
121
+
122
+					Helpers::close();
123
+				}
124
+			}
125
+		}
126
+	}
127 127
 
128 128
 }
129 129
 
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 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
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     {
46 46
 
47 47
         // Only execute for non logged in users.
48
-        if (is_user_logged_in() ) {
48
+        if (is_user_logged_in()) {
49 49
             return;
50 50
         }
51 51
 
@@ -61,32 +61,32 @@  discard block
 block discarded – undo
61 61
         $redirect_page = Options::getRedirectPageUrl(); // WPCS XSS OK.
62 62
 
63 63
         // Exit if site is public.
64
-        if (Options::isPublicSite() ) {
64
+        if (Options::isPublicSite()) {
65 65
             return;
66 66
         }
67 67
 
68 68
         // Check if redirect page is empty or not.
69
-        if (empty($redirect_page) ) {
69
+        if (empty($redirect_page)) {
70 70
             return;
71 71
         }
72 72
 
73 73
         // Check if buddypress activate page.
74
-        if (function_exists('bp_is_activation_page') ) {
75
-            if (bp_is_activation_page() ) {
74
+        if (function_exists('bp_is_activation_page')) {
75
+            if (bp_is_activation_page()) {
76 76
                 return;
77 77
             }
78 78
         }
79 79
 
80 80
         // Check if buddypress registration page.
81
-        if (function_exists('bp_is_register_page') ) {
82
-            if (bp_is_register_page() ) {
81
+        if (function_exists('bp_is_register_page')) {
82
+            if (bp_is_register_page()) {
83 83
                 return;
84 84
             }
85 85
         }
86 86
 
87 87
         // Assign 0 value to empty $post->ID to prevent exception.
88 88
         // This applies to custom WordPress pages such as BP Members Page and Groups.
89
-        if (empty($current_post) ) {
89
+        if (empty($current_post)) {
90 90
             $current_post = new \stdclass;
91 91
             $current_post->ID = 0;
92 92
         }
@@ -98,23 +98,23 @@  discard block
 block discarded – undo
98 98
         // The ID of the first post object inside the loop is not correct.
99 99
         $blog_id = absint(get_option('page_for_posts'));
100 100
 
101
-        if (is_home() ) {
102
-            if ($blog_id === $login_page_id ) {
101
+        if (is_home()) {
102
+            if ($blog_id === $login_page_id) {
103 103
                 $current_page_id = $blog_id;
104 104
             }
105 105
         }
106 106
 
107 107
         // Only execute the script for non-loggedin visitors.
108
-        if (! is_user_logged_in() ) {
108
+        if ( ! is_user_logged_in()) {
109 109
 
110
-            if ($current_page_id !== $login_page_id ) {
111
-                $excluded_page = apply_filters( 'subway_excluded_page', $excluded_page, $current_page_id );
110
+            if ($current_page_id !== $login_page_id) {
111
+                $excluded_page = apply_filters('subway_excluded_page', $excluded_page, $current_page_id);
112 112
 
113
-                if (! in_array($current_page_id, $excluded_page, true) ) {
113
+                if ( ! in_array($current_page_id, $excluded_page, true)) {
114 114
 
115 115
                     wp_safe_redirect(
116 116
                         add_query_arg(
117
-                            array( '_redirected' => 'yes' ),
117
+                            array('_redirected' => 'yes'),
118 118
                             $redirect_page
119 119
                         )
120 120
                     );
Please login to merge, or discard this patch.