Allow chapter navigation buttons to be rendered in other statuses #50
38
FILTERS.md
38
FILTERS.md
@ -258,9 +258,45 @@ Filters the intermediate output array of the chapter micro menu in the `fictione
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
### `apply_filters( 'fictioneer_filter_chapter_nav_buttons_allowed_statuses', $statuses, $post_id )`
|
### `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( $args, $location )` function. The default is `array('publish')`, but you could add `'private'` or `'future'` if you want to allow the navigation to render with these statuses.
|
Filters the array of allowed post statuses for the chapter navigation buttons in the `fictioneer_chapter_nav_buttons( $args, $location )` function. The default is `array('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_fictioneer_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 `array('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_fictioneer_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( $args )` function. The default is `array('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_fictioneer_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 `array('publish')`, but you could add `'private'` or `'future'` if you want to allow the buttons to render with these statuses.
|
||||||
|
|
||||||
**Parameters:**
|
**Parameters:**
|
||||||
* $statuses (array) – Array of allowed post statuses.
|
* $statuses (array) – Array of allowed post statuses.
|
||||||
* $post_id (int) – Current post ID.
|
* $post_id (int) – Current post ID.
|
||||||
|
@ -316,7 +316,7 @@ function fictioneer_chapter_nav_buttons( $args, $location ) {
|
|||||||
$unlisted = get_post_meta( $post_id, 'fictioneer_chapter_hidden', true );
|
$unlisted = get_post_meta( $post_id, 'fictioneer_chapter_hidden', true );
|
||||||
|
|
||||||
// Filter allowed status
|
// Filter allowed status
|
||||||
$allowed_statuses = apply_filters( 'fictioneer_filter_chapter_nav_buttons_allowed_statuses', array( 'publish' ), $post_id );
|
$allowed_statuses = apply_filters( 'fictioneer_filter_chapter_nav_buttons_allowed_statuses', array( 'publish' ), $post_id, $args, $location );
|
||||||
|
|
||||||
// Do not render on hidden posts
|
// Do not render on hidden posts
|
||||||
if ( ! in_array( $post_status, $allowed_statuses ) ) {
|
if ( ! in_array( $post_status, $allowed_statuses ) ) {
|
||||||
@ -374,8 +374,10 @@ function fictioneer_chapter_subscribe_button() {
|
|||||||
$subscribe_buttons = fictioneer_get_subscribe_options();
|
$subscribe_buttons = fictioneer_get_subscribe_options();
|
||||||
$post_status = get_post_status( get_the_ID() );
|
$post_status = get_post_status( get_the_ID() );
|
||||||
|
|
||||||
|
$allowed_statuses = apply_filters( 'fictioneer_filter_fictioneer_chapter_subscribe_button_statuses', array( 'publish' ), get_the_ID() );
|
||||||
|
|
||||||
// Do not render on hidden posts
|
// Do not render on hidden posts
|
||||||
if ( $post_status !== 'publish' ) {
|
if ( ! in_array( $post_status, $allowed_statuses ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,8 +433,10 @@ add_action( 'fictioneer_chapter_actions_top_center', 'fictioneer_chapter_fullscr
|
|||||||
function fictioneer_chapter_index_popup_menu( $args ) {
|
function fictioneer_chapter_index_popup_menu( $args ) {
|
||||||
$post_status = get_post_status( get_the_ID() );
|
$post_status = get_post_status( get_the_ID() );
|
||||||
|
|
||||||
|
$allowed_statuses = apply_filters( 'fictioneer_filter_fictioneer_chapter_index_popup_menu_statuses', array( 'publish' ), get_the_ID(), $args['story_post'] );
|
||||||
|
|
||||||
// Do not render on hidden posts
|
// Do not render on hidden posts
|
||||||
if ( $post_status !== 'publish' ) {
|
if ( ! in_array( $post_status, $allowed_statuses ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -499,8 +503,10 @@ add_action( 'fictioneer_chapter_actions_bottom_center', 'fictioneer_chapter_book
|
|||||||
function fictioneer_chapter_media_buttons() {
|
function fictioneer_chapter_media_buttons() {
|
||||||
$post_status = get_post_status( get_the_ID() );
|
$post_status = get_post_status( get_the_ID() );
|
||||||
|
|
||||||
|
$allowed_statuses = apply_filters( 'fictioneer_filter_fictioneer_chapter_media_buttons_statuses', array( 'publish' ), get_the_ID() );
|
||||||
|
|
||||||
// Do not render on hidden posts
|
// Do not render on hidden posts
|
||||||
if ( $post_status !== 'publish' ) {
|
if ( ! in_array( $post_status, $allowed_statuses ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user