Changeset 1119133
- Timestamp:
- 03/23/2015 08:19:17 PM (11 years ago)
- Location:
- simple-permissions
- Files:
-
- 2 edited
- 3 copied
-
tags/1.2.0 (copied) (copied from simple-permissions/trunk)
-
tags/1.2.0/readme.txt (copied) (copied from simple-permissions/trunk/readme.txt) (3 diffs)
-
tags/1.2.0/simple-permissions.php (copied) (copied from simple-permissions/trunk/simple-permissions.php) (8 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/simple-permissions.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simple-permissions/tags/1.2.0/readme.txt
r1085570 r1119133 4 4 Tags: 5 5 Requires at least: 3.5.2 6 Tested up to: 4.1. 07 Stable tag: 1. 1.46 Tested up to: 4.1.1 7 Stable tag: 1.2.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 34 34 35 35 == Changelog == 36 37 = 1.2.0 = 38 * Fixed (hopefully!) an issue where you would not be redirected to the proper page after login when presented with a protected page notice. I'm getting around this by not redirecting at all. Instead, I'm replacing the requested pages content with the content of the protected page notice. 36 39 37 40 = 1.1.4 = … … 64 67 == Upgrade Notice == 65 68 69 = 1.2.0 = 70 * Pretty significant bug fix. Upgrade suggested. 71 66 72 = 1.1.4 = 67 73 * Minor bug fix. Upgrade if you were having trouble auto saving drafts. -
simple-permissions/tags/1.2.0/simple-permissions.php
r1085570 r1119133 2 2 /** 3 3 * @package Simple-Permissions 4 * @version 1. 1.44 * @version 1.2.0 5 5 */ 6 6 /* … … 9 9 Description: Create simple permission groups for reading or editing posts. 10 10 Author: Michael George 11 Version: 1. 1.411 Version: 1.2.0 12 12 13 13 This program is free software; you can redistribute it and/or modify … … 169 169 // [2] Associated object ID 170 170 function spUserCanDo( $allcaps, $cap, $args ) { 171 //error_log( "userCanDo cap: " . print_r( $cap, true ) . " args: " . print_r( $args, true ) ); 171 172 $protectedOperations = array( 172 173 'delete_page' … … 180 181 //if we are not checking for a specific post, do nothing 181 182 if ( ! isset( $args[2] ) || ! is_numeric( $args[2] ) ) { 182 error_log( "here" );183 183 return $allcaps; 184 184 } … … 186 186 //Bail out if operation isn't protected 187 187 if ( ! in_array( $args[0], $protectedOperations ) ) { 188 error_log( "here2" );189 188 return $allcaps; 190 189 } … … 193 192 //available to admins and super admins 194 193 if ( $allcaps['activate_plugins'] ) { 195 error_log( "here3" );196 194 return $allcaps; 197 195 } … … 243 241 } 244 242 243 //Since 1.2.0 244 //Re-wrote this function as I was seeing wonky things with browswers not actually giving up cached 245 //versions of the redirect page. When someone would hit a protected page, they could then login, but 246 //the browser would navigate back to the protected warning because that's what it did last time, so 247 //why would it be different this time? 248 //My solution is to override the content of the post with the content of the protection page. 245 249 function spOverride404() { 246 250 global $wp_query; … … 253 257 $postid = url_to_postid( "http" . ( isset($_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] != 'off' ? "s" : "" ) . "://" . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI'] ); 254 258 if ( $postid != 0 ) { 255 $redirecturl = get_permalink( $devOptions['redirectPageID'] ); 256 if ( $redirecturl !== false ) { 257 $is404Check = false; 258 wp_redirect( $redirecturl, 301 ); 259 exit; 260 } 261 } 262 } 259 $is404Check = false; 260 $redirectID = $devOptions['redirectPageID']; 261 //error_log( "redirectID: $redirectID" ); 262 if ( ! empty( $redirectID ) && is_numeric( $redirectID ) ) { 263 $redirectPost = get_post( $redirectID ); 264 $wp_query->is_404 = false; 265 $wp_query->is_single = true; 266 $wp_query->found_posts = 1; 267 $redirectPost = get_post( $devOptions['redirectPageID'] ); 268 $post->post_content_filtered = apply_filters( 'the_content', $redirectPost->post_content ); 269 $post = get_post( $postid ); 270 $post->post_content = $redirectPost->post_content; 271 $post->comment_status = 'closed'; 272 $post->comment_count = 0; 273 $post->ID = $devOptions['redirectPageID']; 274 $wp_query->posts[] = $post; 275 $wp_query->post = $post; 276 $wp_query->in_the_loop = true; 277 $wp_query->current_post = -1; 278 $wp_query->comment_count = 0; 279 $wp_query->post_count = 1; 280 } else { 281 //error_log( "empty: " . print_r( ! empty( $redirectID ), true ) . " - numeric: " . print_r( is_numeric( $redirectID ), true ) ); 282 //If no page id is specified in the SP settings, then let the standard 404 action happen 283 //This may be affected by themes or other plugins 284 } 285 } 286 } 287 } 288 289 function spCustom404( $standard_404 ) { 290 global $wp_query; 291 global $post; 292 global $is404Check; 293 294 if ( $wp_query->is_404 == true ) { 295 $is404Check = true; 296 $devOptions = $this->spGetAdminOptions(); 297 $postid = url_to_postid( "http" . ( isset($_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] != 'off' ? "s" : "" ) . "://" . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI'] ); 298 if ( $postid != 0 ) { 299 $redirectPost = get_post( $devOptions['redirectPageID'] ); 300 $post->post_content = apply_filters( 'the_content', $redirectPost->post_content ); 301 error_log( "post2: " . print_r( $post, true ) ); 302 return ( "echo \"" . $post->post_content . "\";" ); 303 } 304 } 305 306 return $standard_404; 263 307 } 264 308 -
simple-permissions/trunk/readme.txt
r1085570 r1119133 4 4 Tags: 5 5 Requires at least: 3.5.2 6 Tested up to: 4.1. 07 Stable tag: 1. 1.46 Tested up to: 4.1.1 7 Stable tag: 1.2.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 34 34 35 35 == Changelog == 36 37 = 1.2.0 = 38 * Fixed (hopefully!) an issue where you would not be redirected to the proper page after login when presented with a protected page notice. I'm getting around this by not redirecting at all. Instead, I'm replacing the requested pages content with the content of the protected page notice. 36 39 37 40 = 1.1.4 = … … 64 67 == Upgrade Notice == 65 68 69 = 1.2.0 = 70 * Pretty significant bug fix. Upgrade suggested. 71 66 72 = 1.1.4 = 67 73 * Minor bug fix. Upgrade if you were having trouble auto saving drafts. -
simple-permissions/trunk/simple-permissions.php
r1085570 r1119133 2 2 /** 3 3 * @package Simple-Permissions 4 * @version 1. 1.44 * @version 1.2.0 5 5 */ 6 6 /* … … 9 9 Description: Create simple permission groups for reading or editing posts. 10 10 Author: Michael George 11 Version: 1. 1.411 Version: 1.2.0 12 12 13 13 This program is free software; you can redistribute it and/or modify … … 169 169 // [2] Associated object ID 170 170 function spUserCanDo( $allcaps, $cap, $args ) { 171 //error_log( "userCanDo cap: " . print_r( $cap, true ) . " args: " . print_r( $args, true ) ); 171 172 $protectedOperations = array( 172 173 'delete_page' … … 180 181 //if we are not checking for a specific post, do nothing 181 182 if ( ! isset( $args[2] ) || ! is_numeric( $args[2] ) ) { 182 error_log( "here" );183 183 return $allcaps; 184 184 } … … 186 186 //Bail out if operation isn't protected 187 187 if ( ! in_array( $args[0], $protectedOperations ) ) { 188 error_log( "here2" );189 188 return $allcaps; 190 189 } … … 193 192 //available to admins and super admins 194 193 if ( $allcaps['activate_plugins'] ) { 195 error_log( "here3" );196 194 return $allcaps; 197 195 } … … 243 241 } 244 242 243 //Since 1.2.0 244 //Re-wrote this function as I was seeing wonky things with browswers not actually giving up cached 245 //versions of the redirect page. When someone would hit a protected page, they could then login, but 246 //the browser would navigate back to the protected warning because that's what it did last time, so 247 //why would it be different this time? 248 //My solution is to override the content of the post with the content of the protection page. 245 249 function spOverride404() { 246 250 global $wp_query; … … 253 257 $postid = url_to_postid( "http" . ( isset($_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] != 'off' ? "s" : "" ) . "://" . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI'] ); 254 258 if ( $postid != 0 ) { 255 $redirecturl = get_permalink( $devOptions['redirectPageID'] ); 256 if ( $redirecturl !== false ) { 257 $is404Check = false; 258 wp_redirect( $redirecturl, 301 ); 259 exit; 260 } 261 } 262 } 259 $is404Check = false; 260 $redirectID = $devOptions['redirectPageID']; 261 //error_log( "redirectID: $redirectID" ); 262 if ( ! empty( $redirectID ) && is_numeric( $redirectID ) ) { 263 $redirectPost = get_post( $redirectID ); 264 $wp_query->is_404 = false; 265 $wp_query->is_single = true; 266 $wp_query->found_posts = 1; 267 $redirectPost = get_post( $devOptions['redirectPageID'] ); 268 $post->post_content_filtered = apply_filters( 'the_content', $redirectPost->post_content ); 269 $post = get_post( $postid ); 270 $post->post_content = $redirectPost->post_content; 271 $post->comment_status = 'closed'; 272 $post->comment_count = 0; 273 $post->ID = $devOptions['redirectPageID']; 274 $wp_query->posts[] = $post; 275 $wp_query->post = $post; 276 $wp_query->in_the_loop = true; 277 $wp_query->current_post = -1; 278 $wp_query->comment_count = 0; 279 $wp_query->post_count = 1; 280 } else { 281 //error_log( "empty: " . print_r( ! empty( $redirectID ), true ) . " - numeric: " . print_r( is_numeric( $redirectID ), true ) ); 282 //If no page id is specified in the SP settings, then let the standard 404 action happen 283 //This may be affected by themes or other plugins 284 } 285 } 286 } 287 } 288 289 function spCustom404( $standard_404 ) { 290 global $wp_query; 291 global $post; 292 global $is404Check; 293 294 if ( $wp_query->is_404 == true ) { 295 $is404Check = true; 296 $devOptions = $this->spGetAdminOptions(); 297 $postid = url_to_postid( "http" . ( isset($_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] != 'off' ? "s" : "" ) . "://" . $_SERVER["SERVER_NAME"] . $_SERVER['REQUEST_URI'] ); 298 if ( $postid != 0 ) { 299 $redirectPost = get_post( $devOptions['redirectPageID'] ); 300 $post->post_content = apply_filters( 'the_content', $redirectPost->post_content ); 301 error_log( "post2: " . print_r( $post, true ) ); 302 return ( "echo \"" . $post->post_content . "\";" ); 303 } 304 } 305 306 return $standard_404; 263 307 } 264 308
Note: See TracChangeset
for help on using the changeset viewer.