diff --git a/functions.php b/functions.php index c510da9..a86cf0e 100755 --- a/functions.php +++ b/functions.php @@ -56,6 +56,9 @@ /** Customizer Additions */ require_once( 'library/bs-customizer-additions.php' ); +/** The "Subhead" metabox and related functions */ +require_once( 'library/metabox-subhead.php' ); + /** Required and Recommended Plugins */ require_once( 'library/class-tgm-plugin-activation.php' ); require_once( 'library/bs-plugin-activation.php' ); @@ -173,4 +176,4 @@ function calhealth_require_files() { } } } -add_action( 'after_setup_theme', 'calhealth_require_files' ); \ No newline at end of file +add_action( 'after_setup_theme', 'calhealth_require_files' ); diff --git a/library/metabox-subhead.php b/library/metabox-subhead.php new file mode 100644 index 0000000..d709b11 --- /dev/null +++ b/library/metabox-subhead.php @@ -0,0 +1,108 @@ + 'post', + 'type' => 'string', + 'description' => __( 'The subhead, deck, subtitle, or lead is a preface shown on article pages below the main title.' , 'allonsy' ), + 'single' => true, + 'sanitize_callback' => 'sanitize_textarea_field', + // 'auth_callback' => '', + 'show_in_rest' => true, + ), + ); +} +add_action( 'init', 'subtitle_meta_box_register_post_meta' ); + +/** + * Output the subtitle metabox. + * + * @link Copied from https://github.com/INN/umbrella-wcij/blob/16247cdd8f03a593633c82f8836c4c1e8aa83987/wp-content/themes/wisconsinwatch/inc/metaboxes.php with improvements + */ +function subtitle_meta_box_display() { + global $post; + $values = get_post_custom( $post->ID ); + wp_nonce_field( 'subtitle_meta_box_nonce', 'subtitle_meta_box_nonce' ); + ?> + + +

+ id="post-">

+ %1$s', + esc_html( $subtitle ), + ); + } + ?>