Allow chapter navigation buttons to be rendered in other statuses #50
53
FILTERS.md
53
FILTERS.md
@ -253,8 +253,53 @@ Filters the intermediate output array of the chapter micro menu in the `fictione
|
||||
* $chapter_password (string) – Chapter password or empty string.
|
||||
* $chapter_ids (array) – IDs of visible chapters in the same story or empty array.
|
||||
* $current_index (int) – Current index in the chapter list.
|
||||
* $prev_index (int|boolean) – Index of previous chapter or false.
|
||||
* $next_index (int|boolean) – Index of next chapter or false.
|
||||
* $prev_index (int|boolean) – Index of previous chapter or false if outside bounds.
|
||||
* $next_index (int|boolean) – Index of next chapter or false if outside bounds.
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_chapter_nav_buttons_allowed_statuses', $statuses, $post_id, $args, $location )`
|
||||
Filters the array of allowed post statuses for the chapter navigation buttons in the `fictioneer_chapter_nav_buttons()` function. The default is `['publish']`, but you could add `'private'` or `'future'` if you want to allow the navigation to render with these statuses.
|
||||
|
||||
**Parameters:**
|
||||
* $statuses (array) – Array of allowed post statuses.
|
||||
* $post_id (int) – Current post ID.
|
||||
* $args (array) – Arguments passed to the function.
|
||||
* $location (string) – Location of the navigation. Either `'top'` or `'bottom'`.
|
||||
|
||||
**$args:**
|
||||
* $chapter_ids (array) – IDs of visible chapters in the same story or empty array.
|
||||
* $indexed_chapter_ids (array) – IDs of accessible chapters in the same story or empty array.
|
||||
* $prev_index (int|boolean) – Index of previous chapter or false if outside bounds.
|
||||
* $next_index (int|boolean) – Index of next chapter or false if outside bounds.
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_chapter_subscribe_button_statuses', $statuses, $post_id )`
|
||||
Filters the array of allowed post statuses for the chapter subscribe button in the `fictioneer_chapter_subscribe_button()` function. The default is `['publish']`, but you could add `'private'` or `'future'` if you want to allow the button to render with these statuses.
|
||||
|
||||
**Parameters:**
|
||||
* $statuses (array) – Array of allowed post statuses.
|
||||
* $post_id (int) – Current post ID.
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_chapter_index_popup_menu_statuses', $statuses, $post_id, $story_id )`
|
||||
Filters the array of allowed post statuses for the chapter index popup menu in the `fictioneer_chapter_index_popup_menu()` function. The default is `['publish']`, but you could add `'private'` or `'future'` if you want to allow the menu to render with these statuses.
|
||||
|
||||
**Parameters:**
|
||||
* $statuses (array) – Array of allowed post statuses.
|
||||
* $post_id (int) – Current post ID.
|
||||
* $story_id (int) – Story ID of the chapter.
|
||||
|
||||
---
|
||||
|
||||
### `apply_filters( 'fictioneer_filter_chapter_media_buttons_statuses', $statuses, $post_id )`
|
||||
Filters the array of allowed post statuses for the chapter media buttons in the `fictioneer_chapter_media_buttons()` function. The default is `['publish']`, but you could add `'private'` or `'future'` if you want to allow the buttons to render with these statuses.
|
||||
|
||||
**Parameters:**
|
||||
* $statuses (array) – Array of allowed post statuses.
|
||||
* $post_id (int) – Current post ID.
|
||||
|
||||
---
|
||||
|
||||
@ -278,8 +323,8 @@ Filters the intermediate output array of the chapter support links in the `ficti
|
||||
* $chapter_password (string) – Chapter password or empty string.
|
||||
* $chapter_ids (array) – IDs of visible chapters in the same story or empty array.
|
||||
* $current_index (int) – Current index in the chapter list.
|
||||
* $prev_index (int|boolean) – Index of previous chapter or false.
|
||||
* $next_index (int|boolean) – Index of next chapter or false.
|
||||
* $prev_index (int|boolean) – Index of previous chapter or false if outside bounds.
|
||||
* $next_index (int|boolean) – Index of next chapter or false if outside bounds.
|
||||
|
||||
---
|
||||
|
||||
|
@ -315,8 +315,17 @@ function fictioneer_chapter_nav_buttons( $args, $location ) {
|
||||
$post_status = get_post_status( $post_id );
|
||||
$unlisted = get_post_meta( $post_id, 'fictioneer_chapter_hidden', true );
|
||||
|
||||
// Filter allowed status
|
||||
$allowed_statuses = apply_filters(
|
||||
'fictioneer_filter_chapter_nav_buttons_allowed_statuses',
|
||||
['publish'],
|
||||
$post_id,
|
||||
$args,
|
||||
$location
|
||||
);
|
||||
|
||||
// Do not render on hidden posts
|
||||
if ( $post_status !== 'publish' ) {
|
||||
if ( ! in_array( $post_status, $allowed_statuses ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -371,8 +380,10 @@ function fictioneer_chapter_subscribe_button() {
|
||||
$subscribe_buttons = fictioneer_get_subscribe_options();
|
||||
$post_status = get_post_status( get_the_ID() );
|
||||
|
||||
$allowed_statuses = apply_filters( 'fictioneer_filter_chapter_subscribe_button_statuses', ['publish'], get_the_ID() );
|
||||
|
||||
// Do not render on hidden posts
|
||||
if ( $post_status !== 'publish' ) {
|
||||
if ( ! in_array( $post_status, $allowed_statuses ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -428,8 +439,15 @@ add_action( 'fictioneer_chapter_actions_top_center', 'fictioneer_chapter_fullscr
|
||||
function fictioneer_chapter_index_popup_menu( $args ) {
|
||||
$post_status = get_post_status( get_the_ID() );
|
||||
|
||||
$allowed_statuses = apply_filters(
|
||||
'fictioneer_filter_chapter_index_popup_menu_statuses',
|
||||
['publish'],
|
||||
get_the_ID(),
|
||||
$args['story_post']
|
||||
);
|
||||
|
||||
// Do not render on hidden posts
|
||||
if ( $post_status !== 'publish' ) {
|
||||
if ( ! in_array( $post_status, $allowed_statuses ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -496,8 +514,10 @@ add_action( 'fictioneer_chapter_actions_bottom_center', 'fictioneer_chapter_book
|
||||
function fictioneer_chapter_media_buttons() {
|
||||
$post_status = get_post_status( get_the_ID() );
|
||||
|
||||
$allowed_statuses = apply_filters( 'fictioneer_filter_chapter_media_buttons_statuses', ['publish'], get_the_ID() );
|
||||
|
||||
// Do not render on hidden posts
|
||||
if ( $post_status !== 'publish' ) {
|
||||
if ( ! in_array( $post_status, $allowed_statuses ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user