Allow admins to always see protected posts
Because they can get the password anyway.
This commit is contained in:
parent
3097a3e70b
commit
05cac2984e
@ -302,6 +302,7 @@ Fictioneer customizes WordPress by using as many standard action and filter hook
|
||||
| `map_meta_cap` | `fcn_read_others_files`, `fictioneer_edit_others_files`, `fictioneer_delete_others_files`, `fictioneer_override_default_taxonomy_capability_check`, `fictioneer_edit_comments`
|
||||
| `navigation_markup_template` | `fictioneer_pagination_markup`
|
||||
| `nav_menu_link_attributes` | `fictioneer_add_menu_link_attributes`
|
||||
| `post_password_required` | `fictioneer_bypass_password`
|
||||
| `post_stuck` | `fictioneer_prevent_post_sticky`
|
||||
| `postbox_classes_{$screen_id}_{$box_id}` | `fictioneer_append_metabox_classes`
|
||||
| `posts_where` | `fictioneer_exclude_protected_posts`
|
||||
|
@ -424,6 +424,28 @@ if ( ! defined( 'FICTIONEER_ALLOWED_PAGE_TEMPLATES' ) ) {
|
||||
define( 'FICTIONEER_ALLOWED_PAGE_TEMPLATES', [] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Exceptions for post passwords
|
||||
*
|
||||
* @since 5.12.3
|
||||
*
|
||||
* @param bool $required Whether the user needs to supply a password.
|
||||
* @param WP_Post $post Post object.
|
||||
*
|
||||
* @return bool True or false.
|
||||
*/
|
||||
|
||||
function fictioneer_bypass_password( $required, $post ) {
|
||||
// Always allow admins
|
||||
if ( current_user_can( 'manage_options' ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Continue filter
|
||||
return $required;
|
||||
}
|
||||
add_filter( 'post_password_required', 'fictioneer_bypass_password', 10, 2 );
|
||||
|
||||
// No restriction can be applied to administrators
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
$post_types = ['post', 'fcn_story', 'fcn_chapter', 'fcn_collection', 'page', 'fcn_recommendation'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user