Force Login - Version 3.3

Version Description

  • Fix - Check for existence of explicit port number before appending port - props Bjrn Ali Gransson.
Download this release

Release Info

Developer kevinvess
Plugin Icon 128x128 Force Login
Version 3.3
Comparing to
See all releases

Code changes from version 3.2 to 3.3

Files changed (2) hide show
  1. readme.txt +8 -5
  2. wp-force-login.php +6 -2
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: kevinvess
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kevin%40vess%2eme&lc=US&item_name=Kevin%20Vess%20-%20WordPress&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
4
  Tags: access, closed, force user login, hidden, login, password, privacy, private, protected, registered only, restricted
5
  Requires at least: 2.7
6
- Tested up to: 4.3
7
- Stable tag: 3.2
8
  License: GPLv2 or later
9
 
10
  Force Login is a simple lightweight plugin that requires visitors to log in to interact with the website.
@@ -38,7 +38,7 @@ Upload the Force Login plugin to your site, then Activate it.
38
 
39
  == Frequently Asked Questions ==
40
 
41
- = How can I specify a URL to redirect to on login? =
42
 
43
  By default, the plugin sends visitors back to the URL they tried to visit. However, you can set a specific URL to always redirect users to by adding the following filter to your functions.php file.
44
 
@@ -56,7 +56,7 @@ function my_forcelogin_redirect() {
56
  add_filter('v_forcelogin_redirect', 'my_forcelogin_redirect', 10, 1);
57
  `
58
 
59
- = How can I add exceptions for certain pages or posts? =
60
 
61
  You can specify an array of URLs to whitelist by adding the following filter to your functions.php file. Each URL must be absolute (as in, http://example.com/mypage/). Recommended: [site_url( '/mypage/' )](https://codex.wordpress.org/Function_Reference/site_url).
62
 
@@ -74,7 +74,7 @@ function my_forcelogin_whitelist( $whitelist ) {
74
  add_filter('v_forcelogin_whitelist', 'my_forcelogin_whitelist', 10, 1);
75
  `
76
 
77
- = How do I get the WordPress mobile app to work? =
78
 
79
  By default, the plugin blocks access to all page URLs; you will need to whitelist the XML-RPC page to allow the WordPress app to access your site for remote publishing.
80
 
@@ -94,6 +94,9 @@ add_filter('v_forcelogin_whitelist', 'my_forcelogin_whitelist', 10, 1);
94
 
95
  == Changelog ==
96
 
 
 
 
97
  = 3.2 =
98
  - Streamlined - removed v_getUrl function to reduce possible duplicates of global functions - props [johappel](https://github.com/johappel).
99
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=kevin%40vess%2eme&lc=US&item_name=Kevin%20Vess%20-%20WordPress&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
4
  Tags: access, closed, force user login, hidden, login, password, privacy, private, protected, registered only, restricted
5
  Requires at least: 2.7
6
+ Tested up to: 4.4
7
+ Stable tag: 3.3
8
  License: GPLv2 or later
9
 
10
  Force Login is a simple lightweight plugin that requires visitors to log in to interact with the website.
38
 
39
  == Frequently Asked Questions ==
40
 
41
+ = 1. How can I specify a URL to redirect to on login? =
42
 
43
  By default, the plugin sends visitors back to the URL they tried to visit. However, you can set a specific URL to always redirect users to by adding the following filter to your functions.php file.
44
 
56
  add_filter('v_forcelogin_redirect', 'my_forcelogin_redirect', 10, 1);
57
  `
58
 
59
+ = 2. How can I add exceptions for certain pages or posts? =
60
 
61
  You can specify an array of URLs to whitelist by adding the following filter to your functions.php file. Each URL must be absolute (as in, http://example.com/mypage/). Recommended: [site_url( '/mypage/' )](https://codex.wordpress.org/Function_Reference/site_url).
62
 
74
  add_filter('v_forcelogin_whitelist', 'my_forcelogin_whitelist', 10, 1);
75
  `
76
 
77
+ = 3. How do I get the WordPress mobile app to work? =
78
 
79
  By default, the plugin blocks access to all page URLs; you will need to whitelist the XML-RPC page to allow the WordPress app to access your site for remote publishing.
80
 
94
 
95
  == Changelog ==
96
 
97
+ = 3.3 =
98
+ - Fix - Check for existence of explicit port number before appending port - props [Björn Ali Göransson](https://github.com/bjorn-ali-goransson).
99
+
100
  = 3.2 =
101
  - Streamlined - removed v_getUrl function to reduce possible duplicates of global functions - props [johappel](https://github.com/johappel).
102
 
wp-force-login.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Force Login
4
  Plugin URI: http://vess.me/
5
  Description: Easily hide your WordPress site from public viewing by requiring visitors to log in first. Activate to turn on.
6
- Version: 3.2
7
  Author: Kevin Vess
8
  Author URI: http://vess.me/
9
  License: GPLv2 or later
@@ -30,7 +30,11 @@ function v_forcelogin() {
30
  // Get URL
31
  $url = isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http';
32
  $url .= '://' . $_SERVER['HTTP_HOST'];
33
- $url .= in_array( $_SERVER['SERVER_PORT'], array('80', '443') ) ? '' : ':' . $_SERVER['SERVER_PORT'];
 
 
 
 
34
  $url .= $_SERVER['REQUEST_URI'];
35
 
36
  // Apply filters
3
  Plugin Name: Force Login
4
  Plugin URI: http://vess.me/
5
  Description: Easily hide your WordPress site from public viewing by requiring visitors to log in first. Activate to turn on.
6
+ Version: 3.3
7
  Author: Kevin Vess
8
  Author URI: http://vess.me/
9
  License: GPLv2 or later
30
  // Get URL
31
  $url = isset( $_SERVER['HTTPS'] ) && 'on' === $_SERVER['HTTPS'] ? 'https' : 'http';
32
  $url .= '://' . $_SERVER['HTTP_HOST'];
33
+
34
+ // port is prepopulated here sometimes
35
+ if( strpos( $_SERVER['HTTP_HOST'], ':' ) === FALSE ) {
36
+ $url .= in_array( $_SERVER['SERVER_PORT'], array('80', '443') ) ? '' : ':' . $_SERVER['SERVER_PORT'];
37
+ }
38
  $url .= $_SERVER['REQUEST_URI'];
39
 
40
  // Apply filters