Customizable post status condition check when appending & indexed chapters #49
27
FILTERS.md
27
FILTERS.md
@ -53,6 +53,14 @@ Filters the data to be returned as JSON by the `fictioneer_ajax_get_user_data()`
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_allowed_chapter_permalinks', $statuses )`
|
||||
Filters the array of chapter statuses that control whether the chapter permalink is rendered in the `fictioneer_story_chapters()` function. By default, the statuses only include `['publish']`.
|
||||
|
||||
**Parameters:**
|
||||
* $statuses (array) – Array of chapter statuses.
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_allowed_orderby', $defaults )`
|
||||
Filters the array of allowed orderby arguments for WP_Query.
|
||||
|
||||
@ -70,6 +78,17 @@ Filters the array of allowed orderby arguments for WP_Query.
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_append_chapter_to_story_statuses', $statuses, $post_id, $story_id, $force )`
|
||||
Filters the array of chapter statuses that can be appended to a story’s `fictioneer_story_chapters` metadata in the `fictioneer_append_chapter_to_story()` function. By default, the statuses are `['publish']`.
|
||||
|
||||
**Parameters:**
|
||||
* $statuses (array) – Array of chapter statuses.
|
||||
* $post_id (int) – The chapter post ID.
|
||||
* $story_id (int) – The story post ID.
|
||||
* $force (boolean) – Whether to skip some guard clauses. Default false.
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_shortcode_article_card_footer', $footer_items, $posts )`
|
||||
Filters the intermediate output array in the `_article-cards.php` partial before it is imploded and rendered. Contains statistics with icons such as the author, publishing or modified date, and comments.
|
||||
|
||||
@ -301,6 +320,14 @@ Filters the array of support links returned for the current post (or post ID if
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_get_story_data_indexed_chapter_statuses', $statuses )`
|
||||
Filters the array of chapter statuses that can be appended to a story’s `indexed_chapter_ids` array in the `fictioneer_get_story_data()` function. By default, the statuses are `['publish']`.
|
||||
|
||||
**Parameters:**
|
||||
* $statuses (array) – Array of chapter statuses.
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_chapters_card_args', $card_args, $args )`
|
||||
Filters the arguments passed to the `partials/_card-chapter` template part in the `fictioneer_chapters_list( $args )` function, normally added via the `fictioneer_chapters_after_content` hook.
|
||||
|
||||
|
@ -394,6 +394,8 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) {
|
||||
$visible_chapter_ids = [];
|
||||
$indexed_chapter_ids = [];
|
||||
|
||||
$allowed_indexed_statuses = apply_filters( 'fictioneer_filter_get_story_data_indexed_chapter_statuses', ['publish'] );
|
||||
|
||||
// Assign correct icon
|
||||
if ( $status != 'Ongoing' ) {
|
||||
switch ( $status ) {
|
||||
@ -426,8 +428,8 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) {
|
||||
// ... but they are still listed!
|
||||
$visible_chapter_ids[] = $chapter->ID;
|
||||
|
||||
// Indexed chapters (accounts for custom filers)
|
||||
if ( $chapter->post_status === 'publish' ) {
|
||||
// Indexed chapters (accounts for custom filters)
|
||||
if ( in_array( $chapter->post_status, $allowed_indexed_statuses ) ) {
|
||||
$indexed_chapter_ids[] = $chapter->ID;
|
||||
}
|
||||
}
|
||||
@ -1396,8 +1398,16 @@ function fictioneer_get_falsy_meta_allow_list() {
|
||||
*/
|
||||
|
||||
function fictioneer_append_chapter_to_story( $post_id, $story_id, $force = false ) {
|
||||
// Abort if chapter is not published
|
||||
if ( get_post_status( $post_id ) !== 'publish' ) {
|
||||
$allowed_statuses = apply_filters(
|
||||
'fictioneer_filter_append_chapter_to_story_statuses',
|
||||
['publish'],
|
||||
$post_id,
|
||||
$story_id,
|
||||
$force
|
||||
);
|
||||
|
||||
// Abort if chapter status is not allowed
|
||||
if ( ! in_array( get_post_status( $post_id ), $allowed_statuses ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -527,7 +527,7 @@ function fictioneer_story_chapters( $args ) {
|
||||
$chapters = fictioneer_get_story_chapter_posts( $story_id );
|
||||
$chapter_groups = [];
|
||||
$group_classes = [];
|
||||
$allowed_permalinks = ['publish'];
|
||||
$allowed_permalinks = apply_filters( 'fictioneer_filter_allowed_chapter_permalinks', ['publish'] );
|
||||
|
||||
if ( $hide_icons ) {
|
||||
$group_classes[] = '_no-icons';
|
||||
|
Loading…
x
Reference in New Issue
Block a user