diff --git a/FILTERS.md b/FILTERS.md index 58c50c2f..b2b4d21f 100644 --- a/FILTERS.md +++ b/FILTERS.md @@ -807,6 +807,15 @@ Filters the form fields of the `fictioneer_contact_form` shortcode. --- +### `apply_filters( 'fictioneer_filter_co_authored_ids', $story_ids, $author_id )` +Filters the array of story IDs co-authored by the specified author ID, as queried and returned by the `fictioneer_sql_get_co_authored_story_ids()` function. These IDs are used to query selectable story chapters and validate permissions for chapter assignment and appending. + +**Parameters:** +* $story_ids (int[]) – Array of story IDs. +* $author_id (int) – Co-author ID. + +--- + ### `apply_filters( 'fictioneer_filter_customizer_{theme_option}', $choices )` Filters the choices arrays of select theme options. Combined with the `fictioneer_filter_pre_build_customize_css` filter, you can append own options and the requires styles. Available options: `header_image_style`, `header_style`, `page_style`, `story_cover_position`, `card_frame`, `card_image_style`, `card_style` (actually card footer), `card_shadow`, `content_list_style`, and `footer_style`. diff --git a/includes/functions/_helpers-query.php b/includes/functions/_helpers-query.php index 719c91e6..e8a51be6 100644 --- a/includes/functions/_helpers-query.php +++ b/includes/functions/_helpers-query.php @@ -710,7 +710,7 @@ if ( ! function_exists( 'fictioneer_sql_has_new_story_chapters' ) ) { } } -if ( ! function_exists( 'fictioneer_get_co_authored_story_ids' ) ) { +if ( ! function_exists( 'fictioneer_sql_get_co_authored_story_ids' ) ) { /** * Returns story IDs where the user is a co-author * @@ -723,7 +723,7 @@ if ( ! function_exists( 'fictioneer_get_co_authored_story_ids' ) ) { * @return int[] Array of story IDs. */ - function fictioneer_get_co_authored_story_ids( $author_id ) { + function fictioneer_sql_get_co_authored_story_ids( $author_id ) { static $cache = []; if ( isset( $cache[ $author_id ] ) ) { @@ -742,6 +742,8 @@ if ( ! function_exists( 'fictioneer_get_co_authored_story_ids' ) ) { ) ); + $story_ids = apply_filters( 'fictioneer_filter_co_authored_ids', $story_ids, $author_id ); + $cache[ $author_id ] = $story_ids; return $story_ids; @@ -784,7 +786,7 @@ if ( ! function_exists( 'fictioneer_sql_get_chapter_story_selection' ) ) { $sql .= " AND p.post_author = %d"; $values[] = $post_author_id; - $co_authored_stories = fictioneer_get_co_authored_story_ids( $post_author_id ); + $co_authored_stories = fictioneer_sql_get_co_authored_story_ids( $post_author_id ); if ( ! empty( $co_authored_stories ) ) { $placeholders = implode( ',', array_fill( 0, count( $co_authored_stories ), '%d' ) ); diff --git a/includes/functions/_setup-meta-fields.php b/includes/functions/_setup-meta-fields.php index a27d220c..034e381f 100644 --- a/includes/functions/_setup-meta-fields.php +++ b/includes/functions/_setup-meta-fields.php @@ -2951,7 +2951,7 @@ function fictioneer_save_chapter_metaboxes( $post_id ) { $invalid_story = false; if ( get_option( 'fictioneer_limit_chapter_stories_by_author' ) ) { - $co_authored_stories = fictioneer_get_co_authored_story_ids( $post_author_id ); + $co_authored_stories = fictioneer_sql_get_co_authored_story_ids( $post_author_id ); $invalid_story = $story_author_id != $post_author_id && ! in_array( $story_id, $co_authored_stories ); } diff --git a/includes/functions/_utility.php b/includes/functions/_utility.php index 19855550..a5d6e6eb 100644 --- a/includes/functions/_utility.php +++ b/includes/functions/_utility.php @@ -1590,7 +1590,7 @@ function fictioneer_append_chapter_to_story( $post_id, $story_id, $force = false // Setup, continued $chapter_author_id = get_post_field( 'post_author', $post_id ); $story_author_id = get_post_field( 'post_author', $story_id ); - $co_authored_story_ids = fictioneer_get_co_authored_story_ids( $chapter_author_id ); + $co_authored_story_ids = fictioneer_sql_get_co_authored_story_ids( $chapter_author_id ); // Abort if the author IDs do not match if (