Refactor style (among other things) #24

Merged
Tetrakern merged 94 commits from refactor_colors into main 2024-03-03 02:47:35 +08:00
6 changed files with 63 additions and 11 deletions
Showing only changes of commit ca89b7b7d1 - Show all commits

View File

@ -408,6 +408,7 @@ Fires between the top actions sections and chapter header (title and authors) in
* $next_index (int|boolean) Index of next chapter or false if outside bounds.
**Hooked actions:**
* `fictioneer_chapter_global_note( $args )` Story-wide note if provided. Priority 5.
* `fictioneer_chapter_foreword( $args )` Chapter foreword if provided. Priority 10.
* `fictioneer_chapter_warnings( $args )` Chapter warnings if provided. Priority 20.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1980,6 +1980,16 @@ function fictioneer_render_story_data_metabox( $post ) {
);
}
// Global note
$output['fictioneer_story_global_note'] = fictioneer_get_metabox_editor(
$post,
'fictioneer_story_global_note',
array(
'label' => _x( 'Global Note', 'Story global note meta field label.', 'fictioneer' ),
'description' => __( 'Displayed in a box above all chapters; include "[!password]" to hide in protected chapters. Limited HTML allowed.', 'fictioneer' )
)
);
// Password note
$output['fictioneer_story_password_note'] = fictioneer_get_metabox_editor(
$post,
@ -2314,6 +2324,12 @@ function fictioneer_save_story_metaboxes( $post_id ) {
}
}
// Global note
if ( isset( $_POST['fictioneer_story_global_note'] ) ) {
$fields['fictioneer_story_global_note'] =
fictioneer_sanitize_editor( $_POST['fictioneer_story_global_note'] );
}
// Password note
if ( isset( $_POST['fictioneer_story_password_note'] ) ) {
$fields['fictioneer_story_password_note'] =

View File

@ -83,6 +83,45 @@ function fictioneer_chapters_list( $args ) {
}
add_action( 'fictioneer_chapters_after_content', 'fictioneer_chapters_list', 30 );
// =============================================================================
// CHAPTER GLOBAL NOTE
// =============================================================================
/**
* Outputs the HTML for the chapter foreword section
*
* @since 5.11.1
*
* @param WP_Post|null $args['story_post'] The story post object.
*/
function fictioneer_chapter_global_note( $args ) {
// Guard
if ( ! ( $args['story_post'] ?? 0 ) ) {
return;
}
// Setup
$note = fictioneer_get_content_field( 'fictioneer_story_global_note', $args['story_post']->ID );
// Abort conditions
if (
empty( $note ) ||
( strpos( $note, '[!password]' ) !== false && post_password_required() )
) {
return;
}
$note = str_replace( '[!password]', '', $note );
// Start HTML ---> ?>
<section id="chapter-global-note" class="chapter__global-note infobox polygon clearfix chapter-note-hideable"><?php
echo trim( $note );
?></section>
<?php // <--- End HTML
}
add_action( 'fictioneer_chapter_before_header', 'fictioneer_chapter_global_note', 5 );
// =============================================================================
// CHAPTER FOREWORD
// =============================================================================
@ -101,7 +140,7 @@ function fictioneer_chapter_foreword( $args ) {
// Abort conditions
if ( empty( $foreword ) || post_password_required() ) {
return '';
return;
}
// Start HTML ---> ?>
@ -424,6 +463,7 @@ add_action( 'fictioneer_chapter_after_content', 'fictioneer_chapter_afterword',
* Outputs the HTML for the chapter support links
*
* @since 5.0.0
* @since 5.11.1
*
* @param WP_User $args['author'] Author of the post.
* @param WP_Post|null $args['story_post'] Optional. Post object of the story.
@ -432,10 +472,7 @@ add_action( 'fictioneer_chapter_after_content', 'fictioneer_chapter_afterword',
function fictioneer_chapter_support_links( $args ) {
// Abort conditions
if (
post_password_required() ||
get_post_meta( $args['chapter_id'], 'fictioneer_chapter_hide_support_links', true )
) {
if ( get_post_meta( $args['chapter_id'], 'fictioneer_chapter_hide_support_links', true ) ) {
return;
}

View File

@ -42,19 +42,17 @@
.main-navigation,
.navigation,
.header-background,
.chapter-note-hideable,
.chapter__actions,
.chapter__suggestion,
.chapter__foreword,
.chapter__afterword,
.chapter__warning,
.chapter__comments,
.chapter__support,
.wp-block-embed,
.wp-block-video,
.wp-block-audio,
.wp-block-file-wrapper,
.micro-menu,
.paragraph-tools,
.chapter__support,
.lightbox {
display: none !important;
content-visibility: hidden;