Version Description
Download this release
Release Info
| Developer | wpmaintainer |
| Plugin | |
| Version | 2.5.3 |
| Comparing to | |
| See all releases | |
Code changes from version 2.5.2 to 2.5.3
- pagerestrict.php +30 -8
- readme.txt +6 -1
pagerestrict.php
CHANGED
|
@@ -5,7 +5,7 @@ Plugin URI: http://theandystratton.com/pagerestrict
|
|
| 5 |
Description: Restrict certain pages to logged in users
|
| 6 |
Author: Matt Martz & Andy Stratton
|
| 7 |
Author URI: http://theandystratton.com
|
| 8 |
-
Version: 2.5.
|
| 9 |
|
| 10 |
Page Restrict is released under the GNU Lesser General Public License (LGPL)
|
| 11 |
http://www.gnu.org/licenses/lgpl-3.0.txt
|
|
@@ -46,11 +46,18 @@ function pr_get_page_content() {
|
|
| 46 |
if ( \pr_get_opt( 'loginform' ) == true ) :
|
| 47 |
|
| 48 |
$errors = '';
|
| 49 |
-
if ( isset( $_GET['
|
| 50 |
{
|
| 51 |
-
$
|
| 52 |
-
|
| 53 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
}
|
| 55 |
|
| 56 |
$user_login = '';
|
|
@@ -201,9 +208,9 @@ function filter_pr_page_title( $title, $is_restricted )
|
|
| 201 |
\add_filter( 'the_excerpt' , 'pr_page_restrict' , 50 );
|
| 202 |
\add_filter( 'comments_array' , 'pr_comment_restrict' , 50 );
|
| 203 |
|
| 204 |
-
\add_action( 'wp_login_failed', 'pr_login_failed', 50,
|
| 205 |
|
| 206 |
-
function pr_login_failed( $username = null )
|
| 207 |
{
|
| 208 |
$referrer = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '';
|
| 209 |
|
|
@@ -226,9 +233,24 @@ function pr_login_failed( $username = null )
|
|
| 226 |
if ( isset( $username->user_login ) )
|
| 227 |
$query['pr-user-login'] = $username->user_login;
|
| 228 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
if ( \count( $query ) > 0 )
|
| 230 |
{
|
| 231 |
-
$redirect .= '?' . \http_build_query( $query );
|
| 232 |
}
|
| 233 |
|
| 234 |
\wp_redirect( $redirect, 303 );
|
| 5 |
Description: Restrict certain pages to logged in users
|
| 6 |
Author: Matt Martz & Andy Stratton
|
| 7 |
Author URI: http://theandystratton.com
|
| 8 |
+
Version: 2.5.3
|
| 9 |
|
| 10 |
Page Restrict is released under the GNU Lesser General Public License (LGPL)
|
| 11 |
http://www.gnu.org/licenses/lgpl-3.0.txt
|
| 46 |
if ( \pr_get_opt( 'loginform' ) == true ) :
|
| 47 |
|
| 48 |
$errors = '';
|
| 49 |
+
if ( isset( $_GET['pr-errors'] ) )
|
| 50 |
{
|
| 51 |
+
$error_messages = \json_decode( \base64_decode( $_GET['pr-errors'] ) );
|
| 52 |
+
|
| 53 |
+
if ( \is_object( $error_messages ) )
|
| 54 |
+
$error_messages = (array) $error_messages;
|
| 55 |
+
|
| 56 |
+
if ( $error_messages && \is_array( $error_messages ) )
|
| 57 |
+
{
|
| 58 |
+
$errors = \implode( '<br>', $error_messages );
|
| 59 |
+
$errors = '<div class="pr-message pr-error"><p>' . $errors . '</p></div>';
|
| 60 |
+
}
|
| 61 |
}
|
| 62 |
|
| 63 |
$user_login = '';
|
| 208 |
\add_filter( 'the_excerpt' , 'pr_page_restrict' , 50 );
|
| 209 |
\add_filter( 'comments_array' , 'pr_comment_restrict' , 50 );
|
| 210 |
|
| 211 |
+
\add_action( 'wp_login_failed', 'pr_login_failed', 50, 2 );
|
| 212 |
|
| 213 |
+
function pr_login_failed( $username = null, $error = false )
|
| 214 |
{
|
| 215 |
$referrer = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '';
|
| 216 |
|
| 233 |
if ( isset( $username->user_login ) )
|
| 234 |
$query['pr-user-login'] = $username->user_login;
|
| 235 |
|
| 236 |
+
if ( $error )
|
| 237 |
+
{
|
| 238 |
+
if ( \is_array( $error->errors ) && \count( $error->errors ) > 0 )
|
| 239 |
+
{
|
| 240 |
+
$error_messages = [];
|
| 241 |
+
|
| 242 |
+
// convert to one dimensional array of messages, preserve WP login error keys
|
| 243 |
+
foreach ( $error->errors as $key => $err )
|
| 244 |
+
$error_messages[ $key ] = \implode( "<br>", $err );
|
| 245 |
+
|
| 246 |
+
$error_messages = \apply_filters( 'pr_login_errors', $error_messages );
|
| 247 |
+
$query['pr-errors'] = \base64_encode( \json_encode( $error_messages ) );
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
if ( \count( $query ) > 0 )
|
| 252 |
{
|
| 253 |
+
$redirect .= '?' . \http_build_query( $query );
|
| 254 |
}
|
| 255 |
|
| 256 |
\wp_redirect( $redirect, 303 );
|
readme.txt
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
Contributors: theandystratton, sivel
|
| 3 |
Tags: pages, page, restrict, restriction, logged in, cms
|
| 4 |
Requires at least: 5.0
|
| 5 |
-
Tested up to: 5.
|
| 6 |
License: GPLv2 or later
|
| 7 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 8 |
Stable tag: trunk
|
|
@@ -47,6 +47,11 @@ NOTE: See "Other Notes" for Upgrade and Usage Instructions as well as other pert
|
|
| 47 |
|
| 48 |
== Changelog ==
|
| 49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
= 2.5.2 =
|
| 51 |
* Added code to use the filtered login form default value for "remember" checkbox allowing the checkbox to be suppressed by the `login_form_defaults` filter.
|
| 52 |
|
| 2 |
Contributors: theandystratton, sivel
|
| 3 |
Tags: pages, page, restrict, restriction, logged in, cms
|
| 4 |
Requires at least: 5.0
|
| 5 |
+
Tested up to: 5.8
|
| 6 |
License: GPLv2 or later
|
| 7 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
| 8 |
Stable tag: trunk
|
| 47 |
|
| 48 |
== Changelog ==
|
| 49 |
|
| 50 |
+
= 2.5.3s =
|
| 51 |
+
* Fixed a bug with login errors not outputting
|
| 52 |
+
* Carried over login errors from default WP login mechanism
|
| 53 |
+
* Added pr_login_errors filter to enable filtering of WP login errors (e.g., obfuscating messaging on front-end)
|
| 54 |
+
|
| 55 |
= 2.5.2 =
|
| 56 |
* Added code to use the filtered login form default value for "remember" checkbox allowing the checkbox to be suppressed by the `login_form_defaults` filter.
|
| 57 |
|
