From f77414413ea82486e8a2cd6e153f67d11a77501a Mon Sep 17 00:00:00 2001 From: Tetrakern <26898880+Tetrakern@users.noreply.github.com> Date: Thu, 9 May 2024 23:11:21 +0200 Subject: [PATCH] Add option to show story header on Story Page template --- DOCUMENTATION.md | 2 +- includes/functions/_setup-meta-fields.php | 25 +++++++++++++++++++--- singular-story.php | 26 +++++++++++++++++++++-- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 689c7299..2d4e5cad 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -397,7 +397,7 @@ Pages work the same as always in WordPress, just with some additional fields and | :-- | :-: | :-- | Short Name | String | Shortened name of the page required for custom tabs in stories. | Filter & Search ID | String | Custom identifier to be used with plugin. Does nothing on its own. -| Story ID | String | ID of a story post. Only used by the "Story Page" page template. +| Story ID | String | ID of a story post. Only used by the "Story Page/Mirror" page templates. ## Shared Options diff --git a/includes/functions/_setup-meta-fields.php b/includes/functions/_setup-meta-fields.php index 40240f5f..3662beee 100644 --- a/includes/functions/_setup-meta-fields.php +++ b/includes/functions/_setup-meta-fields.php @@ -2989,7 +2989,7 @@ function fictioneer_save_chapter_metaboxes( $post_id ) { add_action( 'save_post', 'fictioneer_save_chapter_metaboxes' ); // ============================================================================= -// ADVANCED META FIELDS +// EXTRA META FIELDS // ============================================================================= /** @@ -3011,7 +3011,7 @@ function fictioneer_add_extra_metabox() { add_action( 'add_meta_boxes', 'fictioneer_add_extra_metabox' ); /** - * Render advanced metabox + * Render extra metabox * * @since 5.7.4 * @@ -3095,10 +3095,19 @@ function fictioneer_render_extra_metabox( $post ) { 'fictioneer_template_story_id', array( 'label' => _x( 'Story Id', 'Page story ID meta field label.', 'fictioneer' ), - 'description' => __( 'Used only by the "Story Page" template.', 'fictioneer' ) + 'description' => __( 'Used by the "Story Page/Mirror" templates.', 'fictioneer' ) ) ); } + + // Checkbox: Show story template header + if ( current_user_can( 'manage_options' ) ) { + $output['fictioneer_template_show_story_header'] = fictioneer_get_metabox_checkbox( + $post, + 'fictioneer_template_show_story_header', + __( 'Show story template header', 'fictioneer' ) + ); + } } // Story blogs @@ -3295,6 +3304,16 @@ function fictioneer_save_extra_metabox( $post_id ) { } } + // Checkbox: Show story template header + if ( + isset( $_POST['fictioneer_template_show_story_header'] ) && + $post_type === 'page' && + current_user_can( 'manage_options' ) + ) { + $fields['fictioneer_template_show_story_header'] = + fictioneer_sanitize_checkbox( $_POST['fictioneer_template_show_story_header'] ); + } + // Story blogs if ( isset( $_POST['fictioneer_post_story_blogs'] ) && $post_type === 'post' ) { $story_blogs = fictioneer_explode_list( $_POST['fictioneer_post_story_blogs'] ); diff --git a/singular-story.php b/singular-story.php index 971d572b..0787fb9c 100644 --- a/singular-story.php +++ b/singular-story.php @@ -13,6 +13,13 @@ // Setup $post_id = get_the_ID(); +$story_id = get_post_meta( $post_id, 'fictioneer_template_story_id', true ); +$story_id = fictioneer_validate_id( $story_id, 'fcn_story' ); +$render_story_header = get_post_meta( $post_id, 'fictioneer_template_show_story_header', true ); + +if ( ! $story_id ) { + $render_story_header = false; +} // Header get_header(); @@ -27,7 +34,7 @@ get_header();
-