Passed
Pull Request — master (#40)
by Joseph
01:58
created
templates/login-form-lost-password.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -17,12 +17,12 @@
 block discarded – undo
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
 ?>
24 24
 <p class="subway-login-lost-password">
25
-	<a href="<?php echo esc_url( wp_lostpassword_url( $redirect = '' ) ); ?>">
26
-	 	<?php esc_html_e( 'Forgot Password', 'subway' ); ?>
25
+	<a href="<?php echo esc_url(wp_lostpassword_url($redirect = '')); ?>">
26
+	 	<?php esc_html_e('Forgot Password', 'subway'); ?>
27 27
 	</a>
28 28
 </p>
Please login to merge, or discard this patch.
classes/subway-enqueue.php 2 patches
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.
Spacing   +4 added lines, -4 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
 
@@ -49,19 +49,19 @@  discard block
 block discarded – undo
49 49
         $signin_page = absint(get_option('subway_login_page'));
50 50
 
51 51
         // Only load the stylesheet and javascript documents inside our sign-in page.
52
-        if ($post_id === $signin_page ) {
52
+        if ($post_id === $signin_page) {
53 53
 
54 54
             wp_enqueue_style(
55 55
                 'subway-style', 
56 56
                 SUBWAY_DIR_URL . 'assets/css/subway.css'
57 57
             );
58 58
 
59
-            if (! is_user_logged_in() ) {
59
+            if ( ! is_user_logged_in()) {
60 60
 
61 61
                 wp_enqueue_script(
62 62
                     'subway-script', 
63 63
                     SUBWAY_DIR_URL . 'assets/js/subway.js', 
64
-                    array( 'jquery' )
64
+                    array('jquery')
65 65
                 );
66 66
 
67 67
                 wp_localize_script(
Please login to merge, or discard this patch.
classes/subway-helpers.php 2 patches
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.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 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
 
Please login to merge, or discard this patch.
classes/subway-options.php 2 patches
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.
Spacing   +5 added lines, -5 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,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 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 51
             return;
52 52
 
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 
55 55
         $login_post = get_post($selected_login_post_id);
56 56
 
57
-        if (! empty($login_post) ) {
57
+        if ( ! empty($login_post)) {
58 58
 
59 59
             return trailingslashit(get_permalink($login_post->ID));
60 60
 
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 
77 77
         $excluded_pages_collection = array();
78 78
 
79
-        if (! empty($subway_public_post) ) {
79
+        if ( ! empty($subway_public_post)) {
80 80
 
81 81
             $excluded_pages_collection = explode(',', $subway_public_post);
82 82
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 
99 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 103
             return true;
104 104
 
Please login to merge, or discard this patch.
shortcodes/subway-shortcodes.php 3 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.
Spacing   +20 added lines, -20 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
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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(
Please login to merge, or discard this patch.
i18.php 2 patches
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.
Spacing   +3 added lines, -3 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
 
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
Please login to merge, or discard this patch.
templates/login-form.php 1 patch
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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 } ?>
Please login to merge, or discard this patch.
classes/subway-metabox.php 4 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
      *
199 199
      * @since  2.0.9
200 200
      * @access public
201
-     * @return boolean false Returns false if nonce is not valid.
201
+     * @return boolean|null false Returns false if nonce is not valid.
202 202
      */
203 203
     public function saveVisibilityMetabox( $post_id = '' )
204 204
     {
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
      *
269 269
      * @since  2.0.9
270 270
      * @access public
271
-     * @return boolean false Returns false if nonce is not valid.
271
+     * @return boolean|null false Returns false if nonce is not valid.
272 272
      */
273 273
     public function saveMetaboxValues( $post_id )
274 274
     {
@@ -307,7 +307,7 @@  discard block
 block discarded – undo
307 307
      *
308 308
      * @since  2.0.9
309 309
      * @access public
310
-     * @return boolean true Returns true if nonce is valid.
310
+     * @return null|boolean true Returns true if nonce is valid.
311 311
      */
312 312
     public function isNonceValid( $nonce )
313 313
     {
Please login to merge, or discard this patch.
Indentation   +273 added lines, -273 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
 namespace Subway;
22 22
 
23 23
 if (! defined('ABSPATH') ) {
24
-    return;
24
+	return;
25 25
 }
26 26
 
27 27
 /**
@@ -37,99 +37,99 @@  discard block
 block discarded – undo
37 37
 final class Metabox
38 38
 {
39 39
 
40
-    /**
41
-     * Subway visibility meta value,
42
-     *
43
-     * @since 2.0.9
44
-     * @const string VISIBILITY_METAKEY
45
-     */
46
-    const VISIBILITY_METAKEY = 'subway_visibility_meta_key';
47
-
48
-    /**
49
-     * Registers and update metabox with its intended method below.
50
-     *
51
-     * @since  2.0.9
52
-     * @return void
53
-     */
54
-    public function __construct()
55
-    {
56
-        add_action(
57
-            'add_meta_boxes',
58
-            array(
59
-            $this,
60
-            'addMetabox'
61
-            )
62
-        );
63
-        add_action(
64
-            'save_post',
65
-            array(
66
-            $this,
67
-            'saveMetaboxValues'
68
-            )
69
-        );
70
-    }
71
-
72
-    /**
73
-     * Initialize metabox
74
-     *
75
-     * @since  2.0.9
76
-     * @access public
77
-     * @return void
78
-     */
79
-    public static function initMetabox()
80
-    {
81
-        new Metabox();
82
-    }
83
-
84
-    /**
85
-     * Initialize metabox
86
-     *
87
-     * @since  2.0.9
88
-     * @access public
89
-     * @return void
90
-     */
91
-    public function addMetabox()
92
-    {
93
-        $post_types = $this->getPostTypes();
94
-
95
-        foreach ( $post_types as $post_type => $value ) {
96
-            add_meta_box(
97
-                'subway_visibility_metabox',
98
-                esc_html__('Subway: Visibility Option', 'subway'),
99
-                array( $this, 'visibilityMetabox' ),
100
-                $post_type,
101
-                'side',
102
-                'low'
103
-            );
104
-        }
105
-    }
106
-
107
-    /**
108
-     * This method displays the Subway Visibility checkbox.
109
-     *
110
-     * @param object $post Contains data from the current post.
111
-     *
112
-     * @since  2.0.9
113
-     * @access public
114
-     * @return void
115
-     */
116
-    public function visibilityMetabox( $post )
117
-    {
118
-        $howto = __(
119
-            'Choose the accessibility of this page from the options above.',
120
-            'subway'
121
-        );
40
+	/**
41
+	 * Subway visibility meta value,
42
+	 *
43
+	 * @since 2.0.9
44
+	 * @const string VISIBILITY_METAKEY
45
+	 */
46
+	const VISIBILITY_METAKEY = 'subway_visibility_meta_key';
47
+
48
+	/**
49
+	 * Registers and update metabox with its intended method below.
50
+	 *
51
+	 * @since  2.0.9
52
+	 * @return void
53
+	 */
54
+	public function __construct()
55
+	{
56
+		add_action(
57
+			'add_meta_boxes',
58
+			array(
59
+			$this,
60
+			'addMetabox'
61
+			)
62
+		);
63
+		add_action(
64
+			'save_post',
65
+			array(
66
+			$this,
67
+			'saveMetaboxValues'
68
+			)
69
+		);
70
+	}
71
+
72
+	/**
73
+	 * Initialize metabox
74
+	 *
75
+	 * @since  2.0.9
76
+	 * @access public
77
+	 * @return void
78
+	 */
79
+	public static function initMetabox()
80
+	{
81
+		new Metabox();
82
+	}
83
+
84
+	/**
85
+	 * Initialize metabox
86
+	 *
87
+	 * @since  2.0.9
88
+	 * @access public
89
+	 * @return void
90
+	 */
91
+	public function addMetabox()
92
+	{
93
+		$post_types = $this->getPostTypes();
94
+
95
+		foreach ( $post_types as $post_type => $value ) {
96
+			add_meta_box(
97
+				'subway_visibility_metabox',
98
+				esc_html__('Subway: Visibility Option', 'subway'),
99
+				array( $this, 'visibilityMetabox' ),
100
+				$post_type,
101
+				'side',
102
+				'low'
103
+			);
104
+		}
105
+	}
106
+
107
+	/**
108
+	 * This method displays the Subway Visibility checkbox.
109
+	 *
110
+	 * @param object $post Contains data from the current post.
111
+	 *
112
+	 * @since  2.0.9
113
+	 * @access public
114
+	 * @return void
115
+	 */
116
+	public function visibilityMetabox( $post )
117
+	{
118
+		$howto = __(
119
+			'Choose the accessibility of this page from the options above.',
120
+			'subway'
121
+		);
122 122
       
123
-        $private_setting_label = __( 'Members Only', 'subway'  );
123
+		$private_setting_label = __( 'Members Only', 'subway'  );
124 124
 
125
-        $is_post_public          = self::isPostPublic($post->ID);
126
-        $is_post_private         = self::isPostPrivate($post->ID);
125
+		$is_post_public          = self::isPostPublic($post->ID);
126
+		$is_post_private         = self::isPostPrivate($post->ID);
127 127
 
128
-        // Make sure the form request comes from WordPress
129
-        wp_nonce_field(  basename(__FILE__),  'subway_post_visibility_nonce' );
128
+		// Make sure the form request comes from WordPress
129
+		wp_nonce_field(  basename(__FILE__),  'subway_post_visibility_nonce' );
130 130
 
131
-        // Disable the options (radio) when site is selected as public
132
-        ?>
131
+		// Disable the options (radio) when site is selected as public
132
+		?>
133 133
         
134 134
         <?php if ( ! Options::isPublicSite() ):  ?>
135 135
         <?php // Site is private. Give them some Beer! ?>
@@ -155,188 +155,188 @@  discard block
 block discarded – undo
155 155
             </p>
156 156
         <?php endif; ?>
157 157
         <?php
158
-    }
159
-
160
-    /**
161
-     * This method verify if nonce is valid then updates a post_meta.
162
-     *
163
-     * @param integer $post_id Contains ID of the current post.
164
-     *
165
-     * @since  2.0.9
166
-     * @access public
167
-     * @return boolean false Returns false if nonce is not valid.
168
-     */
169
-    public function saveVisibilityMetabox( $post_id = '' )
170
-    {
171
-
172
-        $public_posts     = Options::getPublicPostsIdentifiers();
173
-
174
-        $posts_implode    = '';
175
-
176
-        $visibility_field = 'subway-visibility-settings';
177
-
178
-        $visibility_nonce = filter_input(
179
-            INPUT_POST,
180
-            'subway_post_visibility_nonce',
181
-            FILTER_SANITIZE_STRING
182
-        );
183
-
184
-        $post_visibility = filter_input(
185
-            INPUT_POST,
186
-            $visibility_field,
187
-            FILTER_SANITIZE_STRING
188
-        );
189
-
190
-        $is_valid_visibility_nonce = self::isNonceValid(
191
-            $visibility_nonce
192
-        );
193
-
194
-        // verify taxonomies meta box nonce
195
-        if (false === $is_valid_visibility_nonce ) {
196
-            return;
197
-        }
198
-
199
-        if (! empty($post_visibility) ) {
200
-            if (! empty($post_id) ) {
201
-                if ('public' === $post_visibility ) {
202
-                    if (! in_array($post_id, $public_posts) ) {
203
-                        array_push($public_posts, $post_id);
204
-                    }
205
-                }
206
-                if ('private' === $post_visibility ) {
207
-                    unset($public_posts[ array_search($post_id, $public_posts) ]);
208
-                }
209
-            }
210
-        }
211
-
212
-        if (! empty($post_id) ) {
213
-            $posts_implode = implode(", ", $public_posts);
214
-
215
-            if ('inherit' !== get_post_status($post_id) ) {
216
-
217
-                if (true === $is_valid_visibility_nonce ) {
218
-                    update_option('subway_public_post', $posts_implode);
219
-                    update_post_meta(
220
-                        $post_id,
221
-                        self::VISIBILITY_METAKEY,
222
-                        $post_visibility
223
-                    );
224
-                }
225
-
226
-            }
227
-        }
228
-    }
229
-
230
-    /**
231
-     * This method runs the methods that handles the update for a post_meta.
232
-     *
233
-     * @param integer $post_id Contains ID of the current post.
234
-     *
235
-     * @since  2.0.9
236
-     * @access public
237
-     * @return boolean false Returns false if nonce is not valid.
238
-     */
239
-    public function saveMetaboxValues( $post_id )
240
-    {
241
-        $this->saveVisibilityMetabox($post_id);
242
-        return;
243
-    }
244
-
245
-    /**
246
-     * Initialize metabox arguments.
247
-     *
248
-     * @param array  $args   The arguments for the get_post_types().
249
-     * @param string $output Your desired output for the data.
250
-     *
251
-     * @since  2.0.9
252
-     * @access public
253
-     * @return void
254
-     */
255
-    public static function getPostTypes( $args = '', $output = '' )
256
-    {
257
-        if (empty($args) ) {
258
-            $args = array(
259
-            'public'   => true,
260
-            );
261
-            $output = 'names';
262
-        }
263
-
264
-        $post_types = get_post_types($args, $output);
265
-
266
-        return $post_types;
267
-    }
268
-
269
-    /**
270
-     * This method verify if nonce is valid.
271
-     *
272
-     * @param mixed $nonce the name of a metabox nonce.
273
-     *
274
-     * @since  2.0.9
275
-     * @access public
276
-     * @return boolean true Returns true if nonce is valid.
277
-     */
278
-    public function isNonceValid( $nonce )
279
-    {
280
-        if (!isset($nonce) || !wp_verify_nonce($nonce, basename(__FILE__)) ) {
281
-            return;
282
-        }
283
-
284
-        return true;
285
-    }
286
-
287
-    /**
288
-     * Checks if a post is set to private.
289
-     *
290
-     * @param integer $post_id Contains ID of the current post.
291
-     *
292
-     * @since  2.0.9
293
-     * @access public
294
-     * @return boolean true Returns true if post is private. Otherwise false.
295
-     */
296
-    public static function isPostPrivate( $post_id )
297
-    {
298
-        $meta_value = '';
299
-
300
-        if ( ! empty( $post_id ) ) {
301
-            $meta_value = get_post_meta($post_id, self::VISIBILITY_METAKEY, true);
302
-
303
-            // New page or old pages that don't have Subway'\ Visibility Options
304
-            if ( empty ( $meta_value ) ) {
305
-                // Get the value from the general settings (Settings > Subway)
306
-                $is_site_public = Options::isPublicSite();
307
-                if ( ! $is_site_public ) {
308
-                    // It's private.
309
-                    return true;
310
-                }
311
-            }
312
-            if ('private' === $meta_value ) {
313
-                return true;
314
-            }
315
-        }
316
-
317
-        return false;
318
-    }
319
-
320
-    /**
321
-     * Checks if a post is set to public.
322
-     *
323
-     * @param integer $post_id Contains ID of the current post.
324
-     *
325
-     * @since  2.0.9
326
-     * @access public
327
-     * @return boolean true Returns true if post is public. Otherwise false.
328
-     */
329
-    public static function isPostPublic( $post_id )
330
-    {
331
-        $public_post = Options::getPublicPostsIdentifiers();
332
-
333
-        if (! empty($post_id) ) {
334
-            if (! in_array($post_id, $public_post, true) ) {
335
-                return true;
336
-            }
337
-        }
338
-
339
-        return false;
340
-    }
158
+	}
159
+
160
+	/**
161
+	 * This method verify if nonce is valid then updates a post_meta.
162
+	 *
163
+	 * @param integer $post_id Contains ID of the current post.
164
+	 *
165
+	 * @since  2.0.9
166
+	 * @access public
167
+	 * @return boolean false Returns false if nonce is not valid.
168
+	 */
169
+	public function saveVisibilityMetabox( $post_id = '' )
170
+	{
171
+
172
+		$public_posts     = Options::getPublicPostsIdentifiers();
173
+
174
+		$posts_implode    = '';
175
+
176
+		$visibility_field = 'subway-visibility-settings';
177
+
178
+		$visibility_nonce = filter_input(
179
+			INPUT_POST,
180
+			'subway_post_visibility_nonce',
181
+			FILTER_SANITIZE_STRING
182
+		);
183
+
184
+		$post_visibility = filter_input(
185
+			INPUT_POST,
186
+			$visibility_field,
187
+			FILTER_SANITIZE_STRING
188
+		);
189
+
190
+		$is_valid_visibility_nonce = self::isNonceValid(
191
+			$visibility_nonce
192
+		);
193
+
194
+		// verify taxonomies meta box nonce
195
+		if (false === $is_valid_visibility_nonce ) {
196
+			return;
197
+		}
198
+
199
+		if (! empty($post_visibility) ) {
200
+			if (! empty($post_id) ) {
201
+				if ('public' === $post_visibility ) {
202
+					if (! in_array($post_id, $public_posts) ) {
203
+						array_push($public_posts, $post_id);
204
+					}
205
+				}
206
+				if ('private' === $post_visibility ) {
207
+					unset($public_posts[ array_search($post_id, $public_posts) ]);
208
+				}
209
+			}
210
+		}
211
+
212
+		if (! empty($post_id) ) {
213
+			$posts_implode = implode(", ", $public_posts);
214
+
215
+			if ('inherit' !== get_post_status($post_id) ) {
216
+
217
+				if (true === $is_valid_visibility_nonce ) {
218
+					update_option('subway_public_post', $posts_implode);
219
+					update_post_meta(
220
+						$post_id,
221
+						self::VISIBILITY_METAKEY,
222
+						$post_visibility
223
+					);
224
+				}
225
+
226
+			}
227
+		}
228
+	}
229
+
230
+	/**
231
+	 * This method runs the methods that handles the update for a post_meta.
232
+	 *
233
+	 * @param integer $post_id Contains ID of the current post.
234
+	 *
235
+	 * @since  2.0.9
236
+	 * @access public
237
+	 * @return boolean false Returns false if nonce is not valid.
238
+	 */
239
+	public function saveMetaboxValues( $post_id )
240
+	{
241
+		$this->saveVisibilityMetabox($post_id);
242
+		return;
243
+	}
244
+
245
+	/**
246
+	 * Initialize metabox arguments.
247
+	 *
248
+	 * @param array  $args   The arguments for the get_post_types().
249
+	 * @param string $output Your desired output for the data.
250
+	 *
251
+	 * @since  2.0.9
252
+	 * @access public
253
+	 * @return void
254
+	 */
255
+	public static function getPostTypes( $args = '', $output = '' )
256
+	{
257
+		if (empty($args) ) {
258
+			$args = array(
259
+			'public'   => true,
260
+			);
261
+			$output = 'names';
262
+		}
263
+
264
+		$post_types = get_post_types($args, $output);
265
+
266
+		return $post_types;
267
+	}
268
+
269
+	/**
270
+	 * This method verify if nonce is valid.
271
+	 *
272
+	 * @param mixed $nonce the name of a metabox nonce.
273
+	 *
274
+	 * @since  2.0.9
275
+	 * @access public
276
+	 * @return boolean true Returns true if nonce is valid.
277
+	 */
278
+	public function isNonceValid( $nonce )
279
+	{
280
+		if (!isset($nonce) || !wp_verify_nonce($nonce, basename(__FILE__)) ) {
281
+			return;
282
+		}
283
+
284
+		return true;
285
+	}
286
+
287
+	/**
288
+	 * Checks if a post is set to private.
289
+	 *
290
+	 * @param integer $post_id Contains ID of the current post.
291
+	 *
292
+	 * @since  2.0.9
293
+	 * @access public
294
+	 * @return boolean true Returns true if post is private. Otherwise false.
295
+	 */
296
+	public static function isPostPrivate( $post_id )
297
+	{
298
+		$meta_value = '';
299
+
300
+		if ( ! empty( $post_id ) ) {
301
+			$meta_value = get_post_meta($post_id, self::VISIBILITY_METAKEY, true);
302
+
303
+			// New page or old pages that don't have Subway'\ Visibility Options
304
+			if ( empty ( $meta_value ) ) {
305
+				// Get the value from the general settings (Settings > Subway)
306
+				$is_site_public = Options::isPublicSite();
307
+				if ( ! $is_site_public ) {
308
+					// It's private.
309
+					return true;
310
+				}
311
+			}
312
+			if ('private' === $meta_value ) {
313
+				return true;
314
+			}
315
+		}
316
+
317
+		return false;
318
+	}
319
+
320
+	/**
321
+	 * Checks if a post is set to public.
322
+	 *
323
+	 * @param integer $post_id Contains ID of the current post.
324
+	 *
325
+	 * @since  2.0.9
326
+	 * @access public
327
+	 * @return boolean true Returns true if post is public. Otherwise false.
328
+	 */
329
+	public static function isPostPublic( $post_id )
330
+	{
331
+		$public_post = Options::getPublicPostsIdentifiers();
332
+
333
+		if (! empty($post_id) ) {
334
+			if (! in_array($post_id, $public_post, true) ) {
335
+				return true;
336
+			}
337
+		}
338
+
339
+		return false;
340
+	}
341 341
 
342 342
 }
Please login to merge, or discard this 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.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -147,10 +147,13 @@
 block discarded – undo
147 147
                  </label>
148 148
             </p>
149 149
             <p class="howto"><?php echo esc_html($howto); ?></p>
150
-        <?php else: ?>
150
+        <?php else {
151
+	: ?>
151 152
             <?php // Site is public! Explain to them ?>
152 153
             <p><em>
153
-                <?php esc_html_e('You have chosen to make your site public inside Settings > Subway. Make your site private so that you can select visibility options.', 'subway'); ?>
154
+                <?php esc_html_e('You have chosen to make your site public inside Settings > Subway. Make your site private so that you can select visibility options.', 'subway');
155
+}
156
+?>
154 157
             </em>
155 158
             </p>
156 159
         <?php endif; ?>
Please login to merge, or discard this patch.
settings-fields/field-subway-lock-wp-admin.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
 
@@ -18,8 +18,8 @@  discard block
 block discarded – undo
18 18
 
19 19
 	<p class="description">
20 20
 		<?php
21
-			echo sprintf( __( "In case, you were locked out. Use the link below to bypass the log-in page and go directly
22
-			to your website's wp-login URL (http://yoursiteurl.com/wp-login.php): <strong class='subway-settings-text-notice'>%s</strong>", 'subway' ), site_url( 'wp-login.php?no_redirect=true' ) ); 
21
+			echo sprintf(__("In case, you were locked out. Use the link below to bypass the log-in page and go directly
22
+			to your website's wp-login URL (http://yoursiteurl.com/wp-login.php): <strong class='subway-settings-text-notice'>%s</strong>", 'subway'), site_url('wp-login.php?no_redirect=true')); 
23 23
 		?>
24 24
 	</p>
25 25
 <?php
Please login to merge, or discard this patch.