Created
December 10, 2015 15:30
-
-
Save jdhobbsuk/a9fa809e679843c01acd to your computer and use it in GitHub Desktop.
By default, users don't have excerpts displayed in the admin...this forces it.
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
// Force Page CPT to have excerpt (all users) | |
// ------------------------------------------------------------- | |
if ( is_admin() ) : | |
function force_excerpt_box() { | |
// get all post types (excluding posts) | |
$post_types = array('page'); | |
// get all users | |
$all_users = get_users( ); | |
$user_list = array(); | |
$hide_boxes = array( | |
'postcustom', | |
'trackbacksdiv', | |
'commentstatusdiv', | |
'commentsdiv', | |
'slugdiv', | |
'authordiv', | |
'revisionsdiv', | |
); | |
foreach($all_users as $user): | |
$user_list[] = $user->id; | |
endforeach; | |
foreach($user_list as $user): | |
foreach($post_types as $post_type): | |
update_user_option($user, 'metaboxhidden_'.$post_type, $hide_boxes); | |
endforeach; | |
endforeach; | |
update_user_option(1, 'metaboxhidden_page', $hide); | |
} | |
add_action( 'admin_menu', 'force_excerpt_box' ); | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
New users are created with certain admin settings pre-set...this includes not seeing the Page's excerpt in the admin. This forces all users to have certain box settings hidden, excluding the excerpt.