Add option to override chapter status icons
This commit is contained in:
parent
c49925ecb3
commit
e3448c1e79
@ -1344,11 +1344,12 @@ if ( ! function_exists( 'fictioneer_get_list_chapter_meta_row' ) ) {
|
||||
// Setup
|
||||
$output = [];
|
||||
$has_grid_view = ! empty( $args['grid'] );
|
||||
$prefer_chapter_icon = get_option( 'fictioneer_override_chapter_status_icons' );
|
||||
$hide_icons = get_option( 'fictioneer_hide_chapter_icons' ) ||
|
||||
get_post_meta( $data['story_id'] ?? 0, 'fictioneer_story_hide_chapter_icons', true );
|
||||
|
||||
// Password
|
||||
if ( $hide_icons && ! empty( $data['password'] ) ) {
|
||||
if ( ! empty( $data['password'] ) && ( $hide_icons || $prefer_chapter_icon ) ) {
|
||||
$output['protected'] = '<i class="fa-solid fa-lock chapter-group__list-item-protected list-view"></i>';
|
||||
}
|
||||
|
||||
|
@ -944,6 +944,7 @@ function fictioneer_shortcode_chapter_list( $attr ) {
|
||||
$group = empty( $attr['group'] ) ? false : strtolower( trim( $attr['group'] ) );
|
||||
$heading = empty( $attr['heading'] ) ? false : $attr['heading'];
|
||||
$story_id = fictioneer_validate_id( $attr['story_id'] ?? -1, 'fcn_story' );
|
||||
$prefer_chapter_icon = get_option( 'fictioneer_override_chapter_status_icons' );
|
||||
$hide_icons = get_option( 'fictioneer_hide_chapter_icons' );
|
||||
$can_checkmarks = get_option( 'fictioneer_enable_checkmarks' ) && ( is_user_logged_in() || get_option( 'fictioneer_enable_ajax_authentication' ) );
|
||||
$classes = wp_strip_all_tags( $attr['class'] ?? '' );
|
||||
@ -1087,9 +1088,9 @@ function fictioneer_shortcode_chapter_list( $attr ) {
|
||||
<?php
|
||||
if ( ! $hide_icons ) {
|
||||
// Icon hierarchy: password > scheduled > text > normal
|
||||
if ( $has_password ) {
|
||||
if ( ! $prefer_chapter_icon && $has_password ) {
|
||||
$icon = '<i class="fa-solid fa-lock chapter-group__list-item-icon"></i>';
|
||||
} elseif ( get_post_status( $chapter_id ) === 'future' ) {
|
||||
} elseif ( ! $prefer_chapter_icon && get_post_status( $chapter_id ) === 'future' ) {
|
||||
$icon = '<i class="fa-solid fa-calendar-days chapter-group__list-item-icon"></i>';
|
||||
} elseif ( $text_icon ) {
|
||||
$icon = "<span class='chapter-group__list-item-icon _text text-icon'>{$text_icon}</span>";
|
||||
|
@ -510,6 +510,7 @@ function fictioneer_story_chapters( $args ) {
|
||||
// Setup
|
||||
$story_id = $args['story_id'];
|
||||
$story = $args['story_data'];
|
||||
$prefer_chapter_icon = get_option( 'fictioneer_override_chapter_status_icons' );
|
||||
$hide_icons = get_post_meta( $story_id, 'fictioneer_story_hide_chapter_icons', true ) ||
|
||||
get_option( 'fictioneer_hide_chapter_icons' );
|
||||
$enable_groups = get_option( 'fictioneer_enable_chapter_groups' ) &&
|
||||
@ -655,9 +656,9 @@ function fictioneer_story_chapters( $args ) {
|
||||
<?php
|
||||
if ( ! $hide_icons ) {
|
||||
// Icon hierarchy: password > scheduled > text > normal
|
||||
if ( $chapter['password'] ) {
|
||||
if ( ! $prefer_chapter_icon && $chapter['password'] ) {
|
||||
$icon = '<i class="fa-solid fa-lock chapter-group__list-item-icon"></i>';
|
||||
} elseif ( $chapter['status'] === 'future' ) {
|
||||
} elseif ( ! $prefer_chapter_icon && $chapter['status'] === 'future' ) {
|
||||
$icon = '<i class="fa-solid fa-calendar-days chapter-group__list-item-icon"></i>';
|
||||
} elseif ( $chapter['text_icon'] ) {
|
||||
$icon = "<span class='chapter-group__list-item-icon _text text-icon'>{$chapter['text_icon']}</span>";
|
||||
|
@ -647,6 +647,12 @@ define( 'FICTIONEER_OPTIONS', array(
|
||||
'group' => 'fictioneer-settings-general-group',
|
||||
'sanitize_callback' => 'fictioneer_sanitize_checkbox',
|
||||
'default' => 0
|
||||
),
|
||||
'fictioneer_override_chapter_status_icons' => array(
|
||||
'name' => 'fictioneer_override_chapter_status_icons',
|
||||
'group' => 'fictioneer-settings-general-group',
|
||||
'sanitize_callback' => 'fictioneer_sanitize_checkbox',
|
||||
'default' => 0
|
||||
)
|
||||
),
|
||||
'integers' => array(
|
||||
@ -1105,7 +1111,8 @@ function fictioneer_get_option_label( $option ) {
|
||||
'fictioneer_rewrite_chapter_permalinks' => __( 'Rewrite chapter permalinks to include story ', 'fictioneer' ),
|
||||
'fictioneer_enable_xmlrpc' => __( 'Enable XML-RPC', 'fictioneer' ),
|
||||
'fictioneer_disable_emojis' => __( 'Disable WordPress emojis', 'fictioneer' ),
|
||||
'fictioneer_disable_default_formatting_indent' => __( 'Disable default indentation of chapter paragraphs', 'fictioneer' )
|
||||
'fictioneer_disable_default_formatting_indent' => __( 'Disable default indentation of chapter paragraphs', 'fictioneer' ),
|
||||
'fictioneer_override_chapter_status_icons' => __( 'Override chapter status icons', 'fictioneer' )
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -207,12 +207,22 @@
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="fictioneer-card__row">
|
||||
<?php
|
||||
fictioneer_settings_label_checkbox(
|
||||
'fictioneer_override_chapter_status_icons',
|
||||
__( 'Override chapter status icons', 'fictioneer' ),
|
||||
__( 'Always renders the chapter icons instead of locks/etc.', 'fictioneer' )
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="fictioneer-card__row">
|
||||
<?php
|
||||
fictioneer_settings_label_checkbox(
|
||||
'fictioneer_enable_chapter_groups',
|
||||
__( 'Enable chapter groups', 'fictioneer' ),
|
||||
__( 'Display chapters in groups on story pages (if set).', 'fictioneer' )
|
||||
__( 'Renders chapters in groups on story pages (if set).', 'fictioneer' )
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user