Created
June 19, 2023 16:48
-
-
Save ofernandolopes/59581f504fe1a410369855c55d76819f to your computer and use it in GitHub Desktop.
Remove the 'all', 'publish', 'future', 'sticky', 'draft', 'pending', 'trash' views for non-admins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Remove the 'all', 'publish', 'future', 'sticky', 'draft', 'pending', 'trash' views for non-admins | |
//https://wordpress.stackexchange.com/questions/224159/how-to-disable-or-remove-all-posts-published-and-trash-in-dashboard-posts | |
add_filter( 'views_edit-post', function( $views ) | |
{ | |
if( current_user_can( 'manage_options' ) ) | |
return $views; | |
$remove_views = [ 'all','publish','future','sticky','draft','pending','trash' ]; | |
foreach( (array) $remove_views as $view ) | |
{ | |
if( isset( $views[$view] ) ) | |
unset( $views[$view] ); | |
} | |
return $views; | |
} ); | |
add_filter( 'views_edit-page', function( $views ) | |
{ | |
if( current_user_can( 'manage_options' ) ) | |
return $views; | |
$remove_views = [ 'all','publish','future','sticky','draft','pending','trash' ]; | |
foreach( (array) $remove_views as $view ) | |
{ | |
if( isset( $views[$view] ) ) | |
unset( $views[$view] ); | |
} | |
return $views; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment