Add constant for default chapter icon

This commit is contained in:
Tetrakern 2024-05-23 20:30:08 +02:00
parent d952c7011e
commit e20d0ae27e
6 changed files with 13 additions and 7 deletions

View File

@ -1455,6 +1455,7 @@ define( 'CONSTANT_NAME', value );
| FICTIONEER_PRIMARY_FONT_CSS | string | CSS name of the primary font. Default `'Open Sans'`.
| FICTIONEER_PRIMARY_FONT_NAME | string | Display name of the primary font. Default `'Open Sans'`.
| FICTIONEER_TTS_REGEX | string | Splits chapter text into sentences for the text-to-speech feature. Default `'([.!?:"\'\u201C\u201D])\s+(?=[A-Z"\'\u201C\u201D])'`.
| FICTIONEER_DEFAULT_CHAPTER_ICON | string | Chapter icon Font Awesome (Free) classes. Default `'fa-solid fa-book'`.
| FICTIONEER_LATEST_UPDATES_LI_DATE | string | Latest Updates shortcode list item date format. Default `'M j'`.
| FICTIONEER_LATEST_UPDATES_FOOTER_DATE | string | Latest Updates shortcode footer date format. Default `"M j, 'y"`.
| FICTIONEER_LATEST_CHAPTERS_FOOTER_DATE | string | Latest Chapters shortcode footer date format. Default `"M j, 'y"`.

View File

@ -130,6 +130,11 @@ if ( ! defined( 'FICTIONEER_AGE_CONFIRMATION_REDIRECT' ) ) {
define( 'FICTIONEER_AGE_CONFIRMATION_REDIRECT', 'https://search.brave.com/' );
}
// String: Default chapter icon Font Awesome classes
if ( ! defined( 'FICTIONEER_DEFAULT_CHAPTER_ICON' ) ) {
define( 'FICTIONEER_DEFAULT_CHAPTER_ICON', 'fa-solid fa-book' );
}
/*
* Date Strings
*/

View File

@ -2570,7 +2570,7 @@ function fictioneer_render_chapter_meta_metabox( $post ) {
__( 'You can use all <em>free</em> <a href="%s" target="_blank">Font Awesome</a> icons.', 'fictioneer' ),
'https://fontawesome.com/search'
),
'placeholder' => 'fa-solid fa-book'
'placeholder' => FICTIONEER_DEFAULT_CHAPTER_ICON
)
);
}
@ -2970,11 +2970,11 @@ function fictioneer_save_chapter_metaboxes( $post_id ) {
// Valid?
if ( ! $icon_object && ( empty( $icon ) || strpos( $icon, 'fa-' ) !== 0 ) ) {
$icon = 'fa-solid fa-book';
$icon = FICTIONEER_DEFAULT_CHAPTER_ICON;
}
if ( $icon_object && ( ! property_exists( $icon_object, 'style' ) || ! property_exists( $icon_object, 'id' ) ) ) {
$icon = 'fa-solid fa-book';
$icon = FICTIONEER_DEFAULT_CHAPTER_ICON;
}
$fields['fictioneer_chapter_icon'] = $icon;

View File

@ -1086,7 +1086,7 @@ function fictioneer_shortcode_chapter_list( $attr ) {
if ( $text_icon ) {
$icon = "<span class='chapter-group__list-item-icon _text text-icon'>{$text_icon}</span>";
} else {
$icon = $icon ?: 'fa-solid fa-book';
$icon = $icon ?: FICTIONEER_DEFAULT_CHAPTER_ICON;
$icon = "<i class='{$icon} chapter-group__list-item-icon'></i>";
}

View File

@ -1085,11 +1085,11 @@ if ( ! function_exists( 'fictioneer_get_icon_field' ) ) {
// Valid?
if ( ! $icon_object && ( empty( $icon ) || strpos( $icon, 'fa-' ) !== 0 ) ) {
return 'fa-solid fa-book';
return FICTIONEER_DEFAULT_CHAPTER_ICON;
}
if ( $icon_object && ( ! property_exists( $icon_object, 'style' ) || ! property_exists( $icon_object, 'id' ) ) ) {
return 'fa-solid fa-book';
return FICTIONEER_DEFAULT_CHAPTER_ICON;
}
// Return

View File

@ -657,7 +657,7 @@ function fictioneer_story_chapters( $args ) {
if ( $chapter['text_icon'] ) {
$icon = "<span class='chapter-group__list-item-icon _text text-icon'>{$chapter['text_icon']}</span>";
} else {
$icon = $chapter['icon'] ?: 'fa-solid fa-book';
$icon = $chapter['icon'] ?: FICTIONEER_DEFAULT_CHAPTER_ICON;
$icon = "<i class='{$icon} chapter-group__list-item-icon'></i>";
}