Refactor also add other chapter actions
This commit is contained in:
parent
f1e3bbec1b
commit
e746df16ac
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.
|
||||
|
||||
**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:**
|
||||
* $statuses (array) – Array of allowed post statuses.
|
||||
* $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 );
|
||||
|
||||
// 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
|
||||
if ( ! in_array( $post_status, $allowed_statuses ) ) {
|
||||
@ -374,8 +374,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_fictioneer_chapter_subscribe_button_statuses', array( 'publish' ), get_the_ID() );
|
||||
|
||||
// Do not render on hidden posts
|
||||
if ( $post_status !== 'publish' ) {
|
||||
if ( ! in_array( $post_status, $allowed_statuses ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -431,8 +433,10 @@ 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_fictioneer_chapter_index_popup_menu_statuses', array( '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;
|
||||
}
|
||||
|
||||
@ -499,8 +503,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_fictioneer_chapter_media_buttons_statuses', array( '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