Add option to show excerpt on protected posts

This commit is contained in:
Tetrakern 2024-04-06 17:30:59 +02:00
parent b6a7b12922
commit a7b2459be5
4 changed files with 32 additions and 4 deletions

View File

@ -684,6 +684,13 @@ define( 'FICTIONEER_OPTIONS', array(
'sanitize_callback' => 'fictioneer_sanitize_checkbox',
'label' => __( 'Count characters instead of words', 'fictioneer' ),
'default' => 0
),
'fictioneer_show_protected_excerpt' => array(
'name' => 'fictioneer_show_protected_excerpt',
'group' => 'fictioneer-settings-general-group',
'sanitize_callback' => 'fictioneer_sanitize_checkbox',
'label' => __( 'Show excerpt on password-protected posts', 'fictioneer' ),
'default' => 0
)
),
'integers' => array(

View File

@ -159,6 +159,15 @@
?>
</div>
<div class="fictioneer-card__row">
<?php
fictioneer_settings_label_checkbox(
'fictioneer_show_protected_excerpt',
__( 'This may be beneficial for search engines.', 'fictioneer' )
);
?>
</div>
<div class="fictioneer-card__row">
<?php
fictioneer_settings_label_checkbox(

View File

@ -166,9 +166,16 @@ get_header( null, $header_args );
?>
<section id="chapter-content" class="chapter__content content-section">
<?php if ( post_password_required() && $password_note ) : ?>
<?php if ( post_password_required() ) : ?>
<?php if ( $password_note ) : ?>
<div class="chapter__password-note infobox"><?php echo $password_note; ?></div>
<?php endif; ?>
<?php if ( get_option( 'fictioneer_show_protected_excerpt' ) ) : ?>
<div class="resize-font chapter-formatting chapter-font-color chapter-font-family">
<?php echo fictioneer_get_forced_excerpt( $post->ID, 512 ); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<div class="resize-font chapter-formatting chapter-font-color chapter-font-family">
<?php the_content(); ?>
</div>

View File

@ -65,9 +65,14 @@ get_header( null, $header_args );
?>
<section class="story__summary padding-left padding-right">
<?php if ( post_password_required() && $password_note ) : ?>
<?php if ( post_password_required() ) : ?>
<?php if ( $password_note ) : ?>
<div class="story__password-note infobox"><?php echo $password_note; ?></div>
<?php endif; ?>
<?php if ( get_option( 'fictioneer_show_protected_excerpt' ) ) : ?>
<?php echo fictioneer_get_forced_excerpt( $post->ID, 512 ); ?>
<?php endif; ?>
<?php endif; ?>
<?php the_content(); ?>
</section>