Rename function to fictioneer_get_story_chapter_ids

Because this is what it actually returns.
This commit is contained in:
Tetrakern 2024-01-26 00:24:31 +01:00
parent 588bdff89a
commit 3b67407678
10 changed files with 18 additions and 18 deletions

View File

@ -382,7 +382,7 @@ if ( ! function_exists( 'fictioneer_refresh_post_caches' ) ) {
$story_id = get_post_meta( $post_id, 'fictioneer_chapter_story', true );
if ( ! empty( $story_id ) ) {
$chapters = fictioneer_get_story_chapters( $story_id );
$chapters = fictioneer_get_story_chapter_ids( $story_id );
delete_post_meta( $story_id, 'fictioneer_story_data_collection' );
fictioneer_purge_post_cache( $story_id );
@ -398,7 +398,7 @@ if ( ! function_exists( 'fictioneer_refresh_post_caches' ) ) {
// Purge associated chapters
if ( $post_type == 'fcn_story' ) {
$chapters = fictioneer_get_story_chapters( $post_id );
$chapters = fictioneer_get_story_chapter_ids( $post_id );
if ( ! empty( $chapters ) ) {
foreach ( $chapters as $chapter_id ) {

View File

@ -1048,7 +1048,7 @@ function fictioneer_generate_epub() {
$story = get_post( $story_id );
$dir = get_template_directory() . '/epubs/';
$folder = "{$story_id}";
$chapters = fictioneer_get_story_chapters( $story_id );
$chapters = fictioneer_get_story_chapter_ids( $story_id );
$author = get_the_author_meta( 'display_name', $story->post_author );
$co_authors = get_post_meta( $story_id, 'fictioneer_story_co_authors', true ) ?: [];
$all_authors = [];

View File

@ -1898,7 +1898,7 @@ function fictioneer_render_story_data_metabox( $post ) {
);
// Chapters
$chapter_ids = fictioneer_get_story_chapters( $post->ID );
$chapter_ids = fictioneer_get_story_chapter_ids( $post->ID );
$chapters = empty( $chapter_ids ) ? [] : get_posts(
array(
@ -2213,7 +2213,7 @@ function fictioneer_save_story_metaboxes( $post_id ) {
// Chapters
if ( isset( $_POST['fictioneer_story_chapters'] ) && current_user_can( 'edit_fcn_stories', $post_id ) ) {
$previous_chapter_ids = fictioneer_get_story_chapters( $post_id );
$previous_chapter_ids = fictioneer_get_story_chapter_ids( $post_id );
$chapter_ids = $_POST['fictioneer_story_chapters'];
$chapter_ids = is_array( $chapter_ids ) ? $chapter_ids : [ $chapter_ids ];

View File

@ -295,7 +295,7 @@ function fictioneer_remove_chapter_from_story( $chapter_id ) {
}
// Check chapter list
$chapters = fictioneer_get_story_chapters( $story_id );
$chapters = fictioneer_get_story_chapter_ids( $story_id );
$previous = $chapters;
if ( empty( $chapters ) || ! in_array( $chapter_id, $chapters ) ) {

View File

@ -270,7 +270,7 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) {
}
// Setup
$chapters = fictioneer_get_story_chapters( $story_id );
$chapters = fictioneer_get_story_chapter_ids( $story_id );
$tags = get_the_tags( $story_id );
$fandoms = get_the_terms( $story_id, 'fcn_fandom' );
$characters = get_the_terms( $story_id, 'fcn_character' );
@ -791,19 +791,19 @@ if ( ! function_exists( 'fictioneer_is_editor' ) ) {
// GET META FIELDS
// =============================================================================
if ( ! function_exists( 'fictioneer_get_story_chapters' ) ) {
if ( ! function_exists( 'fictioneer_get_story_chapter_ids' ) ) {
/**
* Wrapper for get_post_meta() to get story chapters
* Wrapper for get_post_meta() to get story chapter IDs
*
* @since Fictioneer 5.8.2
*
* @param int $post_id Optional. The ID of the post the field belongs to.
* Defaults to current post ID.
*
* @return array Array of post IDs or an empty array.
* @return array Array of chapter post IDs or an empty array.
*/
function fictioneer_get_story_chapters( $post_id = null ) {
function fictioneer_get_story_chapter_ids( $post_id = null ) {
// Setup
$chapter_ids = get_post_meta( $post_id ?? get_the_ID(), 'fictioneer_story_chapters', true );
@ -1049,7 +1049,7 @@ function fictioneer_append_chapter_to_story( $post_id, $story_id, $force = false
}
// Get current story chapters
$story_chapters = fictioneer_get_story_chapters( $story_id );
$story_chapters = fictioneer_get_story_chapter_ids( $story_id );
// Append chapter (if not already included) and save to database
if ( ! in_array( $post_id, $story_chapters ) ) {

View File

@ -505,7 +505,7 @@ function fictioneer_story_chapters( $args ) {
// Start HTML ---> ?>
<section class="story__tab-target _current story__chapters" data-finder="chapters" data-order="asc" data-view="list">
<?php
$chapters = fictioneer_get_story_chapters( $story_id ); // Already prepared!
$chapters = fictioneer_get_story_chapter_ids( $story_id ); // Already prepared!
$chapter_groups = [];
$group_classes = [];

View File

@ -31,7 +31,7 @@ function fictioneer_refresh_story_schema( $post_id, $post ) {
fictioneer_build_story_schema( $post_id );
// Get chapters of story
$chapters = fictioneer_get_story_chapters( $post_id );
$chapters = fictioneer_get_story_chapter_ids( $post_id );
// Rebuild chapter schemas (if any)
if ( ! empty( $chapters ) ) {
@ -67,7 +67,7 @@ if ( ! function_exists( 'fictioneer_build_story_schema' ) ) {
$schema = fictioneer_get_schema_node_root();
$image_data = fictioneer_get_schema_primary_image( $post_id );
$rating = get_post_meta( $post_id, 'fictioneer_story_rating', true );
$chapters = fictioneer_get_story_chapters( $post_id );
$chapters = fictioneer_get_story_chapter_ids( $post_id );
$page_title = fictioneer_get_seo_title( $post_id, array( 'skip_cache' => true ) );
$default_description = fictioneer_first_paragraph_as_excerpt( fictioneer_get_content_field( 'fictioneer_story_short_description', $post_id ) );
$chapter_count = 0;

View File

@ -1327,7 +1327,7 @@ function fictioneer_tools_append_chapters() {
if ( ! empty( $chapter_ids_to_append ) ) {
// Prepare
$story_chapters = fictioneer_get_story_chapters( $story_id );
$story_chapters = fictioneer_get_story_chapter_ids( $story_id );
$count = 0;
// Append missing chapters

View File

@ -84,7 +84,7 @@ if ( ! empty( $items ) ) {
}
break;
case 'fcn_story':
$chapter_ids = fictioneer_get_story_chapters( $item->ID );
$chapter_ids = fictioneer_get_story_chapter_ids( $item->ID );
$word_count += fictioneer_get_word_count( $item->ID );
$story_count += 1;

View File

@ -25,7 +25,7 @@ if ( ! $story_id || $is_hidden || post_password_required( $story_id ) ) {
// Get story data
$story = fictioneer_get_story_data( $story_id, false ); // Does not refresh comment count!
$chapters = fictioneer_get_story_chapters( $story_id );
$chapters = fictioneer_get_story_chapter_ids( $story_id );
// Feed title
$title = sprintf(