Passed
Push — master ( d5eda6...f93275 )
by Joseph
23s
created
admin-settings.php 1 patch
Indentation   +145 added lines, -145 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,153 +36,153 @@  discard block
 block discarded – undo
36 36
 final class AdminSettings
37 37
 {
38 38
 
39
-    /**
40
-     * Our class constructor
41
-     */
42
-    public function __construct() 
43
-    {
39
+	/**
40
+	 * Our class constructor
41
+	 */
42
+	public function __construct() 
43
+	{
44 44
         
45
-        add_action('admin_menu', array( $this, 'adminMenu' ));
46
-
47
-        add_action('admin_init', array( $this, 'registerSettings' ));
48
-
49
-    }
50
-
51
-    /**
52
-     * Display 'Subway' link under 'Settings'
53
-     *
54
-     * @return void
55
-     */
56
-    public function adminMenu() 
57
-    {
58
-
59
-        add_options_page(
60
-            'Subway Settings', 'Subway', 'manage_options', 
61
-            'subway', array( $this, 'optionsPage' )
62
-        );
63
-
64
-        return;
65
-    }
66
-
67
-    /**
68
-     * Registers all settings related to Subway.
69
-     *
70
-     * @return void
71
-     */
72
-    public function registerSettings() 
73
-    {
74
-
75
-        // Register our settings section.
76
-        add_settings_section(
77
-            'subway-page-visibility-section', __('Pages Visibility', 'subway'), 
78
-            array( $this, 'sectionCallback' ), 'subway-settings-section' 
79
-        );
80
-
81
-        // Register Redirect Options pages.
82
-        add_settings_section(
83
-            'subway-redirect-section', __('Redirect Options', 'subway'), 
84
-            array( $this, 'redirectCallback' ), 'subway-settings-section' 
85
-        );
86
-
87
-        // Register the fields.
88
-        $fields = array(
89
-            array(
90
-                'id' => 'subway_is_public',
91
-                'label' => __('Public Website', 'subway'),
92
-                'callback' => 'subway_is_public_form',
93
-                'section' => 'subway-settings-section',
94
-                'group' => 'subway-page-visibility-section',
95
-            ),
45
+		add_action('admin_menu', array( $this, 'adminMenu' ));
46
+
47
+		add_action('admin_init', array( $this, 'registerSettings' ));
48
+
49
+	}
50
+
51
+	/**
52
+	 * Display 'Subway' link under 'Settings'
53
+	 *
54
+	 * @return void
55
+	 */
56
+	public function adminMenu() 
57
+	{
58
+
59
+		add_options_page(
60
+			'Subway Settings', 'Subway', 'manage_options', 
61
+			'subway', array( $this, 'optionsPage' )
62
+		);
63
+
64
+		return;
65
+	}
66
+
67
+	/**
68
+	 * Registers all settings related to Subway.
69
+	 *
70
+	 * @return void
71
+	 */
72
+	public function registerSettings() 
73
+	{
74
+
75
+		// Register our settings section.
76
+		add_settings_section(
77
+			'subway-page-visibility-section', __('Pages Visibility', 'subway'), 
78
+			array( $this, 'sectionCallback' ), 'subway-settings-section' 
79
+		);
80
+
81
+		// Register Redirect Options pages.
82
+		add_settings_section(
83
+			'subway-redirect-section', __('Redirect Options', 'subway'), 
84
+			array( $this, 'redirectCallback' ), 'subway-settings-section' 
85
+		);
86
+
87
+		// Register the fields.
88
+		$fields = array(
89
+			array(
90
+				'id' => 'subway_is_public',
91
+				'label' => __('Public Website', 'subway'),
92
+				'callback' => 'subway_is_public_form',
93
+				'section' => 'subway-settings-section',
94
+				'group' => 'subway-page-visibility-section',
95
+			),
96 96
     
97
-            array(
98
-                'id' => 'subway_login_page',
99
-                'label' => __('Private Login Page', 'subway'),
100
-                'callback' => 'subway_login_page_form',
101
-                'section' => 'subway-settings-section',
102
-                'group' => 'subway-page-visibility-section',
103
-            ),
104
-            array(
105
-                'id' => 'subway_public_post',
106
-                'label' => __('Public Posts IDs', 'subway'),
107
-                'callback' => 'subway_public_post',
108
-                'section' => 'subway-settings-section',
109
-                'group' => 'subway-page-visibility-section',
110
-            ),
97
+			array(
98
+				'id' => 'subway_login_page',
99
+				'label' => __('Private Login Page', 'subway'),
100
+				'callback' => 'subway_login_page_form',
101
+				'section' => 'subway-settings-section',
102
+				'group' => 'subway-page-visibility-section',
103
+			),
104
+			array(
105
+				'id' => 'subway_public_post',
106
+				'label' => __('Public Posts IDs', 'subway'),
107
+				'callback' => 'subway_public_post',
108
+				'section' => 'subway-settings-section',
109
+				'group' => 'subway-page-visibility-section',
110
+			),
111 111
     
112
-            array(
113
-                'id' => 'subway_redirect_type',
114
-                'label' => __('Redirect Type', 'subway'),
115
-                'callback' => 'subway_redirect_option_form',
116
-                'section' => 'subway-settings-section',
117
-                'group' => 'subway-redirect-section',
118
-            ),
119
-            array(
120
-                'id' => 'subway_redirect_wp_admin',
121
-                'label' => __('Bypassing <em>wp-login.php</em>', 'subway'),
122
-                'callback' => 'subway_lock_wp_admin',
123
-                'section' => 'subway-settings-section',
124
-                'group' => 'subway-redirect-section',
125
-            ),
126
-        );
127
-
128
-        foreach ( $fields as $field ) {
129
-
130
-            add_settings_field(
131
-                $field['id'], $field['label'], 
132
-                $field['callback'], $field['section'], 
133
-                $field['group']
134
-            );
135
-
136
-            register_setting('subway-settings-group', $field['id']);
137
-
138
-            $file = str_replace('_', '-', $field['callback']);
139
-
140
-            include_once trailingslashit(SUBWAY_DIR_PATH) . 
141
-            'settings-fields/field-' . sanitize_title($file) . '.php';
142
-
143
-        }
144
-
145
-        // Register Redirect Page ID Settings.
146
-        register_setting('subway-settings-group', 'subway_redirect_page_id');
147
-
148
-        // Register Redirect Custom URL Settings.
149
-        register_setting('subway-settings-group', 'subway_redirect_custom_url');
150
-
151
-        return;
152
-    }
153
-
154
-    /**
155
-     * Callback function for the first Section.
156
-     *
157
-     * @return void
158
-     */
159
-    public function sectionCallback() 
160
-    {
161
-        echo esc_html_e(
162
-            'All settings related to the 
112
+			array(
113
+				'id' => 'subway_redirect_type',
114
+				'label' => __('Redirect Type', 'subway'),
115
+				'callback' => 'subway_redirect_option_form',
116
+				'section' => 'subway-settings-section',
117
+				'group' => 'subway-redirect-section',
118
+			),
119
+			array(
120
+				'id' => 'subway_redirect_wp_admin',
121
+				'label' => __('Bypassing <em>wp-login.php</em>', 'subway'),
122
+				'callback' => 'subway_lock_wp_admin',
123
+				'section' => 'subway-settings-section',
124
+				'group' => 'subway-redirect-section',
125
+			),
126
+		);
127
+
128
+		foreach ( $fields as $field ) {
129
+
130
+			add_settings_field(
131
+				$field['id'], $field['label'], 
132
+				$field['callback'], $field['section'], 
133
+				$field['group']
134
+			);
135
+
136
+			register_setting('subway-settings-group', $field['id']);
137
+
138
+			$file = str_replace('_', '-', $field['callback']);
139
+
140
+			include_once trailingslashit(SUBWAY_DIR_PATH) . 
141
+			'settings-fields/field-' . sanitize_title($file) . '.php';
142
+
143
+		}
144
+
145
+		// Register Redirect Page ID Settings.
146
+		register_setting('subway-settings-group', 'subway_redirect_page_id');
147
+
148
+		// Register Redirect Custom URL Settings.
149
+		register_setting('subway-settings-group', 'subway_redirect_custom_url');
150
+
151
+		return;
152
+	}
153
+
154
+	/**
155
+	 * Callback function for the first Section.
156
+	 *
157
+	 * @return void
158
+	 */
159
+	public function sectionCallback() 
160
+	{
161
+		echo esc_html_e(
162
+			'All settings related to the 
163 163
         	visibility of your site and pages.', 'subway'
164
-        );
165
-        return;
166
-    }
167
-
168
-    /**
169
-     * Callback function for the second Section.
170
-     *
171
-     * @return void
172
-     */
173
-    public function redirectCallback() 
174
-    {
175
-        return;
176
-    }
177
-
178
-    /**
179
-     * Renders the 'wrapper' for our options pages.
180
-     *
181
-     * @return void
182
-     */
183
-    public function optionsPage() 
184
-    {
185
-        ?>
164
+		);
165
+		return;
166
+	}
167
+
168
+	/**
169
+	 * Callback function for the second Section.
170
+	 *
171
+	 * @return void
172
+	 */
173
+	public function redirectCallback() 
174
+	{
175
+		return;
176
+	}
177
+
178
+	/**
179
+	 * Renders the 'wrapper' for our options pages.
180
+	 *
181
+	 * @return void
182
+	 */
183
+	public function optionsPage() 
184
+	{
185
+		?>
186 186
 
187 187
         <div class="wrap">
188 188
             <h2>
@@ -196,7 +196,7 @@  discard block
 block discarded – undo
196 196
         </div>
197 197
         
198 198
         <?php
199
-    }
199
+	}
200 200
 
201 201
 }
202 202
 
Please login to merge, or discard this patch.
classes/subway-enqueue.php 1 patch
Indentation   +35 added lines, -35 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,50 +36,50 @@  discard block
 block discarded – undo
36 36
 final class Enqueue
37 37
 {
38 38
 
39
-    /**
40
-     * Registers our CSS and Javascript to WordPress Enqueue Handler.
41
-     *
42
-     * @return void
43
-     */
44
-    public static function registerJs() 
45
-    {
39
+	/**
40
+	 * Registers our CSS and Javascript to WordPress Enqueue Handler.
41
+	 *
42
+	 * @return void
43
+	 */
44
+	public static function registerJs() 
45
+	{
46 46
 
47
-        $post_id = absint(get_queried_object_id());
47
+		$post_id = absint(get_queried_object_id());
48 48
 
49
-        $signin_page = absint(get_option('subway_login_page'));
49
+		$signin_page = absint(get_option('subway_login_page'));
50 50
 
51
-        // Only load the stylesheet and javascript documents inside our sign-in page.
52
-        if ($post_id === $signin_page ) {
51
+		// Only load the stylesheet and javascript documents inside our sign-in page.
52
+		if ($post_id === $signin_page ) {
53 53
 
54
-            wp_enqueue_style(
55
-                'subway-style', 
56
-                SUBWAY_DIR_URL . 'assets/css/subway.css'
57
-            );
54
+			wp_enqueue_style(
55
+				'subway-style', 
56
+				SUBWAY_DIR_URL . 'assets/css/subway.css'
57
+			);
58 58
 
59
-            if (! is_user_logged_in() ) {
59
+			if (! is_user_logged_in() ) {
60 60
 
61
-                wp_enqueue_script(
62
-                    'subway-script', 
63
-                    SUBWAY_DIR_URL . 'assets/js/subway.js', 
64
-                    array( 'jquery' )
65
-                );
61
+				wp_enqueue_script(
62
+					'subway-script', 
63
+					SUBWAY_DIR_URL . 'assets/js/subway.js', 
64
+					array( 'jquery' )
65
+				);
66 66
 
67
-                wp_localize_script(
68
-                    'subway-script', 'subway_config', array(
69
-                    'ajax_url' => admin_url('admin-ajax.php'),
70
-                    'login_http_error' => esc_html__(
71
-                        'An error occured while 
67
+				wp_localize_script(
68
+					'subway-script', 'subway_config', array(
69
+					'ajax_url' => admin_url('admin-ajax.php'),
70
+					'login_http_error' => esc_html__(
71
+						'An error occured while 
72 72
                     	transmitting the data. Refresh the page and try again', 
73
-                        'subway'
74
-                    ),
75
-                    )
76
-                );
73
+						'subway'
74
+					),
75
+					)
76
+				);
77 77
 
78
-            }
79
-        }
78
+			}
79
+		}
80 80
 
81
-        return;
81
+		return;
82 82
 
83
-    }
83
+	}
84 84
 
85 85
 }
Please login to merge, or discard this patch.
classes/subway-page-redirect.php 1 patch
Indentation   +88 added lines, -88 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,93 +36,93 @@  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
-
112
-                if (! in_array($current_page_id, $excluded_page, true) ) {
113
-
114
-                    wp_safe_redirect(
115
-                        add_query_arg(
116
-                            array( '_redirected' => 'yes' ),
117
-                            $redirect_page
118
-                        )
119
-                    );
120
-
121
-                    Helpers::close();
122
-                }
123
-            }
124
-        }
125
-    }
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
+
112
+				if (! in_array($current_page_id, $excluded_page, true) ) {
113
+
114
+					wp_safe_redirect(
115
+						add_query_arg(
116
+							array( '_redirected' => 'yes' ),
117
+							$redirect_page
118
+						)
119
+					);
120
+
121
+					Helpers::close();
122
+				}
123
+			}
124
+		}
125
+	}
126 126
 
127 127
 }
128 128
 
Please login to merge, or discard this patch.
classes/subway-helpers.php 1 patch
Indentation   +10 added lines, -10 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,13 +36,13 @@  discard block
 block discarded – undo
36 36
 final class Helpers
37 37
 {
38 38
 
39
-    /**
40
-     * Exit wrapper.
41
-     * 
42
-     * @return void
43
-     */
44
-    public static function close() 
45
-    {
46
-        exit;
47
-    }
39
+	/**
40
+	 * Exit wrapper.
41
+	 * 
42
+	 * @return void
43
+	 */
44
+	public static function close() 
45
+	{
46
+		exit;
47
+	}
48 48
 }
Please login to merge, or discard this patch.
classes/subway-options.php 1 patch
Indentation   +47 added lines, -47 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,73 +36,73 @@  discard block
 block discarded – undo
36 36
 final class Options
37 37
 {
38 38
 
39
-    /**
40
-     * Get the redirect page url.
41
-     *
42
-     * @return mixed The redirect url of our settings. Otherwise, false.
43
-     */
44
-    public static function getRedirectPageUrl() 
45
-    {
39
+	/**
40
+	 * Get the redirect page url.
41
+	 *
42
+	 * @return mixed The redirect url of our settings. Otherwise, false.
43
+	 */
44
+	public static function getRedirectPageUrl() 
45
+	{
46 46
 
47
-        $selected_login_post_id = intval(get_option('subway_login_page'));
47
+		$selected_login_post_id = intval(get_option('subway_login_page'));
48 48
 
49
-        if (0 === $selected_login_post_id ) {
49
+		if (0 === $selected_login_post_id ) {
50 50
 
51
-            return;
51
+			return;
52 52
 
53
-        }
53
+		}
54 54
 
55
-        $login_post = get_post($selected_login_post_id);
55
+		$login_post = get_post($selected_login_post_id);
56 56
 
57
-        if (! empty($login_post) ) {
57
+		if (! empty($login_post) ) {
58 58
 
59
-            return trailingslashit(get_permalink($login_post->ID));
59
+			return trailingslashit(get_permalink($login_post->ID));
60 60
 
61
-        }
61
+		}
62 62
 
63
-        return false;
63
+		return false;
64 64
 
65
-    }
65
+	}
66 66
 
67
-    /**
68
-     * Fetches the public post ids.
69
-     *
70
-     * @return array The collection of public 'post' IDs.
71
-     */
72
-    public static function getPublicPostsIdentifiers() 
73
-    {
67
+	/**
68
+	 * Fetches the public post ids.
69
+	 *
70
+	 * @return array The collection of public 'post' IDs.
71
+	 */
72
+	public static function getPublicPostsIdentifiers() 
73
+	{
74 74
 
75
-        $subway_public_post = get_option('subway_public_post');
75
+		$subway_public_post = get_option('subway_public_post');
76 76
 
77
-        $excluded_pages_collection = array();
77
+		$excluded_pages_collection = array();
78 78
 
79
-        if (! empty($subway_public_post) ) {
79
+		if (! empty($subway_public_post) ) {
80 80
 
81
-            $excluded_pages_collection = explode(',', $subway_public_post);
81
+			$excluded_pages_collection = explode(',', $subway_public_post);
82 82
 
83
-        }
83
+		}
84 84
 
85
-        // Should filter it by integer, spaces will be ignored, other strings.
86
-        // Will be converted to zero '0'.
87
-        return array_filter(array_map('intval', $excluded_pages_collection));
85
+		// Should filter it by integer, spaces will be ignored, other strings.
86
+		// Will be converted to zero '0'.
87
+		return array_filter(array_map('intval', $excluded_pages_collection));
88 88
 
89
-    }
89
+	}
90 90
 
91
-    /**
92
-     * Check if site is public or not.
93
-     *
94
-     * @return boolean True on success. Otherwise, false.
95
-     */
96
-    public static function isPublicSite() 
97
-    {
91
+	/**
92
+	 * Check if site is public or not.
93
+	 *
94
+	 * @return boolean True on success. Otherwise, false.
95
+	 */
96
+	public static function isPublicSite() 
97
+	{
98 98
 
99
-        $subway_public_post = get_option('subway_is_public');
99
+		$subway_public_post = get_option('subway_is_public');
100 100
 
101
-        if (! empty($subway_public_post) ) {
101
+		if (! empty($subway_public_post) ) {
102 102
 
103
-            return true;
103
+			return true;
104 104
 
105
-        }
106
-        return false;
107
-    }
105
+		}
106
+		return false;
107
+	}
108 108
 }
Please login to merge, or discard this patch.
shortcodes/subway-shortcodes.php 2 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     /**
40 40
      * Class Constructor.
41 41
      *
42
-     * @return void
42
+     * @return Shortcodes
43 43
      */
44 44
     private function __construct() 
45 45
     {
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     /**
54 54
      * Instantiate our class.
55 55
      * 
56
-     * @return mixed The instance of this class.
56
+     * @return Shortcodes|null The instance of this class.
57 57
      */
58 58
     public static function instance() 
59 59
     {
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
     /**
92 92
      * Displays the login form
93 93
      * 
94
-     * @return void
94
+     * @return null|string
95 95
      */
96 96
     public function loginForm( $atts )
97 97
     {
Please login to merge, or discard this patch.
Indentation   +137 added lines, -137 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,166 +36,166 @@  discard block
 block discarded – undo
36 36
 final class Shortcodes
37 37
 {
38 38
 
39
-    /**
40
-     * Class Constructor.
41
-     *
42
-     * @return void
43
-     */
44
-    private function __construct() 
45
-    {
39
+	/**
40
+	 * Class Constructor.
41
+	 *
42
+	 * @return void
43
+	 */
44
+	private function __construct() 
45
+	{
46 46
         
47
-        add_action('init', array( $this, 'register'));
47
+		add_action('init', array( $this, 'register'));
48 48
         
49
-        return $this;
49
+		return $this;
50 50
 
51
-    }
51
+	}
52 52
 
53
-    /**
54
-     * Instantiate our class.
55
-     * 
56
-     * @return mixed The instance of this class.
57
-     */
58
-    public static function instance() 
59
-    {
53
+	/**
54
+	 * Instantiate our class.
55
+	 * 
56
+	 * @return mixed The instance of this class.
57
+	 */
58
+	public static function instance() 
59
+	{
60 60
         
61
-        static $instance = null;
62
-
63
-        if (null === $instance ) {
64
-
65
-            $instance = new Shortcodes();
66
-
67
-        }
68
-
69
-        return $instance;
70
-
71
-    }
72
-
73
-    /**
74
-     * Instantiate our class.
75
-     * 
76
-     * @return void
77
-     */
78
-    public function register() 
79
-    {
80
-
81
-        add_shortcode('subway_login', array( $this, 'loginForm' ));
82
-
83
-        add_action('login_form_middle', array( $this, 'loginFormAction' ), 10, 2);
84
-
85
-        add_action('login_form_middle', array( $this, 'lostPasswordLink' ), 10, 2);
86
-
87
-        return;
88
-
89
-    }
90
-
91
-    /**
92
-     * Displays the login form
93
-     * 
94
-     * @return void
95
-     */
96
-    public function loginForm( $atts )
97
-    {
98
-        $atts = shortcode_atts( array(
99
-            'echo'           => true,
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' ),
105
-            'id_username'    => 'user_login',
106
-            'id_password'    => 'user_pass',
107
-            'id_remember'    => 'rememberme',
108
-            'id_submit'      => 'wp-submit',
109
-            'remember'       => true,
110
-            'value_username' => '',
111
-            'value_remember' => false,
112
-            'redirect'       => home_url(),
113
-        ), $atts );
114
-
115
-        return $this->renderTemplate($atts, 'login-form.php');
116
-    }
117
-
118
-    /**
119
-     * Include the specific plugin file if there is no template file.
120
-     * 
121
-     * @param mixed  $atts The shortcode attribute.
122
-     * @param string $file The shortcode template file.
123
-     * 
124
-     * @return string The html template content.
125
-     */
126
-    protected function renderTemplate( $atts, $file = '' ) 
127
-    {
128
-
129
-        ob_start();
130
-
131
-        if (empty($file) ) {
61
+		static $instance = null;
62
+
63
+		if (null === $instance ) {
64
+
65
+			$instance = new Shortcodes();
66
+
67
+		}
68
+
69
+		return $instance;
70
+
71
+	}
72
+
73
+	/**
74
+	 * Instantiate our class.
75
+	 * 
76
+	 * @return void
77
+	 */
78
+	public function register() 
79
+	{
80
+
81
+		add_shortcode('subway_login', array( $this, 'loginForm' ));
82
+
83
+		add_action('login_form_middle', array( $this, 'loginFormAction' ), 10, 2);
84
+
85
+		add_action('login_form_middle', array( $this, 'lostPasswordLink' ), 10, 2);
86
+
87
+		return;
88
+
89
+	}
90
+
91
+	/**
92
+	 * Displays the login form
93
+	 * 
94
+	 * @return void
95
+	 */
96
+	public function loginForm( $atts )
97
+	{
98
+		$atts = shortcode_atts( array(
99
+			'echo'           => true,
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' ),
105
+			'id_username'    => 'user_login',
106
+			'id_password'    => 'user_pass',
107
+			'id_remember'    => 'rememberme',
108
+			'id_submit'      => 'wp-submit',
109
+			'remember'       => true,
110
+			'value_username' => '',
111
+			'value_remember' => false,
112
+			'redirect'       => home_url(),
113
+		), $atts );
114
+
115
+		return $this->renderTemplate($atts, 'login-form.php');
116
+	}
117
+
118
+	/**
119
+	 * Include the specific plugin file if there is no template file.
120
+	 * 
121
+	 * @param mixed  $atts The shortcode attribute.
122
+	 * @param string $file The shortcode template file.
123
+	 * 
124
+	 * @return string The html template content.
125
+	 */
126
+	protected function renderTemplate( $atts, $file = '' ) 
127
+	{
128
+
129
+		ob_start();
130
+
131
+		if (empty($file) ) {
132 132
             
133
-            return;
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
-            if ($theme_template) {
143
+			if ($theme_template) {
144 144
 
145
-                   $template = $theme_template;
145
+				   $template = $theme_template;
146 146
 
147
-            }
147
+			}
148 148
 
149
-            include $template;
149
+			include $template;
150 150
 
151
-        } else {
151
+		} else {
152 152
 
153
-            echo sprintf(
154
-                esc_html_e(
155
-                    'Subway Error: Unable to find template file in: %1s', 'subway'
156
-                ), 
157
-                $template
158
-            );
153
+			echo sprintf(
154
+				esc_html_e(
155
+					'Subway Error: Unable to find template file in: %1s', 'subway'
156
+				), 
157
+				$template
158
+			);
159 159
 
160
-        }
160
+		}
161 161
 
162
-        return ob_get_clean();
163
-    }
162
+		return ob_get_clean();
163
+	}
164 164
 
165
-    /**
166
-     * The action for our login form.
167
-     * 
168
-     * @param string $__content The current filtered contents.
169
-     * 
170
-     * @return string            The content of our login form action.
171
-     */
172
-    public function loginFormAction( $__content ) 
173
-    {
165
+	/**
166
+	 * The action for our login form.
167
+	 * 
168
+	 * @param string $__content The current filtered contents.
169
+	 * 
170
+	 * @return string            The content of our login form action.
171
+	 */
172
+	public function loginFormAction( $__content ) 
173
+	{
174 174
 
175
-        ob_start();
175
+		ob_start();
176 176
         
177
-        do_action('login_form');
177
+		do_action('login_form');
178 178
         
179
-        return $__content . ob_get_clean();
180
-
181
-    }
182
-
183
-     /**
184
-     * The action for our 'lost password' link.
185
-     * 
186
-     * @param string $content The current filtered contents.
187
-     * 
188
-     * @return string          The content of our lost password link.
189
-     */
190
-    public function lostPasswordLink( $content ) 
191
-    {
179
+		return $__content . ob_get_clean();
180
+
181
+	}
182
+
183
+	 /**
184
+	  * The action for our 'lost password' link.
185
+	  * 
186
+	  * @param string $content The current filtered contents.
187
+	  * 
188
+	  * @return string          The content of our lost password link.
189
+	  */
190
+	public function lostPasswordLink( $content ) 
191
+	{
192 192
         
193
-        return $content . $this->renderTemplate(
194
-            array(), 
195
-            'login-form-lost-password.php'
196
-        );
193
+		return $content . $this->renderTemplate(
194
+			array(), 
195
+			'login-form-lost-password.php'
196
+		);
197 197
 
198
-    }
198
+	}
199 199
 
200 200
 }
201 201
 
Please login to merge, or discard this patch.
i18.php 1 patch
Indentation   +21 added lines, -21 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,32 +36,32 @@  discard block
 block discarded – undo
36 36
 final class I18
37 37
 {
38 38
 
39
-    /**
40
-     * Class Constructor.
41
-     *
42
-     * @return void
43
-     */
44
-    public function __construct() 
45
-    {
39
+	/**
40
+	 * Class Constructor.
41
+	 *
42
+	 * @return void
43
+	 */
44
+	public function __construct() 
45
+	{
46 46
 
47
-        add_action('plugins_loaded', array( $this, 'subwayLocalizePlugin' ));
47
+		add_action('plugins_loaded', array( $this, 'subwayLocalizePlugin' ));
48 48
 
49
-        return;
50
-    }
49
+		return;
50
+	}
51 51
 
52
-    /**
53
-     * Subway l8n callback.
54
-     *
55
-     * @return void
56
-     */
57
-    public function subwayLocalizePlugin() 
58
-    {
52
+	/**
53
+	 * Subway l8n callback.
54
+	 *
55
+	 * @return void
56
+	 */
57
+	public function subwayLocalizePlugin() 
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
-        return;
62
+		return;
63 63
 
64
-    }
64
+	}
65 65
 
66 66
 }
67 67
 
Please login to merge, or discard this patch.
classes/subway-auth-redirect.php 1 patch
Indentation   +125 added lines, -125 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,182 +36,182 @@  discard block
 block discarded – undo
36 36
 final class AuthRedirect
37 37
 {
38 38
 
39
-    /**
40
-     * Handles our ajax authentication.
41
-     *
42
-     * @return void
43
-     */
44
-    public static function handleAuthentication() 
45
-    {
39
+	/**
40
+	 * Handles our ajax authentication.
41
+	 *
42
+	 * @return void
43
+	 */
44
+	public static function handleAuthentication() 
45
+	{
46 46
 
47
-        // Set the header type to json.
48
-        header('Content-Type: application/json');
47
+		// Set the header type to json.
48
+		header('Content-Type: application/json');
49 49
 
50
-        $log = filter_input(INPUT_POST, 'log', FILTER_SANITIZE_STRING);
50
+		$log = filter_input(INPUT_POST, 'log', FILTER_SANITIZE_STRING);
51 51
 
52
-        $pwd = filter_input(INPUT_POST, 'pwd', FILTER_SANITIZE_STRING);
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
-            $response['type'] = 'error';
56
+			$response['type'] = 'error';
57 57
 
58
-            $response['message'] = esc_html__(
59
-                'Username and Password cannot be empty.', 
60
-                'subway'
61
-            );
58
+			$response['message'] = esc_html__(
59
+				'Username and Password cannot be empty.', 
60
+				'subway'
61
+			);
62 62
 
63
-        } else {
63
+		} else {
64 64
 
65
-            $is_signin = wp_signon();
65
+			$is_signin = wp_signon();
66 66
 
67
-            $response = array();
67
+			$response = array();
68 68
 
69
-            if (is_wp_error($is_signin) ) {
69
+			if (is_wp_error($is_signin) ) {
70 70
 
71
-                $response['type'] = 'error';
71
+				$response['type'] = 'error';
72 72
 
73
-                $response['message'] = $is_signin->get_error_message();
73
+				$response['message'] = $is_signin->get_error_message();
74 74
 
75
-            } else {
75
+			} else {
76 76
 
77
-                $response['type'] = 'success';
77
+				$response['type'] = 'success';
78 78
 
79
-                $response['message'] = esc_html__(
80
-                    'You have successfully logged-in. 
79
+				$response['message'] = esc_html__(
80
+					'You have successfully logged-in. 
81 81
                 	Redirecting you in few seconds...'
82
-                );
82
+				);
83 83
 
84
-            }
85
-        }
84
+			}
85
+		}
86 86
         
87
-        $subway_redirect_url = AuthRedirect::getLoginRedirectUrl('', $is_signin);
87
+		$subway_redirect_url = AuthRedirect::getLoginRedirectUrl('', $is_signin);
88 88
 
89
-        $response['redirect_url'] = apply_filters(
90
-            'subway_login_redirect', 
91
-            $subway_redirect_url
92
-        );
89
+		$response['redirect_url'] = apply_filters(
90
+			'subway_login_redirect', 
91
+			$subway_redirect_url
92
+		);
93 93
 
94
-        echo wp_json_encode($response);
94
+		echo wp_json_encode($response);
95 95
 
96
-        wp_die();
96
+		wp_die();
97 97
 
98
-    }
98
+	}
99 99
 
100
-    /**
101
-     * Returns the filtered redirect url for the current user.
102
-     *
103
-     * @param string $redirect_to The default redirect callback argument.
104
-     * @param mixed  $user        The object/array of the logged-in user.
105
-     * 
106
-     * @return string              The final redirect url.
107
-     */
108
-    public static function getLoginRedirectUrl( $redirect_to, $user ) 
109
-    {
100
+	/**
101
+	 * Returns the filtered redirect url for the current user.
102
+	 *
103
+	 * @param string $redirect_to The default redirect callback argument.
104
+	 * @param mixed  $user        The object/array of the logged-in user.
105
+	 * 
106
+	 * @return string              The final redirect url.
107
+	 */
108
+	public static function getLoginRedirectUrl( $redirect_to, $user ) 
109
+	{
110 110
 
111
-        $subway_redirect_type = get_option('subway_redirect_type');
111
+		$subway_redirect_type = get_option('subway_redirect_type');
112 112
 
113
-        // Redirect the user to default behaviour.
114
-        // If there are no redirect type option saved.
115
-        if (empty($subway_redirect_type) ) {
113
+		// Redirect the user to default behaviour.
114
+		// If there are no redirect type option saved.
115
+		if (empty($subway_redirect_type) ) {
116 116
 
117
-            return $redirect_to;
117
+			return $redirect_to;
118 118
 
119
-        }
119
+		}
120 120
 
121
-        if ('default' === $subway_redirect_type ) {
122
-            return $redirect_to;
123
-        }
121
+		if ('default' === $subway_redirect_type ) {
122
+			return $redirect_to;
123
+		}
124 124
 
125
-        if ('page' === $subway_redirect_type ) {
125
+		if ('page' === $subway_redirect_type ) {
126 126
 
127
-            // Get the page url of the selected page.
128
-            // If the admin selected 'Custom Page' in the redirect type settings.
129
-            $selected_redirect_page = intval(get_option('subway_redirect_page_id'));
127
+			// Get the page url of the selected page.
128
+			// If the admin selected 'Custom Page' in the redirect type settings.
129
+			$selected_redirect_page = intval(get_option('subway_redirect_page_id'));
130 130
 
131
-            // Redirect to default WordPress behaviour.
132
-            // If the user did not select page.
133
-            if (empty($selected_redirect_page) ) {
131
+			// Redirect to default WordPress behaviour.
132
+			// If the user did not select page.
133
+			if (empty($selected_redirect_page) ) {
134 134
 
135
-                return $redirect_to;
136
-            }
135
+				return $redirect_to;
136
+			}
137 137
 
138
-            // Otherwise, get the permalink of the saved page 
139
-            // and let the user go into that page.
140
-            return get_permalink($selected_redirect_page);
138
+			// Otherwise, get the permalink of the saved page 
139
+			// and let the user go into that page.
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
-            // Get the custom url saved in the redirect type settings.
145
-            $entered_custom_url = get_option('subway_redirect_custom_url');
144
+			// Get the custom url saved in the redirect type settings.
145
+			$entered_custom_url = get_option('subway_redirect_custom_url');
146 146
 
147
-            // Redirect to default WordPress behaviour 
148
-            // if the user did enter a custom url.
149
-            if (empty($entered_custom_url) ) {
147
+			// Redirect to default WordPress behaviour 
148
+			// if the user did enter a custom url.
149
+			if (empty($entered_custom_url) ) {
150 150
 
151
-                return $redirect_to;
151
+				return $redirect_to;
152 152
 
153
-            }
153
+			}
154 154
 
155
-            // Otherwise, get the custom url saved 
156
-            // and let the user go into that page.
157
-            if (! empty($user->ID) ) {
158
-                $entered_custom_url = str_replace(
159
-                    '%user_id%', $user->ID, 
160
-                    $entered_custom_url
161
-                );
162
-            }
155
+			// Otherwise, get the custom url saved 
156
+			// and let the user go into that page.
157
+			if (! empty($user->ID) ) {
158
+				$entered_custom_url = str_replace(
159
+					'%user_id%', $user->ID, 
160
+					$entered_custom_url
161
+				);
162
+			}
163 163
 
164
-            if (! empty($user->user_login) ) {
165
-                $entered_custom_url = str_replace(
166
-                    '%user_name%', $user->user_login, 
167
-                    $entered_custom_url
168
-                );
169
-            }
164
+			if (! empty($user->user_login) ) {
165
+				$entered_custom_url = str_replace(
166
+					'%user_name%', $user->user_login, 
167
+					$entered_custom_url
168
+				);
169
+			}
170 170
 
171
-            return $entered_custom_url;
171
+			return $entered_custom_url;
172 172
 
173
-        }
173
+		}
174 174
 
175
-        // Otherwise, quit and redirect the user back to default WordPress behaviour.
176
-        return $redirect_to;
177
-    }
175
+		// Otherwise, quit and redirect the user back to default WordPress behaviour.
176
+		return $redirect_to;
177
+	}
178 178
 
179
-    /**
180
-     * Callback function for the 'login_url' filter defined in Subway.php
181
-     *
182
-     * @param string $login_url The login url.
183
-     * 
184
-     * @return string            The final login url.
185
-     */
186
-    public static function loginUrl( $login_url  ) 
187
-    {
179
+	/**
180
+	 * Callback function for the 'login_url' filter defined in Subway.php
181
+	 *
182
+	 * @param string $login_url The login url.
183
+	 * 
184
+	 * @return string            The final login url.
185
+	 */
186
+	public static function loginUrl( $login_url  ) 
187
+	{
188 188
 
189
-        $subway_login_page = Options::getRedirectPageUrl();
189
+		$subway_login_page = Options::getRedirectPageUrl();
190 190
 
191
-        // Return the default login url if there is no log-in page defined.
192
-        if (empty($subway_login_page) ) {
193
-            return $login_url;
194
-        }
191
+		// Return the default login url if there is no log-in page defined.
192
+		if (empty($subway_login_page) ) {
193
+			return $login_url;
194
+		}
195 195
 
196
-        // Otherwise, return the Subway login page.
197
-        return $subway_login_page;
196
+		// Otherwise, return the Subway login page.
197
+		return $subway_login_page;
198 198
 
199
-    }
199
+	}
200 200
 
201
-    /**
202
-     * The callback function for our logout filter.
203
-     *
204
-     * @return void
205
-     */
206
-    public static function logoutUrl() 
207
-    {
201
+	/**
202
+	 * The callback function for our logout filter.
203
+	 *
204
+	 * @return void
205
+	 */
206
+	public static function logoutUrl() 
207
+	{
208 208
 
209
-        $subway_login_page = Options::getRedirectPageUrl();
209
+		$subway_login_page = Options::getRedirectPageUrl();
210 210
 
211
-        wp_safe_redirect(esc_url($subway_login_page . '?loggedout=true'));
211
+		wp_safe_redirect(esc_url($subway_login_page . '?loggedout=true'));
212 212
 
213
-        Helpers::close();
213
+		Helpers::close();
214 214
 
215
-    }
215
+	}
216 216
 
217 217
 }
Please login to merge, or discard this patch.