Added Global announcement to all chapter. #14

Closed
Nabeelshar wants to merge 4 commits from main into main
3 changed files with 34 additions and 1 deletions

View File

@ -110,6 +110,29 @@ function fictioneer_chapter_foreword( $args ) {
}
add_action( 'fictioneer_chapter_before_header', 'fictioneer_chapter_foreword', 10 );
// =============================================================================
// CHAPTER Announcement
// =============================================================================
/**
* Outputs the HTML for the chapter announcement notice
*
* @since Fictioneer 5.8.5
*/
function fictioneer_chapter_announcement_notice() {
// Get notice
// Get notice
$g_notices = trim( get_option( 'fictioneer_chapter_announcement_notice' ) );
Tetrakern commented 2024-01-04 01:41:44 +08:00 (Migrated from github.com)
Review

This should be in its own action hooked into fictioneer_chapter_before_header, because it is a different concern. Also without the infobox--warning modifier, that makes everything red. I newly changed how the script to hide info boxes works, just add hideable as extra class so people can hide these things. These boxes are noise for most reader.

force_balance_tags() is a potentially expensive function and an admin should know what they are doing (otherwise they really shouldn't manage a website). See notes on the function. Reminds me that I wanted the remove the one instance where I used it and forgot (this has been amended now). Probably where you got that from.

Please also adhere to the coding and formatting style of the theme.

This should be in its own action hooked into `fictioneer_chapter_before_header`, because it is a different concern. Also without the `infobox--warning` modifier, that makes everything red. I newly changed how the script to hide info boxes works, just add `hideable` as extra class so people can hide these things. These boxes are noise for most reader. `force_balance_tags()` is a potentially expensive function and an admin should know what they are doing (otherwise they really shouldn't manage a website). See [notes](https://developer.wordpress.org/reference/functions/force_balance_tags/) on the function. Reminds me that I wanted the remove the one instance where I used it and forgot (this has been amended now). Probably where you got that from. Please also adhere to the coding and formatting style of the theme.
Nabeelshar commented 2024-01-04 02:20:24 +08:00 (Migrated from github.com)
Review

oh I should force_balance_tags was created by you. I got it from comments notice.
Will makes changes

oh I should force_balance_tags was created by you. I got it from comments notice. Will makes changes
// Show Notice
if ( ! empty( $g_notices ) ) { ?>
<div class="chapter__warning infobox polygon clearfix hideable">
<?php echo force_balance_tags( $g_notices ); ?>
</div>
<?php };
}
add_action( 'fictioneer_chapter_before_header', 'fictioneer_chapter_announcement_notice', 20 );
// =============================================================================
// CHAPTER WARNINGS
// =============================================================================

View File

@ -801,6 +801,14 @@ define( 'FICTIONEER_OPTIONS', array(
'label' => __( 'Notice above comments. Leave empty to hide. HTML allowed.', 'fictioneer' ),
'default' => '',
'placeholder' => ''
),
'fictioneer_chapter_announcement_notice' => array(
'name' => 'fictioneer_chapter_announcement_notice',
'group' => 'fictioneer-settings-general-group',
'sanitize_callback' => 'wp_kses_post',
'label' => __( 'Notice above chapters. Leave empty to hide. HTML allowed.', 'fictioneer' ),
'default' => '',
'placeholder' => ''
),
'fictioneer_discord_client_id' => array(
'name' => 'fictioneer_discord_client_id',

View File

@ -202,7 +202,9 @@
);
?>
</div>
<div class="fictioneer-card__row">
<?php fictioneer_settings_textarea( 'fictioneer_chapter_announcement_notice', '214px' ); ?>
</div>
<div class="fictioneer-card__row fictioneer-card__row--inline-input">
Tetrakern commented 2024-01-04 01:52:49 +08:00 (Migrated from github.com)
Review

Please put this as the last row and mind the formatting, spacing, and indentation.

Please put this as the last row and mind the formatting, spacing, and indentation.
Nabeelshar commented 2024-01-04 02:20:46 +08:00 (Migrated from github.com)
Review

Okay

Okay
<p class="fictioneer-inline-text-input"><?php
printf(