Add and apply fcn_reduced_profile cap
Applied to subscribers by default
This commit is contained in:
parent
e0954dd3bf
commit
6559bba251
@ -213,8 +213,8 @@ Fictioneer customizes WordPress by using as many standard action and filter hook
|
||||
| `admin_bar_menu` | `fictioneer_remove_comments_from_admin_bar`
|
||||
| `admin_enqueue_scripts` | `fictioneer_admin_scripts`, `fictioneer_admin_styles`, `fictioneer_disable_moderator_comment_edit`, `fictioneer_hide_private_data`
|
||||
| `admin_head` | `fictioneer_remove_update_notice`
|
||||
| `admin_head-profile.php` | `fictioneer_hide_subscriber_profile_blocks`
|
||||
| `admin_init` | `fictioneer_reduce_subscriber_profile`, `fictioneer_register_settings`, `fictioneer_skip_dashboard`
|
||||
| `admin_head-profile.php` | `fictioneer_remove_profile_blocks`
|
||||
| `admin_init` | `fictioneer_register_settings`, `fictioneer_skip_dashboard`
|
||||
| `admin_menu` | `fictioneer_add_admin_menu`, `fictioneer_remove_dashboard_menu`, `fictioneer_remove_comments_menu_page`
|
||||
| `admin_notices` | `fictioneer_admin_profile_notices`, `fictioneer_admin_settings_notices`, `fictioneer_admin_update_notice`
|
||||
| `admin_post_*` | `fictioneer_purge_all_epubs`, `admin_post_purge_all_seo_schemas`, `fictioneer_purge_seo_meta_caches`, `fictioneer_tools_add_moderator_role`, `fictioneer_tools_remove_moderator_role`, `fictioneer_tools_move_story_tags_to_genres`, `fictioneer_tools_duplicate_story_tags_to_genres`, `fictioneer_tools_purge_story_data_caches`, `fictioneer_tools_move_chapter_tags_to_genres`, `fictioneer_tools_duplicate_chapter_tags_to_genres`, `fictioneer_tools_append_default_genres`, `fictioneer_tools_append_default_tags`, `fictioneer_tools_remove_unused_tags`, `fictioneer_tools_reset_post_relationship_registry`, `fictioneer_tools_fix_users`, `fictioneer_tools_fix_stories`, `fictioneer_tools_fix_chapters`, `fictioneer_tools_fix_collections`, `fictioneer_tools_fix_pages`, `fictioneer_tools_fix_posts`, `fictioneer_tools_fix_recommendations`, `fictioneer_admin_profile_unset_oauth`, `fictioneer_admin_profile_clear_data_node`, `fictioneer_update_frontend_profile`, `fictioneer_cancel_frontend_email_change`
|
||||
|
@ -298,56 +298,6 @@ if ( ! get_option( 'fictioneer_enable_all_blocks' ) ) {
|
||||
add_filter( 'allowed_block_types_all', 'fictioneer_allowed_block_types' );
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// REDUCE SUBSCRIBER ADMIN PROFILE
|
||||
// =============================================================================
|
||||
|
||||
/**
|
||||
* Reduce subscriber profile in admin panel
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
|
||||
function fictioneer_reduce_subscriber_profile() {
|
||||
// Setup
|
||||
$user = wp_get_current_user();
|
||||
|
||||
// Abort if administrator
|
||||
if ( fictioneer_is_admin( $user->ID ) ) return;
|
||||
|
||||
// Remove application password
|
||||
add_filter( 'wp_is_application_passwords_available', '__return_false' );
|
||||
|
||||
// Abort if not a subscriber (higher role)
|
||||
if ( ! in_array( 'subscriber', $user->roles ) ) return;
|
||||
|
||||
// Reduce profile...
|
||||
remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
|
||||
add_filter( 'user_contactmethods', '__return_empty_array', 20 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide subscriber profile blocks in admin panel
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
|
||||
function fictioneer_hide_subscriber_profile_blocks() {
|
||||
// Setup
|
||||
$user = wp_get_current_user();
|
||||
|
||||
// Abort if not a subscriber (higher role)
|
||||
if ( ! in_array( 'subscriber', $user->roles ) ) return;
|
||||
|
||||
// Add CSS to hide blocks...
|
||||
echo '<style>.user-url-wrap, .user-description-wrap, .user-first-name-wrap, .user-last-name-wrap, .user-language-wrap, .user-admin-bar-front-wrap, .user-pass1-wrap, .user-pass2-wrap, .user-generate-reset-link-wrap, #contextual-help-link-wrap, #your-profile > h2:first-of-type { display: none; }</style>';
|
||||
}
|
||||
|
||||
if ( get_option( 'fictioneer_admin_reduce_subscriber_profile' ) ) {
|
||||
add_action( 'admin_init', 'fictioneer_reduce_subscriber_profile' );
|
||||
add_action( 'admin_head-profile.php', 'fictioneer_hide_subscriber_profile_blocks' );
|
||||
}
|
||||
|
||||
// =============================================================================
|
||||
// ADD OR UPDATE TERM
|
||||
// =============================================================================
|
||||
|
@ -40,6 +40,7 @@ function fictioneer_initialize_roles() {
|
||||
$administrator = get_role( 'administrator' );
|
||||
|
||||
$administrator->remove_cap( 'fcn_edit_only_others_comments' );
|
||||
$administrator->remove_cap( 'fcn_reduced_profile' );
|
||||
|
||||
foreach ( $all as $cap ) {
|
||||
$administrator->add_cap( $cap );
|
||||
@ -77,6 +78,7 @@ function fictioneer_initialize_roles() {
|
||||
);
|
||||
|
||||
$editor->remove_cap( 'fcn_edit_only_others_comments' );
|
||||
$editor->remove_cap( 'fcn_reduced_profile' );
|
||||
|
||||
foreach ( $editor_caps as $cap ) {
|
||||
$editor->add_cap( $cap );
|
||||
@ -166,6 +168,7 @@ function fictioneer_initialize_roles() {
|
||||
$subscriber_caps = array(
|
||||
// Base
|
||||
'fcn_admin_panel_access',
|
||||
'fcn_reduced_profile',
|
||||
// Stories
|
||||
'read_fcn_story',
|
||||
// Chapters
|
||||
@ -800,6 +803,29 @@ if ( ! current_user_can( 'manage_options' ) ) {
|
||||
add_filter( 'comment_row_actions', 'fictioneer_remove_quick_edit', 9999 );
|
||||
add_action( 'admin_enqueue_scripts', 'fictioneer_hide_private_data', 9999 );
|
||||
}
|
||||
|
||||
// === FCN_REDUCED_PROFILE ===================================================
|
||||
|
||||
/**
|
||||
* Hide subscriber profile blocks in admin panel
|
||||
*
|
||||
* @since 5.6.0
|
||||
*/
|
||||
|
||||
function fictioneer_remove_profile_blocks() {
|
||||
// Add CSS to hide blocks...
|
||||
echo '<style>.user-url-wrap, .user-description-wrap, .user-first-name-wrap, .user-last-name-wrap, .user-language-wrap, .user-admin-bar-front-wrap, .user-pass1-wrap, .user-pass2-wrap, .pw-weak, .user-generate-reset-link-wrap, #contextual-help-link-wrap, #your-profile > h2:first-of-type { display: none; }</style>';
|
||||
|
||||
// Add JS to remove blocks...
|
||||
echo '<script>document.addEventListener("DOMContentLoaded", () =>{document.querySelectorAll(".user-pass1-wrap, .user-pass2-wrap, .pw-weak, .user-generate-reset-link-wrap").forEach(element => {console.log(element); element.remove();});});</script>';
|
||||
}
|
||||
|
||||
if ( current_user_can( 'fcn_reduced_profile' ) ) {
|
||||
add_filter( 'wp_is_application_passwords_available', '__return_false', 9999 );
|
||||
add_filter( 'user_contactmethods', '__return_empty_array', 9999 );
|
||||
add_action( 'admin_head-profile.php', 'fictioneer_remove_profile_blocks', 9999 );
|
||||
remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -517,13 +517,6 @@ define( 'FICTIONEER_OPTIONS', array(
|
||||
'label' => __( 'Enable AJAX user authentication', 'fictioneer' ),
|
||||
'default' => false
|
||||
),
|
||||
'fictioneer_admin_reduce_subscriber_profile' => array(
|
||||
'name' => 'fictioneer_admin_reduce_subscriber_profile',
|
||||
'group' => 'fictioneer-settings-general-group',
|
||||
'sanitize_callback' => 'fictioneer_sanitize_checkbox',
|
||||
'label' => __( 'Reduce subscriber user profile', 'fictioneer' ),
|
||||
'default' => false
|
||||
),
|
||||
'fictioneer_disable_application_passwords' => array(
|
||||
'name' => 'fictioneer_disable_application_passwords',
|
||||
'group' => 'fictioneer-settings-general-group',
|
||||
|
@ -761,14 +761,6 @@
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label for="fictioneer_admin_reduce_subscriber_profile" class="label-wrapped-checkbox row">
|
||||
<input name="fictioneer_admin_reduce_subscriber_profile" type="checkbox" id="fictioneer_admin_reduce_subscriber_profile" <?php echo checked( 1, get_option( 'fictioneer_admin_reduce_subscriber_profile' ), false ); ?> value="1">
|
||||
<div>
|
||||
<span><?php echo FICTIONEER_OPTIONS['booleans']['fictioneer_admin_reduce_subscriber_profile']['label']; ?></span>
|
||||
<p class="sub-label"><?php _e( 'Removes superfluous blocks from subscriber profile, such as personal options and application passwords.', 'fictioneer' ) ?></p>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label for="fictioneer_disable_application_passwords" class="label-wrapped-checkbox row">
|
||||
<input name="fictioneer_disable_application_passwords" type="checkbox" id="fictioneer_disable_application_passwords" <?php echo checked( 1, get_option( 'fictioneer_disable_application_passwords' ), false ); ?> value="1">
|
||||
<div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user