ID, ‘tcgovTheme_pageSubtitle’, true );
echo ‘
‘;
echo ‘‘;
}
/* ================================================================ */
// WHEN POST IS SUBMITTED, SAVE CUSTOM INFO
//@param int $post_id The ID of the post being saved.
function tcgovTheme_save_postdata( $post_id ) {
/*
* We need to verify this came from the our screen and with proper authorization,
* because save_post can be triggered at other times.
*/
// Check if our nonce is set.
if ( ! isset( $_POST[‘tcgovTheme_inner_custom_box_nonce’] ) )
return $post_id;
$nonce = $_POST[‘tcgovTheme_inner_custom_box_nonce’];
// Verify that the nonce is valid.
if ( ! wp_verify_nonce( $nonce, ‘tcgovTheme_inner_custom_box’ ) )
return $post_id;
// If this is an autosave, our form has not been submitted, so we don’t want to do anything.
if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE )
return $post_id;
// Check the user’s permissions.
if ( ‘page’ == $_POST[‘post_type’] ) {
if ( ! current_user_can( ‘edit_page’, $post_id ) )
return $post_id;
} else {
if ( ! current_user_can( ‘edit_post’, $post_id ) )
return $post_id;
}
/* OK, its safe for us to save the data now. */
// Sanitize user input.
$mydata = sanitize_text_field( $_POST[‘tcgovTheme_new_field’] );
// Update the meta field in the database.
update_post_meta( $post_id, ‘tcgovTheme_pageSubtitle’, $mydata );
}
add_action( ‘save_post’, ‘tcgovTheme_save_postdata’ );
/* ================================================================ */
// ADD CSS TO WP ADMIN //
function metabox_css(){
// CSS //
wp_register_style( ‘metabox_css’, get_template_directory_uri() . ‘/admin_extras.css’, false, ‘1.0.0’ );
wp_enqueue_style(‘metabox_css’);
}
add_action( ‘admin_enqueue_scripts’, ‘metabox_css’ );