Last active
July 14, 2020 18:06
-
-
Save cabrailsford/78945cf3e186cf092a590def8f887658 to your computer and use it in GitHub Desktop.
Functions to enforce showing of excerpt regardless of previous checkbox selection, and to hide the excerpt checkbox option.
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
<?php | |
// Update post to force show of excerpt | |
function edit_post_show_excerpt() { | |
$user = wp_get_current_user(); | |
$unchecked = get_user_meta( $user->ID, 'metaboxhidden_post', true ); | |
if( !empty( $unchecked ) ){ | |
$key = array_search( 'postexcerpt', $unchecked ); | |
if ( $key !== FALSE ) { | |
array_splice( $unchecked, $key, 1 ); | |
update_user_meta( $user->ID, 'metaboxhidden_post', $unchecked ); | |
} | |
} | |
} | |
add_action( 'admin_init', 'edit_post_show_excerpt', 10 ); | |
// Remove checkbox to hide/unhide excerpt | |
function remove_post_excerpt_checkbox() { ?> | |
<style> | |
.metabox-prefs label[for="postexcerpt-hide"] { | |
display: none; | |
} | |
</style> | |
<?php } | |
add_action( 'admin_head', 'remove_post_excerpt_checkbox' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment