Add [!global] render hint to story passwords

This will render the note on all associated chapters if they do not have a more specific note.
This commit is contained in:
Tetrakern 2024-03-03 12:24:59 +01:00
parent 024e0a2775
commit 143340a4db
2 changed files with 11 additions and 1 deletions

View File

@ -1996,7 +1996,7 @@ function fictioneer_render_story_data_metabox( $post ) {
'fictioneer_story_password_note',
array(
'label' => _x( 'Password Note', 'Story password note meta field label.', 'fictioneer' ),
'description' => __( 'Displayed for password protected content. Limited HTML allowed.', 'fictioneer' )
'description' => __( 'Displayed for password protected content; start with "[!global]" to show on all protected chapters without note. Limited HTML allowed.', 'fictioneer' )
)
);

View File

@ -153,6 +153,16 @@ get_header( null, $header_args );
// Password note
$password_note = fictioneer_get_content_field( 'fictioneer_chapter_password_note', $post->ID );
if ( post_password_required() && empty( $password_note ) ) {
$password_note = fictioneer_get_content_field( 'fictioneer_story_password_note', $story_id );
if ( ! empty( $password_note ) && strpos( $password_note, '[!global]' ) !== false ) {
$password_note = str_replace( '[!global]', '', $password_note );
} else {
$password_note = '';
}
}
?>
<section id="chapter-content" class="chapter__content content-section">