@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @package Subway |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | return; |
15 | 15 | } |
16 | 16 | |
@@ -37,9 +37,9 @@ discard block |
||
37 | 37 | <!-- Page --> |
38 | 38 | <label for="subway_use_page"> |
39 | 39 | |
40 | - <input <?php checked( 'page', get_option( 'subway_redirect_type' ), true ); ?> value="page" name="subway_redirect_type" id="subway_use_page" type="radio" class="code" /> |
|
40 | + <input <?php checked('page', get_option('subway_redirect_type'), true); ?> value="page" name="subway_redirect_type" id="subway_use_page" type="radio" class="code" /> |
|
41 | 41 | |
42 | - <?php esc_html_e( 'Custom Page', 'subway' ); ?> |
|
42 | + <?php esc_html_e('Custom Page', 'subway'); ?> |
|
43 | 43 | |
44 | 44 | </label> |
45 | 45 | |
@@ -49,9 +49,9 @@ discard block |
||
49 | 49 | |
50 | 50 | <label for="subway_use_custom_url"> |
51 | 51 | |
52 | - <input <?php checked( 'custom_url', get_option( 'subway_redirect_type' ), true ); ?> value="custom_url" name="subway_redirect_type" id="subway_use_custom_url" type="radio" class="code" /> |
|
52 | + <input <?php checked('custom_url', get_option('subway_redirect_type'), true); ?> value="custom_url" name="subway_redirect_type" id="subway_use_custom_url" type="radio" class="code" /> |
|
53 | 53 | |
54 | - <?php esc_html_e( 'Custom URL', 'subway' ); ?> |
|
54 | + <?php esc_html_e('Custom URL', 'subway'); ?> |
|
55 | 55 | |
56 | 56 | </label> |
57 | 57 | |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | |
62 | 62 | <label for="subway_use_default"> |
63 | 63 | |
64 | - <input <?php checked( 'default', get_option( 'subway_redirect_type' ), true ); ?> value="default" name="subway_redirect_type" id="subway_use_default" type="radio" class="code" /> |
|
64 | + <input <?php checked('default', get_option('subway_redirect_type'), true); ?> value="default" name="subway_redirect_type" id="subway_use_default" type="radio" class="code" /> |
|
65 | 65 | |
66 | - <?php esc_html_e( 'Default Behavior', 'subway' ); ?> |
|
66 | + <?php esc_html_e('Default Behavior', 'subway'); ?> |
|
67 | 67 | |
68 | 68 | </label> |
69 | 69 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | <div id="subway_redirect_page_option_section" class="hidden subway-redirect-option-section"> |
80 | 80 | |
81 | 81 | <label for="subway_redirect_page_id"> |
82 | - <?php esc_html_e( 'Select Page' ); ?> |
|
82 | + <?php esc_html_e('Select Page'); ?> |
|
83 | 83 | </label> |
84 | 84 | |
85 | 85 | <?php |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | wp_dropdown_pages( |
88 | 88 | array( |
89 | 89 | 'name' => 'subway_redirect_page_id', |
90 | - 'selected' => intval( get_option( 'subway_redirect_page_id' ) ), |
|
91 | - 'show_option_none' => esc_html__( '-', 'subway' ), |
|
90 | + 'selected' => intval(get_option('subway_redirect_page_id')), |
|
91 | + 'show_option_none' => esc_html__('-', 'subway'), |
|
92 | 92 | ) |
93 | 93 | ); |
94 | 94 | |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | |
97 | 97 | <p class="description"> |
98 | 98 | |
99 | - <?php _e( 'The selected page will be used as the redirect endpoint for all of your users. Selecting blank (-) will redirect the user to the default redirect defined in WordPress or other plugins. Choose "Custom URL" if you want to redirect to a custom URL or domain.', 'subway' ); ?> |
|
99 | + <?php _e('The selected page will be used as the redirect endpoint for all of your users. Selecting blank (-) will redirect the user to the default redirect defined in WordPress or other plugins. Choose "Custom URL" if you want to redirect to a custom URL or domain.', 'subway'); ?> |
|
100 | 100 | |
101 | 101 | </p> |
102 | 102 | |
@@ -105,29 +105,29 @@ discard block |
||
105 | 105 | <div id="subway_redirect_custom_url_option_section" class="hidden subway-redirect-option-section"> |
106 | 106 | |
107 | 107 | <label for="subway_redirect_custom_url"> |
108 | - <?php esc_attr_e( 'Enter Redirect URL:', 'subway' ); ?> |
|
108 | + <?php esc_attr_e('Enter Redirect URL:', 'subway'); ?> |
|
109 | 109 | </label> |
110 | 110 | |
111 | - <input value="<?php echo esc_attr( esc_url( get_option( 'subway_redirect_custom_url' ) ) ); ?>" type="text" name="subway_redirect_custom_url" placeholder="<?php esc_attr_e( 'http://', 'subway' ); ?>" |
|
111 | + <input value="<?php echo esc_attr(esc_url(get_option('subway_redirect_custom_url'))); ?>" type="text" name="subway_redirect_custom_url" placeholder="<?php esc_attr_e('http://', 'subway'); ?>" |
|
112 | 112 | id="subway_redirect_custom_url" size="75" /> |
113 | 113 | |
114 | 114 | <p class="description"><br> |
115 | 115 | |
116 | 116 | <?php |
117 | - echo sprintf( __( 'When entering a custom domain, you can use a variable string such us: %1$s and %2$s. For example, http://yoursiteurl.com/members/<strong>%2$s</strong> will translate to http://yoursiteurl/members/<strong>admin</strong> where "admin" is equal to the %2$s variable; http://yoursiteurl.com/users/<strong>%1$s</strong> will translate to http://yoursiteurl.com/users/<strong>4</strong> where "4" is equal to the %1$s. Both variables refer to the current user that is logged-in.', 'subway' ), '%user_id%', '%user_name%' ); |
|
117 | + echo sprintf(__('When entering a custom domain, you can use a variable string such us: %1$s and %2$s. For example, http://yoursiteurl.com/members/<strong>%2$s</strong> will translate to http://yoursiteurl/members/<strong>admin</strong> where "admin" is equal to the %2$s variable; http://yoursiteurl.com/users/<strong>%1$s</strong> will translate to http://yoursiteurl.com/users/<strong>4</strong> where "4" is equal to the %1$s. Both variables refer to the current user that is logged-in.', 'subway'), '%user_id%', '%user_name%'); |
|
118 | 118 | ?> |
119 | 119 | |
120 | 120 | </p><br> |
121 | 121 | |
122 | 122 | <p class="description"> |
123 | 123 | |
124 | - <?php esc_attr_e( 'Leave empty to use existing WordPress or other 3rd party plugin redirect option.', 'subway' ); ?> |
|
124 | + <?php esc_attr_e('Leave empty to use existing WordPress or other 3rd party plugin redirect option.', 'subway'); ?> |
|
125 | 125 | |
126 | 126 | </p><br> |
127 | 127 | |
128 | 128 | <p class="description"> |
129 | 129 | |
130 | - <?php esc_html_e( 'Warning: External URLs are not supported by WordPress Function (wp_safe_redirect) and will be redirected back to default WordPress behavior.', 'subway' ); ?> |
|
130 | + <?php esc_html_e('Warning: External URLs are not supported by WordPress Function (wp_safe_redirect) and will be redirected back to default WordPress behavior.', 'subway'); ?> |
|
131 | 131 | |
132 | 132 | </p> |
133 | 133 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | <div id="subway_redirect_default_option_section" class="hidden subway-redirect-option-section"> |
138 | 138 | <p> |
139 | 139 | <?php |
140 | - esc_html_e( "By choosing the default behavior, the redirect type will be set to the default WordPress' behavior. For example, if you have plugins like Peter's Login Redirect. This option will disable Subway's redirect and use the Peter's Login Redirect Instead.", 'subway' ); |
|
140 | + esc_html_e("By choosing the default behavior, the redirect type will be set to the default WordPress' behavior. For example, if you have plugins like Peter's Login Redirect. This option will disable Subway's redirect and use the Peter's Login Redirect Instead.", 'subway'); |
|
141 | 141 | ?> |
142 | 142 | </p> |
143 | 143 | </div> |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @package Subway |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | return; |
15 | 15 | } |
16 | 16 | |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | */ |
22 | 22 | function subway_is_public_form() { |
23 | 23 | |
24 | - echo '<label for="subway_is_public"><input ' . checked( 1, get_option( 'subway_is_public' ), false ) . ' value="1" name="subway_is_public" id="subway_is_public" type="checkbox" class="code" /> Check to make all of your posts and pages visible to public.</label>'; |
|
25 | - echo '<p class="description">' . esc_html__( 'This option will overwrite the \'Private Login Page\' below. BuddyPress pages like user profile, members, and groups are still only available to the rightful owner of the profile.', 'subway' ) . '</p>'; |
|
24 | + echo '<label for="subway_is_public"><input ' . checked(1, get_option('subway_is_public'), false) . ' value="1" name="subway_is_public" id="subway_is_public" type="checkbox" class="code" /> Check to make all of your posts and pages visible to public.</label>'; |
|
25 | + echo '<p class="description">' . esc_html__('This option will overwrite the \'Private Login Page\' below. BuddyPress pages like user profile, members, and groups are still only available to the rightful owner of the profile.', 'subway') . '</p>'; |
|
26 | 26 | |
27 | 27 | return; |
28 | 28 | } |
@@ -10,15 +10,15 @@ |
||
10 | 10 | * @package Subway |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | return; |
15 | 15 | } |
16 | 16 | |
17 | 17 | function subway_public_post() { |
18 | 18 | |
19 | - echo '<textarea id="subway_public_post" name="subway_public_post" rows="5" cols="95">' . esc_attr( trim( get_option( 'subway_public_post' ) ) ) . '</textarea>'; |
|
19 | + echo '<textarea id="subway_public_post" name="subway_public_post" rows="5" cols="95">' . esc_attr(trim(get_option('subway_public_post'))) . '</textarea>'; |
|
20 | 20 | |
21 | - echo '<p class="description">' . nl2br( esc_html( "Enter the IDs of posts and pages that you wanted to show in public. You need to separate it by ',' (comma), for example: 143,123,213. Alternatively, you can enable public viewing of all of your pages and posts by checking the 'Public Website' option above.", 'subway' ) ) . '</p>'; |
|
21 | + echo '<p class="description">' . nl2br(esc_html("Enter the IDs of posts and pages that you wanted to show in public. You need to separate it by ',' (comma), for example: 143,123,213. Alternatively, you can enable public viewing of all of your pages and posts by checking the 'Public Website' option above.", 'subway')) . '</p>'; |
|
22 | 22 | |
23 | 23 | return; |
24 | 24 |
@@ -27,13 +27,13 @@ discard block |
||
27 | 27 | * @package Subway |
28 | 28 | */ |
29 | 29 | |
30 | -if ( ! defined( 'ABSPATH' ) ) { |
|
30 | +if ( ! defined('ABSPATH')) { |
|
31 | 31 | return; |
32 | 32 | } |
33 | 33 | |
34 | 34 | // Terminate Subway for PHP version 5.3.0 and below. |
35 | -if ( version_compare( PHP_VERSION, '5.3.0', '<' ) ) { |
|
36 | - add_action( 'admin_notices', 'subway_admin_notice' ); |
|
35 | +if (version_compare(PHP_VERSION, '5.3.0', '<')) { |
|
36 | + add_action('admin_notices', 'subway_admin_notice'); |
|
37 | 37 | /** |
38 | 38 | * Displays admin notifications if the installed PHP version is less than 5.3.0 |
39 | 39 | * |
@@ -44,10 +44,10 @@ discard block |
||
44 | 44 | <div class="notice notice-error is-dismissible"> |
45 | 45 | <p> |
46 | 46 | <strong> |
47 | - <?php esc_html_e( 'Notice: Subway uses PHP Class Namespaces |
|
47 | + <?php esc_html_e('Notice: Subway uses PHP Class Namespaces |
|
48 | 48 | which is only available in servers with PHP 5.3.0 version and above. |
49 | 49 | Update your server\'s PHP version. You can deactivate |
50 | - Subway in the meantime.', 'subway' ); ?> |
|
50 | + Subway in the meantime.', 'subway'); ?> |
|
51 | 51 | </strong> |
52 | 52 | </p> |
53 | 53 | </div> |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | // Define Subway Plugin Version. |
59 | -define( 'SUBWAY_VERSION', '2.0' ); |
|
59 | +define('SUBWAY_VERSION', '2.0'); |
|
60 | 60 | |
61 | 61 | // Define Subway Directory Path. |
62 | -define( 'SUBWAY_DIR_PATH', trailingslashit( plugin_dir_path( __FILE__ ) ) ); |
|
62 | +define('SUBWAY_DIR_PATH', trailingslashit(plugin_dir_path(__FILE__))); |
|
63 | 63 | |
64 | 64 | // Define Subway URL Path. |
65 | -define( 'SUBWAY_DIR_URL', trailingslashit( plugin_dir_url( __FILE__ ) ) ); |
|
65 | +define('SUBWAY_DIR_URL', trailingslashit(plugin_dir_url(__FILE__))); |
|
66 | 66 | |
67 | 67 | // Include Subway i18n. |
68 | 68 | require_once SUBWAY_DIR_PATH . 'i18.php'; |
@@ -86,20 +86,20 @@ discard block |
||
86 | 86 | require_once SUBWAY_DIR_PATH . 'shortcodes/subway-shortcodes.php'; |
87 | 87 | |
88 | 88 | // Redirect (302) all front-end request to the login page. |
89 | -add_action( 'wp', array( 'Subway\Page_Redirect', 'index' ) ); |
|
89 | +add_action('wp', array('Subway\Page_Redirect', 'index')); |
|
90 | 90 | |
91 | 91 | // Redirect (302) invalid login request to the login page. |
92 | -add_action( 'wp_ajax_nopriv_subway_logging_in', array( 'Subway\Auth_Redirect', 'handle_authentication' ) ); |
|
92 | +add_action('wp_ajax_nopriv_subway_logging_in', array('Subway\Auth_Redirect', 'handle_authentication')); |
|
93 | 93 | |
94 | 94 | // Load our JS and CSS files. |
95 | -add_action( 'wp_enqueue_scripts', array( 'Subway\Enqueue', 'register_js' ) ); |
|
95 | +add_action('wp_enqueue_scripts', array('Subway\Enqueue', 'register_js')); |
|
96 | 96 | |
97 | 97 | // Change the default login url to our sign-in page. |
98 | -add_filter( 'login_url', array( 'Subway\Auth_Redirect', 'login_url' ), 10, 3 ); |
|
98 | +add_filter('login_url', array('Subway\Auth_Redirect', 'login_url'), 10, 3); |
|
99 | 99 | |
100 | 100 | // Redirect the user after successful logged in to the right page. |
101 | 101 | // Does not trigger when using ajax form. Only on default wp-login.php and wp_login_form(). |
102 | -add_filter( 'login_redirect', array( 'Subway\Auth_Redirect', 'get_login_redirect_url' ), 10, 3 ); |
|
102 | +add_filter('login_redirect', array('Subway\Auth_Redirect', 'get_login_redirect_url'), 10, 3); |
|
103 | 103 | |
104 | 104 | // Change the default logout url to our sign-in page. |
105 | -add_action( 'wp_logout', array( 'Subway\Auth_Redirect', 'logout_url' ), 10, 3 ); |
|
105 | +add_action('wp_logout', array('Subway\Auth_Redirect', 'logout_url'), 10, 3); |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace Subway; |
14 | 14 | |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | return; |
17 | 17 | } |
18 | 18 | |
@@ -30,22 +30,22 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public static function register_js() { |
32 | 32 | |
33 | - $post_id = absint( get_queried_object_id() ); |
|
33 | + $post_id = absint(get_queried_object_id()); |
|
34 | 34 | |
35 | - $signin_page = absint( get_option( 'subway_login_page' ) ); |
|
35 | + $signin_page = absint(get_option('subway_login_page')); |
|
36 | 36 | |
37 | 37 | // Only load the stylesheet and javascript documents inside our sign-in page. |
38 | - if ( $post_id === $signin_page ) { |
|
38 | + if ($post_id === $signin_page) { |
|
39 | 39 | |
40 | - wp_enqueue_style( 'subway-style', SUBWAY_DIR_URL . 'assets/css/subway.css' ); |
|
40 | + wp_enqueue_style('subway-style', SUBWAY_DIR_URL . 'assets/css/subway.css'); |
|
41 | 41 | |
42 | - if ( ! is_user_logged_in() ) { |
|
42 | + if ( ! is_user_logged_in()) { |
|
43 | 43 | |
44 | - wp_enqueue_script( 'subway-script', SUBWAY_DIR_URL . 'assets/js/subway.js', array( 'jquery' ) ); |
|
44 | + wp_enqueue_script('subway-script', SUBWAY_DIR_URL . 'assets/js/subway.js', array('jquery')); |
|
45 | 45 | |
46 | - wp_localize_script( 'subway-script', 'subway_config', array( |
|
47 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
48 | - 'login_http_error' => esc_html__( 'An error occured while transmitting the data. Refresh the page and try again', 'subway' ), |
|
46 | + wp_localize_script('subway-script', 'subway_config', array( |
|
47 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
48 | + 'login_http_error' => esc_html__('An error occured while transmitting the data. Refresh the page and try again', 'subway'), |
|
49 | 49 | ) |
50 | 50 | ); |
51 | 51 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace Subway; |
14 | 14 | |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | return; |
17 | 17 | } |
18 | 18 | /** |
@@ -30,15 +30,15 @@ discard block |
||
30 | 30 | public static function index() { |
31 | 31 | |
32 | 32 | // Only execute for non logged in users. |
33 | - if ( is_user_logged_in() ) { |
|
33 | + if (is_user_logged_in()) { |
|
34 | 34 | return; |
35 | 35 | } |
36 | 36 | |
37 | 37 | $queried_id = get_queried_object_id(); |
38 | 38 | |
39 | - $current_post = get_post( absint( $queried_id ) ); |
|
39 | + $current_post = get_post(absint($queried_id)); |
|
40 | 40 | |
41 | - $login_page_id = absint( get_option( 'subway_login_page' ) ); |
|
41 | + $login_page_id = absint(get_option('subway_login_page')); |
|
42 | 42 | |
43 | 43 | $excluded_page = Options::get_public_post_ids(); |
44 | 44 | |
@@ -46,59 +46,59 @@ discard block |
||
46 | 46 | $redirect_page = Options::get_redirect_page_url(); // WPCS XSS OK. |
47 | 47 | |
48 | 48 | // Exit if site is public. |
49 | - if ( Options::is_public_site() ) { |
|
49 | + if (Options::is_public_site()) { |
|
50 | 50 | return; |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Check if redirect page is empty or not. |
54 | - if ( empty( $redirect_page ) ) { |
|
54 | + if (empty($redirect_page)) { |
|
55 | 55 | return; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Check if buddypress activate page. |
59 | - if ( function_exists( 'bp_is_activation_page' ) ) { |
|
60 | - if ( bp_is_activation_page() ) { |
|
59 | + if (function_exists('bp_is_activation_page')) { |
|
60 | + if (bp_is_activation_page()) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
65 | 65 | // Check if buddypress registration page. |
66 | - if ( function_exists( 'bp_is_register_page' ) ) { |
|
67 | - if ( bp_is_register_page() ) { |
|
66 | + if (function_exists('bp_is_register_page')) { |
|
67 | + if (bp_is_register_page()) { |
|
68 | 68 | return; |
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | 72 | // Assign 0 value to empty $post->ID to prevent exception. |
73 | 73 | // This applies to custom WordPress pages such as BP Members Page and Groups. |
74 | - if ( empty( $current_post ) ) { |
|
74 | + if (empty($current_post)) { |
|
75 | 75 | $current_post = new \stdclass; |
76 | 76 | $current_post->ID = 0; |
77 | 77 | } |
78 | 78 | |
79 | - $current_page_id = absint( $current_post->ID ); |
|
79 | + $current_page_id = absint($current_post->ID); |
|
80 | 80 | |
81 | 81 | // Check if $current_page_id && $selected_blog_id is equal to each other. |
82 | 82 | // If that is the case, get the page ID instead of global $post->ID that the query returns. |
83 | 83 | // The ID of the first post object inside the loop is not correct. |
84 | - $blog_id = absint( get_option( 'page_for_posts' ) ); |
|
84 | + $blog_id = absint(get_option('page_for_posts')); |
|
85 | 85 | |
86 | - if ( is_home() ) { |
|
87 | - if ( $blog_id === $login_page_id ) { |
|
86 | + if (is_home()) { |
|
87 | + if ($blog_id === $login_page_id) { |
|
88 | 88 | $current_page_id = $blog_id; |
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
92 | 92 | // Only execute the script for non-loggedin visitors. |
93 | - if ( ! is_user_logged_in() ) { |
|
93 | + if ( ! is_user_logged_in()) { |
|
94 | 94 | |
95 | - if ( $current_page_id !== $login_page_id ) { |
|
95 | + if ($current_page_id !== $login_page_id) { |
|
96 | 96 | |
97 | - if ( ! in_array( $current_page_id, $excluded_page, true ) ) { |
|
97 | + if ( ! in_array($current_page_id, $excluded_page, true)) { |
|
98 | 98 | |
99 | 99 | wp_safe_redirect( |
100 | 100 | add_query_arg( |
101 | - array( '_redirected' => 'yes' ), |
|
101 | + array('_redirected' => 'yes'), |
|
102 | 102 | $redirect_page |
103 | 103 | ) |
104 | 104 | ); |
@@ -158,7 +158,7 @@ |
||
158 | 158 | } |
159 | 159 | |
160 | 160 | // Otherwise, return the Subway login page. |
161 | - return $subway_login_page; |
|
161 | + return $subway_login_page; |
|
162 | 162 | |
163 | 163 | } |
164 | 164 |
@@ -78,8 +78,6 @@ |
||
78 | 78 | * Returns the filtered redirect url for the current user. |
79 | 79 | * |
80 | 80 | * @param string $redirect_to The default redirect callback argument. |
81 | - * @param string $request The default redirect request callback argument. |
|
82 | - * @param integer $user The current user logging in. |
|
83 | 81 | * @return string The final redirect url. |
84 | 82 | */ |
85 | 83 | public static function get_login_redirect_url( $redirect_to ) { |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace Subway; |
14 | 14 | |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | return; |
17 | 17 | } |
18 | 18 | |
@@ -31,17 +31,17 @@ discard block |
||
31 | 31 | public static function handle_authentication() { |
32 | 32 | |
33 | 33 | // Set the header type to json. |
34 | - header( 'Content-Type: application/json' ); |
|
34 | + header('Content-Type: application/json'); |
|
35 | 35 | |
36 | - $log = filter_input( INPUT_POST, 'log', FILTER_SANITIZE_STRING ); |
|
36 | + $log = filter_input(INPUT_POST, 'log', FILTER_SANITIZE_STRING); |
|
37 | 37 | |
38 | - $pwd = filter_input( INPUT_POST, 'pwd', FILTER_SANITIZE_STRING ); |
|
38 | + $pwd = filter_input(INPUT_POST, 'pwd', FILTER_SANITIZE_STRING); |
|
39 | 39 | |
40 | - if ( empty( $log ) && empty( $pwd ) ) { |
|
40 | + if (empty($log) && empty($pwd)) { |
|
41 | 41 | |
42 | 42 | $response['type'] = 'error'; |
43 | 43 | |
44 | - $response['message'] = esc_html__( 'Username and Password cannot be empty.', 'subway' ); |
|
44 | + $response['message'] = esc_html__('Username and Password cannot be empty.', 'subway'); |
|
45 | 45 | |
46 | 46 | } else { |
47 | 47 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | $response = array(); |
51 | 51 | |
52 | - if ( is_wp_error( $is_signin ) ) { |
|
52 | + if (is_wp_error($is_signin)) { |
|
53 | 53 | |
54 | 54 | $response['type'] = 'error'; |
55 | 55 | |
@@ -59,16 +59,16 @@ discard block |
||
59 | 59 | |
60 | 60 | $response['type'] = 'success'; |
61 | 61 | |
62 | - $response['message'] = esc_html__( 'You have successfully logged-in. Redirecting you in few seconds...' ); |
|
62 | + $response['message'] = esc_html__('You have successfully logged-in. Redirecting you in few seconds...'); |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | } |
66 | 66 | |
67 | - $subway_redirect_url = Auth_Redirect::get_login_redirect_url( '', '' ); |
|
67 | + $subway_redirect_url = Auth_Redirect::get_login_redirect_url('', ''); |
|
68 | 68 | |
69 | - $response['redirect_url'] = apply_filters( 'subway_login_redirect', $subway_redirect_url ); |
|
69 | + $response['redirect_url'] = apply_filters('subway_login_redirect', $subway_redirect_url); |
|
70 | 70 | |
71 | - echo wp_json_encode( $response ); |
|
71 | + echo wp_json_encode($response); |
|
72 | 72 | |
73 | 73 | wp_die(); |
74 | 74 | |
@@ -82,42 +82,42 @@ discard block |
||
82 | 82 | * @param integer $user The current user logging in. |
83 | 83 | * @return string The final redirect url. |
84 | 84 | */ |
85 | - public static function get_login_redirect_url( $redirect_to ) { |
|
85 | + public static function get_login_redirect_url($redirect_to) { |
|
86 | 86 | |
87 | - $subway_redirect_type = get_option( 'subway_redirect_type' ); |
|
87 | + $subway_redirect_type = get_option('subway_redirect_type'); |
|
88 | 88 | |
89 | 89 | // Redirect the user to default behaviour if there are no redirect type option saved. |
90 | - if ( empty( $subway_redirect_type ) ) { |
|
90 | + if (empty($subway_redirect_type)) { |
|
91 | 91 | |
92 | 92 | return $redirect_to; |
93 | 93 | |
94 | 94 | } |
95 | 95 | |
96 | - if ( 'default' === $subway_redirect_type ) { |
|
96 | + if ('default' === $subway_redirect_type) { |
|
97 | 97 | return $redirect_to; |
98 | 98 | } |
99 | 99 | |
100 | - if ( 'page' === $subway_redirect_type ) { |
|
100 | + if ('page' === $subway_redirect_type) { |
|
101 | 101 | |
102 | 102 | // Get the page url of the selected page if the admin selected 'Custom Page' in the redirect type settings. |
103 | - $selected_redirect_page = intval( get_option( 'subway_redirect_page_id' ) ); |
|
103 | + $selected_redirect_page = intval(get_option('subway_redirect_page_id')); |
|
104 | 104 | |
105 | 105 | // Redirect to default WordPress behaviour if the user did not select page. |
106 | - if ( empty( $selected_redirect_page ) ) { |
|
106 | + if (empty($selected_redirect_page)) { |
|
107 | 107 | |
108 | 108 | return $redirect_to; |
109 | 109 | } |
110 | 110 | |
111 | 111 | // Otherwise, get the permalink of the saved page and let the user go into that page. |
112 | - return get_permalink( $selected_redirect_page ); |
|
112 | + return get_permalink($selected_redirect_page); |
|
113 | 113 | |
114 | - } elseif ( 'custom_url' === $subway_redirect_type ) { |
|
114 | + } elseif ('custom_url' === $subway_redirect_type) { |
|
115 | 115 | |
116 | 116 | // Get the custom url saved in the redirect type settings. |
117 | - $entered_custom_url = get_option( 'subway_redirect_custom_url' ); |
|
117 | + $entered_custom_url = get_option('subway_redirect_custom_url'); |
|
118 | 118 | |
119 | 119 | // Redirect to default WordPress behaviour if the user did enter a custom url. |
120 | - if ( empty( $entered_custom_url ) ) { |
|
120 | + if (empty($entered_custom_url)) { |
|
121 | 121 | |
122 | 122 | return $redirect_to; |
123 | 123 | |
@@ -126,12 +126,12 @@ discard block |
||
126 | 126 | // Otherwise, get the custom url saved and let the user go into that page. |
127 | 127 | $current_user = wp_get_current_user(); |
128 | 128 | |
129 | - if ( ! empty( $current_user->ID ) ) { |
|
130 | - $entered_custom_url = str_replace( '%user_id%', $current_user->ID, $entered_custom_url ); |
|
129 | + if ( ! empty($current_user->ID)) { |
|
130 | + $entered_custom_url = str_replace('%user_id%', $current_user->ID, $entered_custom_url); |
|
131 | 131 | } |
132 | 132 | |
133 | - if ( ! empty( $current_user->user_login ) ) { |
|
134 | - $entered_custom_url = str_replace( '%user_name%', $current_user->user_login, $entered_custom_url ); |
|
133 | + if ( ! empty($current_user->user_login)) { |
|
134 | + $entered_custom_url = str_replace('%user_name%', $current_user->user_login, $entered_custom_url); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | return $entered_custom_url; |
@@ -148,12 +148,12 @@ discard block |
||
148 | 148 | * @param string $login_url The login url. |
149 | 149 | * @return string The final login url. |
150 | 150 | */ |
151 | - public static function login_url( $login_url ) { |
|
151 | + public static function login_url($login_url) { |
|
152 | 152 | |
153 | 153 | $subway_login_page = Options::get_redirect_page_url(); |
154 | 154 | |
155 | 155 | // Return the default login url if there is no log-in page defined. |
156 | - if ( empty( $subway_login_page ) ) { |
|
156 | + if (empty($subway_login_page)) { |
|
157 | 157 | return $login_url; |
158 | 158 | } |
159 | 159 | |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | |
172 | 172 | $subway_login_page = Options::get_redirect_page_url(); |
173 | 173 | |
174 | - wp_safe_redirect( esc_url( $subway_login_page . '?loggedout=true' ) ); |
|
174 | + wp_safe_redirect(esc_url($subway_login_page . '?loggedout=true')); |
|
175 | 175 | |
176 | 176 | Helpers::close(); |
177 | 177 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | namespace Subway; |
14 | 14 | |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | return; |
17 | 17 | } |
18 | 18 | |
@@ -30,19 +30,19 @@ discard block |
||
30 | 30 | */ |
31 | 31 | public static function get_redirect_page_url() { |
32 | 32 | |
33 | - $selected_login_post_id = intval( get_option( 'subway_login_page' ) ); |
|
33 | + $selected_login_post_id = intval(get_option('subway_login_page')); |
|
34 | 34 | |
35 | - if ( 0 === $selected_login_post_id ) { |
|
35 | + if (0 === $selected_login_post_id) { |
|
36 | 36 | |
37 | 37 | return; |
38 | 38 | |
39 | 39 | } |
40 | 40 | |
41 | - $login_post = get_post( $selected_login_post_id ); |
|
41 | + $login_post = get_post($selected_login_post_id); |
|
42 | 42 | |
43 | - if ( ! empty( $login_post ) ) { |
|
43 | + if ( ! empty($login_post)) { |
|
44 | 44 | |
45 | - return trailingslashit( get_permalink( $login_post->ID ) ); |
|
45 | + return trailingslashit(get_permalink($login_post->ID)); |
|
46 | 46 | |
47 | 47 | } |
48 | 48 | |
@@ -57,19 +57,19 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public static function get_public_post_ids() { |
59 | 59 | |
60 | - $subway_public_post = get_option( 'subway_public_post' ); |
|
60 | + $subway_public_post = get_option('subway_public_post'); |
|
61 | 61 | |
62 | 62 | $excluded_pages_collection = array(); |
63 | 63 | |
64 | - if ( ! empty( $subway_public_post ) ) { |
|
64 | + if ( ! empty($subway_public_post)) { |
|
65 | 65 | |
66 | - $excluded_pages_collection = explode( ',', $subway_public_post ); |
|
66 | + $excluded_pages_collection = explode(',', $subway_public_post); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | |
70 | 70 | // Should filter it by integer, spaces will be ignored, other strings. |
71 | 71 | // Will be converted to zero '0'. |
72 | - return array_filter( array_map( 'intval', $excluded_pages_collection ) ); |
|
72 | + return array_filter(array_map('intval', $excluded_pages_collection)); |
|
73 | 73 | |
74 | 74 | } |
75 | 75 | |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | */ |
81 | 81 | public static function is_public_site() { |
82 | 82 | |
83 | - $subway_public_post = get_option( 'subway_is_public' ); |
|
83 | + $subway_public_post = get_option('subway_is_public'); |
|
84 | 84 | |
85 | - if ( ! empty ( $subway_public_post ) ) { |
|
85 | + if ( ! empty ($subway_public_post)) { |
|
86 | 86 | |
87 | 87 | return true; |
88 | 88 |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @package Subway |
11 | 11 | */ |
12 | 12 | |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | return; |
15 | 15 | } |
16 | 16 | |
@@ -21,24 +21,24 @@ discard block |
||
21 | 21 | */ |
22 | 22 | function subway_login_page_form() { |
23 | 23 | |
24 | - $subway_login_page_id = intval( get_option( 'subway_login_page' ) ); |
|
24 | + $subway_login_page_id = intval(get_option('subway_login_page')); |
|
25 | 25 | |
26 | - if ( ! empty( $subway_login_page_id ) ) { |
|
26 | + if ( ! empty($subway_login_page_id)) { |
|
27 | 27 | |
28 | - $login_page_object = get_post( $subway_login_page_id ); |
|
28 | + $login_page_object = get_post($subway_login_page_id); |
|
29 | 29 | |
30 | - if ( ! empty( $login_page_object ) && isset( $login_page_object->post_content ) ) { |
|
30 | + if ( ! empty($login_page_object) && isset($login_page_object->post_content)) { |
|
31 | 31 | |
32 | 32 | // Automatically prepend the login shortcode if no |
33 | 33 | // Shortcode exists in the selected login page. |
34 | - if ( ! has_shortcode( $login_page_object->post_content, 'subway_login' ) ) { |
|
34 | + if ( ! has_shortcode($login_page_object->post_content, 'subway_login')) { |
|
35 | 35 | |
36 | 36 | $new_post_object = array( |
37 | 37 | 'ID' => $login_page_object->ID, |
38 | - 'post_content' => '[subway_login] ' . $login_page_object->post_content,// Prepend Only. |
|
38 | + 'post_content' => '[subway_login] ' . $login_page_object->post_content, // Prepend Only. |
|
39 | 39 | ); |
40 | 40 | |
41 | - wp_update_post( $new_post_object ); |
|
41 | + wp_update_post($new_post_object); |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | } |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | wp_dropdown_pages( |
47 | 47 | array( |
48 | 48 | 'name' => 'subway_login_page', |
49 | - 'selected' => intval( $subway_login_page_id ), |
|
50 | - 'show_option_none' => esc_html__( '---', 'subway' ), |
|
49 | + 'selected' => intval($subway_login_page_id), |
|
50 | + 'show_option_none' => esc_html__('---', 'subway'), |
|
51 | 51 | ) |
52 | 52 | ); |
53 | 53 | |
54 | - echo '<p class="description">' . sprintf( esc_html__( 'Select a login page and save the changes to make your site private. Leave blank to make your site public. %1$s.', 'subway' ), '<span style="font-weight: bold; color: #e53935;">' . esc_html__( 'You need to add "[subway_login]" shortcode in the selected page to show the login form (this will be done automatically after saving)', 'subway' ) ) . '</span></p>'; |
|
54 | + echo '<p class="description">' . sprintf(esc_html__('Select a login page and save the changes to make your site private. Leave blank to make your site public. %1$s.', 'subway'), '<span style="font-weight: bold; color: #e53935;">' . esc_html__('You need to add "[subway_login]" shortcode in the selected page to show the login form (this will be done automatically after saving)', 'subway')) . '</span></p>'; |
|
55 | 55 | |
56 | 56 | return; |
57 | 57 | } |