From b65e8ccea12b238259887365994a37280c7821a4 Mon Sep 17 00:00:00 2001 From: Tetrakern <26898880+Tetrakern@users.noreply.github.com> Date: Thu, 30 Nov 2023 16:03:53 +0100 Subject: [PATCH] Replace fictioneer_get_field with get_post_meta This wrapper made sense at some point in the past, now it was just unnecessary overhead. --- header.php | 10 +-- includes/functions/_api.php | 26 ++++---- .../functions/_caching_and_transients.php | 12 ++-- includes/functions/_content_helpers.php | 60 ++++++++--------- includes/functions/_discord.php | 8 +-- includes/functions/_epub.php | 24 +++---- includes/functions/_meta_fields.php | 56 ++++++++-------- includes/functions/_post_updates.php | 14 ++-- includes/functions/_query_helpers.php | 12 ++-- includes/functions/_roles.php | 2 +- includes/functions/_schemas.php | 2 +- includes/functions/_seo.php | 32 ++++----- includes/functions/_shortcodes.php | 18 ++--- includes/functions/_sitemap.php | 6 +- includes/functions/_theme_setup.php | 2 +- includes/functions/_utility.php | 65 ++++++------------- includes/functions/_wordpress_mods.php | 4 +- includes/functions/hooks/_chapter_hooks.php | 12 ++-- includes/functions/hooks/_general_hooks.php | 10 +-- .../functions/hooks/_mobile_menu_hooks.php | 2 +- includes/functions/hooks/_post_hooks.php | 2 +- .../functions/hooks/_recommendation_hooks.php | 6 +- includes/functions/hooks/_story_hooks.php | 8 ++- .../functions/schemas/_chapter_schema.php | 8 +-- .../functions/schemas/_chapters_schema.php | 4 +- .../schemas/_recommendation_schema.php | 6 +- .../functions/schemas/_stories_schema.php | 3 +- includes/functions/schemas/_story_schema.php | 10 +-- .../settings/_settings_page_epubs.php | 2 +- .../functions/settings/_settings_page_seo.php | 6 +- includes/functions/users/_follows.php | 4 +- partials/_archive-loop.php | 4 +- partials/_article-cards.php | 6 +- partials/_card-chapter.php | 12 ++-- partials/_card-collection.php | 18 ++--- partials/_card-recommendation.php | 11 ++-- partials/_card-story.php | 10 +-- partials/_chapter-header.php | 2 +- partials/_collection-statistics.php | 6 +- partials/_latest-chapters-compact.php | 8 +-- partials/_latest-chapters.php | 10 +-- partials/_latest-recommendations-compact.php | 4 +- partials/_latest-recommendations.php | 8 +-- partials/_latest-stories-compact.php | 4 +- partials/_latest-stories.php | 4 +- partials/_latest-updates-compact.php | 10 +-- partials/_latest-updates.php | 10 +-- partials/_share-buttons.php | 4 +- partials/_showcase.php | 11 ++-- partials/_story-content.php | 34 +++++----- partials/_story-header.php | 12 +++- rss-rss-main.php | 4 +- rss-rss-story.php | 7 +- single-fcn_chapter.php | 9 ++- single-fcn_collection.php | 8 +-- single-fcn_story.php | 5 +- 56 files changed, 326 insertions(+), 331 deletions(-) diff --git a/header.php b/header.php index 3ee49b80..f997b4ab 100644 --- a/header.php +++ b/header.php @@ -80,16 +80,16 @@ if ( is_archive() || is_search() || is_404() ) { $story_id = $post_id; break; case 'fcn_chapter': - $story_id = fictioneer_get_field( 'fictioneer_chapter_story' ); + $story_id = get_post_meta( get_the_ID(), 'fictioneer_chapter_story', true ); break; } // Custom header image? - if ( fictioneer_get_field( 'fictioneer_custom_header_image', $post_id ) ) { - $header_image_url = fictioneer_get_field( 'fictioneer_custom_header_image', $post_id ); + if ( get_post_meta( $post_id, 'fictioneer_custom_header_image', true ) ) { + $header_image_url = get_post_meta( $post_id, 'fictioneer_custom_header_image', true ); $header_image_url = wp_get_attachment_image_url( $header_image_url, 'full' ); - } elseif ( ! empty( $story_id ) && fictioneer_get_field( 'fictioneer_custom_header_image', $story_id ) ) { - $header_image_url = fictioneer_get_field( 'fictioneer_custom_header_image', $story_id ); + } elseif ( ! empty( $story_id ) && get_post_meta( $story_id, 'fictioneer_custom_header_image', true ) ) { + $header_image_url = get_post_meta( $story_id, 'fictioneer_custom_header_image', true ); $header_image_url = wp_get_attachment_image_url( $header_image_url, 'full' ); } } diff --git a/includes/functions/_api.php b/includes/functions/_api.php index f2d1a8f4..7d0f6d09 100644 --- a/includes/functions/_api.php +++ b/includes/functions/_api.php @@ -28,8 +28,8 @@ if ( ! function_exists( 'fictioneer_api_get_story_node' ) ) { // Setup $author_id = get_post_field( 'post_author', $story_id ); $author_url = get_the_author_meta( 'user_url', $author_id ); - $co_author_ids = fictioneer_get_field( 'fictioneer_story_co_authors', $story_id ); - $language = fictioneer_get_field( 'fictioneer_story_language', $story_id ); + $co_author_ids = get_post_meta( $story_id, 'fictioneer_story_co_authors', true ); + $language = get_post_meta( $story_id, 'fictioneer_story_language', true ); $node = []; // Identity @@ -77,7 +77,7 @@ if ( ! function_exists( 'fictioneer_api_get_story_node' ) ) { // Content $content = get_the_content( null, false, $story_id ); - $description = fictioneer_get_field( 'fictioneer_story_short_description', $story_id ); + $description = get_post_meta( $story_id, 'fictioneer_story_short_description', true ); $node['content'] = $content; $node['description'] = strip_shortcodes( $description ); @@ -96,7 +96,7 @@ if ( ! function_exists( 'fictioneer_api_get_story_node' ) ) { 'hotlinkAllowed' => FICTIONEER_API_STORYGRAPH_HOTLINK, ); $cover = get_the_post_thumbnail_url( $story_id, 'full' ); - $header = fictioneer_get_field( 'fictioneer_custom_header_image', $story_id ); + $header = get_post_meta( $story_id, 'fictioneer_custom_header_image', true ); $header = wp_get_attachment_image_url( $header, 'full' ); if ( ! empty( $header ) ) { @@ -148,20 +148,20 @@ if ( ! function_exists( 'fictioneer_api_get_story_node' ) ) { $chapter_id = get_the_ID(); // Skip not visible chapters - if ( fictioneer_get_field( 'fictioneer_chapter_hidden' ) ) { + if ( get_post_meta( $chapter_id, 'fictioneer_chapter_hidden', true ) ) { continue; } // Data $author_id = get_the_author_meta( 'id' ); $author_url = get_the_author_meta( 'user_url' ); - $co_author_ids = fictioneer_get_field( 'fictioneer_chapter_co_authors', $chapter_id ); - $group = fictioneer_get_field( 'fictioneer_chapter_group', $chapter_id ); - $rating = fictioneer_get_field( 'fictioneer_chapter_rating', $chapter_id ); - $language = fictioneer_get_field( 'fictioneer_chapter_language', $chapter_id ); - $prefix = fictioneer_get_field( 'fictioneer_chapter_prefix', $chapter_id ); - $no_chapter = fictioneer_get_field( 'fictioneer_chapter_no_chapter', $chapter_id ); - $warning = fictioneer_get_field( 'fictioneer_chapter_warning', $chapter_id ); + $co_author_ids = get_post_meta( $chapter_id, 'fictioneer_chapter_co_authors', true ); + $group = get_post_meta( $chapter_id, 'fictioneer_chapter_group', true ); + $rating = get_post_meta( $chapter_id, 'fictioneer_chapter_rating', true ); + $language = get_post_meta( $chapter_id, 'fictioneer_chapter_language', true ); + $prefix = get_post_meta( $chapter_id, 'fictioneer_chapter_prefix', true ); + $no_chapter = get_post_meta( $chapter_id, 'fictioneer_chapter_no_chapter', true ); + $warning = get_post_meta( $chapter_id, 'fictioneer_chapter_warning', true ); // Chapter identity $chapter = []; @@ -220,7 +220,7 @@ if ( ! function_exists( 'fictioneer_api_get_story_node' ) ) { $chapter['published'] = get_post_time( 'U', true ); $chapter['modified'] = get_post_modified_time( 'U', true ); $chapter['protected'] = post_password_required(); - $chapter['words'] = intval( fictioneer_get_field( '_word_count', $chapter_id ) ); + $chapter['words'] = intval( get_post_meta( $chapter_id, '_word_count', true ) ); $chapter['nonChapter'] = ! empty( $no_chapter ); if ( ! empty( $rating ) ) { diff --git a/includes/functions/_caching_and_transients.php b/includes/functions/_caching_and_transients.php index dc66ddd9..4b071443 100644 --- a/includes/functions/_caching_and_transients.php +++ b/includes/functions/_caching_and_transients.php @@ -379,16 +379,16 @@ if ( ! function_exists( 'fictioneer_refresh_post_caches' ) ) { // Purge parent story (if any)... if ( $post_type == 'fcn_chapter' ) { - $story_id = fictioneer_get_field( 'fictioneer_chapter_story', $post_id ); + $story_id = get_post_meta( $post_id, 'fictioneer_chapter_story', true ); if ( ! empty( $story_id ) ) { - $chapters = fictioneer_get_field( 'fictioneer_story_chapters', $story_id ); + $chapters = get_post_meta( $story_id, 'fictioneer_story_chapters', true ); delete_post_meta( $story_id, 'fictioneer_story_data_collection' ); fictioneer_purge_post_cache( $story_id ); // ... and associated chapters - if ( ! empty( $chapters ) ) { + if ( is_array( $chapters ) && ! empty( $chapters ) ) { foreach ( $chapters as $chapter_id ) { fictioneer_purge_post_cache( $chapter_id ); } @@ -398,9 +398,9 @@ if ( ! function_exists( 'fictioneer_refresh_post_caches' ) ) { // Purge associated chapters if ( $post_type == 'fcn_story' ) { - $chapters = fictioneer_get_field( 'fictioneer_story_chapters', $post_id ); + $chapters = get_post_meta( $post_id, 'fictioneer_story_chapters', true ); - if ( ! empty( $chapters ) ) { + if ( is_array( $chapters ) && ! empty( $chapters ) ) { foreach ( $chapters as $chapter_id ) { fictioneer_purge_post_cache( $chapter_id ); } @@ -618,7 +618,7 @@ if ( ! function_exists( 'fictioneer_track_chapter_and_story_updates' ) ) { // Get story ID from post or parent story (if any) $post_type = get_post_type( $post_id ); // Not all hooks get the $post object! - $story_id = $post_type == 'fcn_story' ? $post_id : fictioneer_get_field( 'fictioneer_chapter_story', $post_id ); + $story_id = $post_type == 'fcn_story' ? $post_id : get_post_meta( $post_id, 'fictioneer_chapter_story', true ); // If there is a story... if ( ! empty( $story_id ) ) { diff --git a/includes/functions/_content_helpers.php b/includes/functions/_content_helpers.php index 6d4bffb1..8d0bf975 100644 --- a/includes/functions/_content_helpers.php +++ b/includes/functions/_content_helpers.php @@ -630,19 +630,19 @@ if ( ! function_exists( 'fictioneer_get_subscribe_options' ) ) { function fictioneer_get_subscribe_options( $post_id = null, $author_id = null, $feed = null ) { // Setup $post_id = $post_id ? $post_id : get_the_ID(); - $story_id = fictioneer_get_field( 'fictioneer_chapter_story', $post_id ); + $story_id = get_post_meta( $post_id, 'fictioneer_chapter_story', true ); $author_id = $author_id ? $author_id : get_the_author_meta( 'ID' ); - $patreon_link = fictioneer_get_field( 'fictioneer_patreon_link', $post_id ); - $kofi_link = fictioneer_get_field( 'fictioneer_kofi_link', $post_id ); - $subscribestar_link = fictioneer_get_field( 'fictioneer_subscribestar_link', $post_id ); + $patreon_link = get_post_meta( $post_id, 'fictioneer_patreon_link', true ); + $kofi_link = get_post_meta( $post_id, 'fictioneer_kofi_link', true ); + $subscribestar_link = get_post_meta( $post_id, 'fictioneer_subscribestar_link', true ); $output = []; $feed = get_option( 'fictioneer_enable_theme_rss' ) ? $feed: null; // Look for story support links if none provided by post if ( ! empty( $story_id ) ) { - if ( empty( $patreon_link ) ) $patreon_link = fictioneer_get_field( 'fictioneer_patreon_link', $story_id ); - if ( empty( $kofi_link ) ) $kofi_link = fictioneer_get_field( 'fictioneer_kofi_link', $story_id ); - if ( empty( $subscribestar_link ) ) $subscribestar_link = fictioneer_get_field( 'fictioneer_subscribestar_link', $story_id ); + if ( empty( $patreon_link ) ) $patreon_link = get_post_meta( $story_id, 'fictioneer_patreon_link', true ); + if ( empty( $kofi_link ) ) $kofi_link = get_post_meta( $story_id, 'fictioneer_kofi_link', true ); + if ( empty( $subscribestar_link ) ) $subscribestar_link = get_post_meta( $story_id, 'fictioneer_subscribestar_link', true ); } // Look for author support links if none provided by post or story @@ -732,12 +732,12 @@ if ( ! function_exists( 'fictioneer_get_story_buttons' ) ) { // Setup $story_data = $args['story_data']; $story_id = $args['story_id']; - $ebook_upload = fictioneer_get_field( 'fictioneer_story_ebook_upload_one', $story_id ); // Attachment ID + $ebook_upload = get_post_meta( $story_id, 'fictioneer_story_ebook_upload_one', true ); // Attachment ID $subscribe_buttons = fictioneer_get_subscribe_options(); $output = []; // Flags - $show_epub_download = $story_data['chapter_count'] > 0 && fictioneer_get_field( 'fictioneer_story_epub_preface', $story_id ) && get_option( 'fictioneer_enable_epubs' ) && ! fictioneer_get_field( 'fictioneer_story_no_epub', $story_id ); + $show_epub_download = $story_data['chapter_count'] > 0 && get_post_meta( $story_id, 'fictioneer_story_epub_preface', true ) && get_option( 'fictioneer_enable_epubs' ) && ! get_post_meta( $story_id, 'fictioneer_story_no_epub', true ); $can_follows = get_option( 'fictioneer_enable_follows' ); $can_reminders = get_option( 'fictioneer_enable_reminders' ); $show_login = get_option( 'fictioneer_enable_oauth' ) && ! is_user_logged_in(); @@ -833,7 +833,7 @@ if ( ! function_exists( 'fictioneer_get_chapter_author_nodes' ) ) { function fictioneer_get_chapter_author_nodes( $chapter_id ) { // Setup - $all_authors = fictioneer_get_field( 'fictioneer_chapter_co_authors', $chapter_id ) ?? []; + $all_authors = get_post_meta( $chapter_id, 'fictioneer_chapter_co_authors', true ) ?? []; $all_authors = is_array( $all_authors ) ? $all_authors : []; array_unshift( $all_authors, get_post_field( 'post_author', $chapter_id ) ); @@ -968,7 +968,7 @@ if ( ! function_exists( 'fictioneer_get_chapter_list_items' ) ) { function fictioneer_get_chapter_list_items( $story_id, $data, $current_index ) { // Setup - $hide_icons = fictioneer_get_field( 'fictioneer_story_hide_chapter_icons', $story_id ) || get_option( 'fictioneer_hide_chapter_icons' ); + $hide_icons = get_post_meta( $story_id, 'fictioneer_story_hide_chapter_icons', true ) || get_option( 'fictioneer_hide_chapter_icons' ); $query_args = array( 'post__in' => fictioneer_rescue_array_zero( $data['chapter_ids'] ), // Only visible and published @@ -989,9 +989,9 @@ if ( ! function_exists( 'fictioneer_get_chapter_list_items' ) ) { // Prepare $classes = []; $title = trim( $post->post_title ); - $list_title = fictioneer_get_field( 'fictioneer_chapter_list_title', $post->ID ); + $list_title = get_post_meta( $post->ID, 'fictioneer_chapter_list_title', true ); $list_title = trim( wp_strip_all_tags( $list_title ) ); - $text_icon = fictioneer_get_field( 'fictioneer_chapter_text_icon', $post->ID ); + $text_icon = get_post_meta( $post->ID, 'fictioneer_chapter_text_icon', true ); $parsed_url = wp_parse_url( home_url() ); $relative_path = isset( $parsed_url['path'] ) ? $parsed_url['path'] : ''; @@ -1147,7 +1147,7 @@ if ( ! function_exists( 'fictioneer_get_rss_link' ) ) { $feed = esc_url( add_query_arg( 'story_id', $post_id, home_url( 'feed/rss-chapters' ) ) ); break; case 'fcn_chapter': - $story_id = fictioneer_get_field( 'fictioneer_chapter_story', $post_id ); + $story_id = get_post_meta( $post_id, 'fictioneer_chapter_story', true ); if ( $story_id ) { $feed = esc_url( add_query_arg( 'story_id', $story_id, home_url( 'feed/rss-chapters' ) ) ); }; @@ -1513,8 +1513,8 @@ if ( ! function_exists( 'fictioneer_echo_card' ) ) { switch ( $type ) { case 'fcn_chapter': if ( - fictioneer_get_field( 'fictioneer_chapter_hidden', get_the_ID() ) || - fictioneer_get_field( 'fictioneer_chapter_no_chapter', get_the_ID() ) + get_post_meta( get_the_ID(), 'fictioneer_chapter_hidden', true ) || + get_post_meta( get_the_ID(), 'fictioneer_chapter_no_chapter', true ) ) { get_template_part( 'partials/_card-hidden', null, $args ); } else { @@ -1522,7 +1522,7 @@ if ( ! function_exists( 'fictioneer_echo_card' ) ) { } break; case 'fcn_story': - if ( fictioneer_get_field( 'fictioneer_story_hidden', get_the_ID() ) ) { + if ( get_post_meta( get_the_ID(), 'fictioneer_story_hidden', true ) ) { get_template_part( 'partials/_card-hidden', null, $args ); } else { get_template_part( 'partials/_card-story', null, $args ); @@ -1571,36 +1571,36 @@ if ( ! function_exists( 'fictioneer_get_support_links' ) ) { // Get story ID if chapter and parent ID not given if ( $parent_id === null && get_post_type( $post_id ) == 'fcn_chapter' ) { - $parent_id = fictioneer_get_field( 'fictioneer_chapter_story', $post_id ); + $parent_id = get_post_meta( $post_id, 'fictioneer_chapter_story', true ); } // Post level (e.g. chapter) - $links['topwebfiction'] = fictioneer_get_field( 'fictioneer_story_topwebfiction_link', $post_id ); - $links['patreon'] = fictioneer_get_field( 'fictioneer_patreon_link', $post_id ); - $links['kofi'] = fictioneer_get_field( 'fictioneer_kofi_link', $post_id ); - $links['subscribestar'] = fictioneer_get_field( 'fictioneer_subscribestar_link', $post_id ); - $links['paypal'] = fictioneer_get_field( 'fictioneer_paypal_link', $post_id ); - $links['donation'] = fictioneer_get_field( 'fictioneer_donation_link', $post_id ); + $links['topwebfiction'] = get_post_meta( $post_id, 'fictioneer_story_topwebfiction_link', true ); + $links['patreon'] = get_post_meta( $post_id, 'fictioneer_patreon_link', true ); + $links['kofi'] = get_post_meta( $post_id, 'fictioneer_kofi_link', true ); + $links['subscribestar'] = get_post_meta( $post_id, 'fictioneer_subscribestar_link', true ); + $links['paypal'] = get_post_meta( $post_id, 'fictioneer_paypal_link', true ); + $links['donation'] = get_post_meta( $post_id, 'fictioneer_donation_link', true ); // Parent level (e.g. story) if ( ! empty( $parent_id ) ) { if ( empty( $links['topwebfiction'] ) ) { - $links['topwebfiction'] = fictioneer_get_field( 'fictioneer_story_topwebfiction_link', $parent_id ); + $links['topwebfiction'] = get_post_meta( $parent_id, 'fictioneer_story_topwebfiction_link', true ); } if ( empty( $links['patreon'] ) ) { - $links['patreon'] = fictioneer_get_field( 'fictioneer_patreon_link', $parent_id ); + $links['patreon'] = get_post_meta( $parent_id, 'fictioneer_patreon_link', true ); } if ( empty( $links['kofi'] ) ) { - $links['kofi'] = fictioneer_get_field( 'fictioneer_kofi_link', $parent_id ); + $links['kofi'] = get_post_meta( $parent_id, 'fictioneer_kofi_link', true ); } if ( empty( $links['subscribestar'] ) ) { - $links['subscribestar'] = fictioneer_get_field( 'fictioneer_subscribestar_link', $parent_id ); + $links['subscribestar'] = get_post_meta( $parent_id, 'fictioneer_subscribestar_link', true ); } if ( empty( $links['paypal'] ) ) { - $links['paypal'] = fictioneer_get_field( 'fictioneer_paypal_link', $parent_id ); + $links['paypal'] = get_post_meta( $parent_id, 'fictioneer_paypal_link', true ); } if ( empty( $links['donation'] ) ) { - $links['donation'] = fictioneer_get_field( 'fictioneer_donation_link', $parent_id ); + $links['donation'] = get_post_meta( $parent_id, 'fictioneer_donation_link', true ); } } diff --git a/includes/functions/_discord.php b/includes/functions/_discord.php index 99cf4960..77e3a179 100644 --- a/includes/functions/_discord.php +++ b/includes/functions/_discord.php @@ -106,7 +106,7 @@ function fictioneer_post_comment_to_discord( $comment_id, $comment_approved ) { } // Is chapter with story? - $story_id = fictioneer_get_field( 'fictioneer_chapter_story', $post->ID ); + $story_id = get_post_meta( $post->ID, 'fictioneer_chapter_story', true ); if ( $story_id ) { $message['embeds'][0]['footer'] = array( @@ -198,7 +198,7 @@ function fictioneer_post_story_to_discord( $post_id ) { } // Already triggered once? - if ( ! empty( fictioneer_get_field( 'fictioneer_discord_post_trigger', $post_id ) ) ) { + if ( ! empty( get_post_meta( $post_id, 'fictioneer_discord_post_trigger', true ) ) ) { return; } @@ -286,12 +286,12 @@ function fictioneer_post_chapter_to_discord( $post_id ) { } // Already triggered once? - if ( ! empty( fictioneer_get_field( 'fictioneer_discord_post_trigger', $post_id ) ) ) { + if ( ! empty( get_post_meta( $post_id, 'fictioneer_discord_post_trigger', true ) ) ) { return; } // Story? - $story_id = fictioneer_get_field( 'fictioneer_chapter_story', $post_id ); + $story_id = get_post_meta( $post_id, 'fictioneer_chapter_story', true ); $story_status = get_post_status( $story_id ); $story_title = get_the_title( $story_id ); $story_url = get_permalink( $story_id ); diff --git a/includes/functions/_epub.php b/includes/functions/_epub.php index f52c1eac..67a601a2 100644 --- a/includes/functions/_epub.php +++ b/includes/functions/_epub.php @@ -47,11 +47,11 @@ if ( ! function_exists( 'fictioneer_download_epub' ) ) { // Count downloads per ePUB version if ( $story_id ) { // Download counter(s) - $downloads = fictioneer_get_field( 'fictioneer_epub_downloads', $story_id ); + $downloads = get_post_meta( $story_id, 'fictioneer_epub_downloads', true ); $downloads = is_array( $downloads ) ? $downloads : []; // Generate version key based on timestamp - $key = md5( fictioneer_get_field( 'fictioneer_epub_timestamp', $story_id ) ); + $key = md5( get_post_meta( $story_id, 'fictioneer_epub_timestamp', true ) ); // Is this version already tracked? $downloads[ $key ] = ( $downloads[ $key ] ?? 0 ) + 1; @@ -240,7 +240,7 @@ if ( ! function_exists( 'fictioneer_prepare_build_directory' ) ) { // Copy/Edit CSS file $css_path = $epub_dir . '/OEBPS/Styles/style.css'; - $css_edit = fictioneer_get_field( 'fictioneer_story_epub_custom_css', $story_id, false ); + $css_edit = get_post_meta( $story_id, 'fictioneer_story_epub_custom_css', true ); copy( $dir . '_build/templates/style.css', $css_path ); @@ -367,14 +367,14 @@ if ( ! function_exists( 'fictioneer_add_epub_chapters' ) ) { // Process chapters foreach ( $chapter_query->posts as $post ) { // Skip if... - if ( fictioneer_get_field( 'fictioneer_chapter_no_chapter', $post->ID ) ) { + if ( get_post_meta( $post->ID, 'fictioneer_chapter_no_chapter', true ) ) { continue; } // Setup $title = fictioneer_get_safe_title( $post->ID ); $content = apply_filters( 'the_content', $post->post_content ); - $is_hidden = fictioneer_get_field( 'fictioneer_chapter_hidden', $post->ID ); + $is_hidden = get_post_meta( $post->ID, 'fictioneer_chapter_hidden', true ); $processed = false; $index++; @@ -419,7 +419,7 @@ if ( ! function_exists( 'fictioneer_add_epub_chapters' ) ) { $head->appendChild( $doc->createElement( 'title', $title ) ); // Add title to frame if not hidden - if ( ! fictioneer_get_field( 'fictioneer_chapter_hide_title' ) ) { + if ( ! get_post_meta( $post->ID, 'fictioneer_chapter_hide_title', true ) ) { $frame->appendChild( $doc->createElement( 'h1', $title ) ); } @@ -697,7 +697,7 @@ if ( ! function_exists( 'fictioneer_generate_epub_opf' ) ) { } // Afterword node - if ( fictioneer_get_field( 'fictioneer_story_epub_afterword', $story_id, false ) ) { + if ( get_post_meta( $story_id, 'fictioneer_story_epub_afterword', true ) ) { $m_item = $opf->createElement( 'item' ); $m_item->setAttribute( 'href', 'Text/afterword.html' ); $m_item->setAttribute( 'id', 'afterword' ); @@ -775,7 +775,7 @@ if ( ! function_exists( 'fictioneer_generate_epub_ncx' ) ) { } // Add afterword node - if ( fictioneer_get_field( 'fictioneer_story_epub_afterword', $story_id, false ) ) { + if ( get_post_meta( $story_id, 'fictioneer_story_epub_afterword', true ) ) { $navmap->appendChild( fictioneer_nav_point( $ncx, $index, 'Text/afterword.html', __( 'Afterword', 'fictioneer' ) ) ); $index++; } @@ -1012,7 +1012,7 @@ function fictioneer_generate_epub() { if ( empty( $story_id ) || ! get_option( 'fictioneer_enable_epubs' ) || - fictioneer_get_field( 'fictioneer_story_no_epub', $story_id ) + get_post_meta( $story_id, 'fictioneer_story_no_epub', true ) ) { fictioneer_epub_return_and_exit(); } @@ -1036,14 +1036,14 @@ function fictioneer_generate_epub() { $story = get_post( $story_id ); $dir = get_template_directory() . '/epubs/'; $folder = "{$story_id}"; - $chapters = fictioneer_get_field( 'fictioneer_story_chapters', $story_id ); + $chapters = get_post_meta( $story_id, 'fictioneer_story_chapters', true ) ?: []; $author = get_the_author_meta( 'display_name', $story->post_author ); - $co_authors = fictioneer_get_field( 'fictioneer_story_co_authors', $story_id ) ?? []; + $co_authors = get_post_meta( $story_id, 'fictioneer_story_co_authors', true ) ?: []; $all_authors = []; $short_description = mb_convert_encoding( fictioneer_get_content_field( 'fictioneer_story_short_description', $story_id, false ), 'HTML-ENTITIES', 'UTF-8' ); $short_description = fictioneer_fix_html_entities( $short_description ); $story_last_modified = get_the_modified_date( 'Y-m-d H:i:s', $story_id ); - $epub_last_built = fictioneer_get_field( 'fictioneer_epub_timestamp', $story_id ); + $epub_last_built = get_post_meta( $story_id, 'fictioneer_epub_timestamp', true ); $toc_list = []; $ncx_list = []; $opf_list = []; diff --git a/includes/functions/_meta_fields.php b/includes/functions/_meta_fields.php index e544402e..a445f351 100644 --- a/includes/functions/_meta_fields.php +++ b/includes/functions/_meta_fields.php @@ -54,7 +54,7 @@ function fictioneer_get_metabox_checkbox( $post, $meta_key, $label, $args = [] )
- ID ), 1 ); ?> > + ID, $meta_key, true ), 1 ); ?> >
@@ -87,7 +87,7 @@ function fictioneer_get_metabox_checkbox( $post, $meta_key, $label, $args = [] ) function fictioneer_get_metabox_text( $post, $meta_key, $args = [] ) { // Setup - $meta_value = esc_attr( fictioneer_get_field( $meta_key, $post->ID ) ); + $meta_value = esc_attr( get_post_meta( $post->ID, $meta_key, true ) ); $label = strval( $args['label'] ?? '' ); $description = strval( $args['description'] ?? '' ); $placeholder = strval( $args['placeholder'] ?? '' ); @@ -142,7 +142,7 @@ function fictioneer_get_metabox_text( $post, $meta_key, $args = [] ) { function fictioneer_get_metabox_url( $post, $meta_key, $args = [] ) { // Setup - $meta_value = esc_attr( fictioneer_get_field( $meta_key, $post->ID ) ); + $meta_value = esc_attr( get_post_meta( $post->ID, $meta_key, true ) ); $label = strval( $args['label'] ?? '' ); $description = strval( $args['description'] ?? '' ); $placeholder = strval( $args['placeholder'] ?? '' ); @@ -197,7 +197,7 @@ function fictioneer_get_metabox_url( $post, $meta_key, $args = [] ) { function fictioneer_get_metabox_array( $post, $meta_key, $args = [] ) { // Setup - $array = fictioneer_get_field( $meta_key, $post->ID ); + $array = get_post_meta( $post->ID, $meta_key, true ); $array = is_array( $array ) ? $array : []; $list = esc_attr( implode( ', ', $array ) ); $label = strval( $args['label'] ?? '' ); @@ -251,7 +251,7 @@ function fictioneer_get_metabox_array( $post, $meta_key, $args = [] ) { function fictioneer_get_metabox_select( $post, $meta_key, $options, $args = [] ) { // Setup - $selected = absint( fictioneer_get_field( $meta_key, $post->ID ) ); + $selected = absint( get_post_meta( $post->ID, $meta_key, true ) ); $selected = empty( $selected ) ? array_keys( $options )[0] : $selected; $label = strval( $args['label'] ?? '' ); $description = strval( $args['description'] ?? '' ); @@ -312,7 +312,7 @@ function fictioneer_get_metabox_select( $post, $meta_key, $options, $args = [] ) function fictioneer_get_metabox_textarea( $post, $meta_key, $args = [] ) { // Setup - $meta_value = fictioneer_get_field( $meta_key, $post->ID ); + $meta_value = get_post_meta( $post->ID, $meta_key, true ); $label = strval( $args['label'] ?? '' ); $description = strval( $args['description'] ?? '' ); $placeholder = strval( $args['placeholder'] ?? '' ); @@ -366,7 +366,7 @@ function fictioneer_get_metabox_textarea( $post, $meta_key, $args = [] ) { function fictioneer_get_metabox_image( $post, $meta_key, $args = [] ) { // Setup - $meta_value = fictioneer_get_field( $meta_key, $post->ID ); + $meta_value = get_post_meta( $post->ID, $meta_key, true ); $label = strval( $args['label'] ?? '' ); $description = strval( $args['description'] ?? '' ); $upload = strval( $args['button'] ?? _x( 'Set image', 'Metabox image upload button.', 'fictioneer' ) ); @@ -425,7 +425,7 @@ function fictioneer_get_metabox_image( $post, $meta_key, $args = [] ) { function fictioneer_get_metabox_ebook( $post, $meta_key, $args = [] ) { // Setup - $meta_value = fictioneer_get_field( $meta_key, $post->ID ); + $meta_value = get_post_meta( $post->ID, $meta_key, true ); $file_path = get_attached_file( $meta_value ); $label = strval( $args['label'] ?? '' ); $description = strval( $args['description'] ?? '' ); @@ -523,7 +523,7 @@ function fictioneer_get_metabox_ebook( $post, $meta_key, $args = [] ) { function fictioneer_get_metabox_tokens( $post, $meta_key, $options, $args = [] ) { // Setup - $array = fictioneer_get_field( $meta_key, $post->ID ); + $array = get_post_meta( $post->ID, $meta_key, true ); $array = is_array( $array ) ? $array : []; $list = esc_attr( implode( ', ', $array ) ); $label = strval( $args['label'] ?? '' ); @@ -595,7 +595,7 @@ function fictioneer_get_metabox_tokens( $post, $meta_key, $options, $args = [] ) function fictioneer_get_metabox_icons( $post, $meta_key, $args = [] ) { // Setup - $meta_value = esc_attr( fictioneer_get_field( $meta_key, $post->ID ) ); + $meta_value = esc_attr( get_post_meta( $post->ID, $meta_key, true ) ); $label = strval( $args['label'] ?? '' ); $description = strval( $args['description'] ?? '' ); $placeholder = strval( $args['placeholder'] ?? '' ); @@ -667,7 +667,7 @@ function fictioneer_get_metabox_icons( $post, $meta_key, $args = [] ) { function fictioneer_get_metabox_editor( $post, $meta_key, $args = [] ) { // Setup - $meta_value = fictioneer_get_field( $meta_key, $post->ID ); + $meta_value = get_post_meta( $post->ID, $meta_key, true ); $label = strval( $args['label'] ?? '' ); $description = strval( $args['description'] ?? '' ); $required = ( $args['required'] ?? 0 ) ? 'required' : ''; @@ -962,7 +962,7 @@ function fictioneer_callback_relationship_chapters( $selected, $meta_key, $args $title = fictioneer_get_safe_title( $chapter ); $classes = ['fictioneer-meta-field__relationships-item', 'fictioneer-meta-field__relationships-values-item']; - if ( fictioneer_get_field( 'fictioneer_chapter_hidden', $chapter->ID ) ) { + if ( get_post_meta( $chapter->ID, 'fictioneer_chapter_hidden', true ) ) { $title = "{$title} (" . _x( 'Unlisted', 'Chapter assignment flag.', 'fictioneer' ) . ")"; } @@ -1051,7 +1051,7 @@ function fictioneer_ajax_get_relationship_chapters( $post_id, $meta_key ) { $classes = ['fictioneer-meta-field__relationships-item', 'fictioneer-meta-field__relationships-source-item']; // Update title if necessary - if ( fictioneer_get_field( 'fictioneer_chapter_hidden', $chapter->ID ) ) { + if ( get_post_meta( $chapter->ID, 'fictioneer_chapter_hidden', true ) ) { $title = "{$title} (" . _x( 'Unlisted', 'Chapter assignment flag.', 'fictioneer' ) . ")"; } @@ -1109,11 +1109,11 @@ function fictioneer_ajax_get_relationship_chapters( $post_id, $meta_key ) { function fictioneer_get_relationship_chapter_details( $chapter ) { // Setup - $text_icon = fictioneer_get_field( 'fictioneer_chapter_text_icon', $chapter->ID ); + $text_icon = get_post_meta( $chapter->ID, 'fictioneer_chapter_text_icon', true ); $icon = fictioneer_get_icon_field( 'fictioneer_chapter_icon', $chapter->ID ); - $rating = fictioneer_get_field( 'fictioneer_chapter_rating', $chapter->ID ); - $warning = fictioneer_get_field( 'fictioneer_chapter_warning', $chapter->ID ); - $group = fictioneer_get_field( 'fictioneer_chapter_group', $chapter->ID ); + $rating = get_post_meta( $chapter->ID, 'fictioneer_chapter_rating', true ); + $warning = get_post_meta( $chapter->ID, 'fictioneer_chapter_warning', true ); + $group = get_post_meta( $chapter->ID, 'fictioneer_chapter_group', true ); $flags = []; $status_labels = array( 'draft' => get_post_status_object( 'draft' )->label, @@ -1129,11 +1129,11 @@ function fictioneer_get_relationship_chapter_details( $chapter ) { // Build $info[] = empty( $text_icon ) ? sprintf( '', $icon ) : "{$text_icon}"; - if ( fictioneer_get_field( 'fictioneer_chapter_hidden', $chapter->ID ) ) { + if ( get_post_meta( $chapter->ID, 'fictioneer_chapter_hidden', true ) ) { $flags[] = _x( 'Unlisted', 'Chapter assignment flag.', 'fictioneer' ); } - if ( fictioneer_get_field( 'fictioneer_chapter_no_chapter', $chapter->ID ) ) { + if ( get_post_meta( $chapter->ID, 'fictioneer_chapter_no_chapter', true ) ) { $flags[] = _x( 'No Chapter', 'Chapter assignment flag.', 'fictioneer' ); } @@ -1905,7 +1905,7 @@ function fictioneer_render_story_data_metabox( $post ) { ); // Chapters - $chapter_ids = fictioneer_get_field( 'fictioneer_story_chapters', $post->ID ) ?: []; + $chapter_ids = get_post_meta( $post->ID, 'fictioneer_story_chapters', true ) ?: []; $chapter_ids = is_array( $chapter_ids ) ? $chapter_ids : []; $chapters = empty( $chapter_ids ) ? [] : get_posts( array( @@ -1936,7 +1936,7 @@ function fictioneer_render_story_data_metabox( $post ) { // Custom pages if ( current_user_can( 'fcn_story_pages', $post->ID ) && FICTIONEER_MAX_CUSTOM_PAGES_PER_STORY > 0 ) { - $page_ids = fictioneer_get_field( 'fictioneer_story_custom_pages', $post->ID ) ?: []; + $page_ids = get_post_meta( $post->ID, 'fictioneer_story_custom_pages', true ) ?: []; $page_ids = is_array( $page_ids ) ? $page_ids : []; $pages = empty( $page_ids ) ? [] : get_posts( array( @@ -2220,7 +2220,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_field( 'fictioneer_story_chapters', $post_id ); + $previous_chapter_ids = get_post_meta( $post_id, 'fictioneer_story_chapters', true ); $previous_chapter_ids = is_array( $previous_chapter_ids ) ? $previous_chapter_ids : []; $chapter_ids = $_POST['fictioneer_story_chapters']; @@ -2568,7 +2568,7 @@ function fictioneer_render_chapter_data_metabox( $post ) { $nonce = wp_create_nonce( "chapter_meta_data_{$post->ID}" ); // Accounts for manual wp_update_post() calls! $post_author_id = get_post_field( 'post_author', $post->ID ); - $current_story_id = fictioneer_get_field( 'fictioneer_chapter_story', $post->ID ); + $current_story_id = get_post_meta( $post->ID, 'fictioneer_chapter_story', true ); $output = []; // --- Add fields ------------------------------------------------------------ @@ -2844,7 +2844,7 @@ function fictioneer_save_chapter_metaboxes( $post_id ) { // Story if ( isset( $_POST['fictioneer_chapter_story'] ) ) { $story_id = absint( $_POST['fictioneer_chapter_story'] ); - $current_story_id = absint( fictioneer_get_field( 'fictioneer_chapter_story', $post_id ) ); + $current_story_id = absint( get_post_meta( $post_id, 'fictioneer_chapter_story', true ) ); if ( $story_id ) { $story_author_id = get_post_field( 'post_author', $story_id ); @@ -2942,7 +2942,7 @@ function fictioneer_append_chapter_to_story( $post_id, $story_id ) { } // Get current story chapters - $story_chapters = fictioneer_get_field( 'fictioneer_story_chapters', $story_id ); + $story_chapters = get_post_meta( $story_id, 'fictioneer_story_chapters', true ); // Prepare chapter array if null (or broken) if ( ! is_array( $story_chapters ) ) { @@ -3483,7 +3483,7 @@ function fictioneer_render_featured_content_metabox( $post ) { // --- Add fields -------------------------------------------------------------- // Featured items - $item_ids = fictioneer_get_field( 'fictioneer_post_featured', $post->ID ) ?: []; + $item_ids = get_post_meta( $post->ID, 'fictioneer_post_featured', true ) ?: []; $item_ids = is_array( $item_ids ) ? $item_ids : []; $items = empty( $item_ids ) ? [] : get_posts( array( @@ -3616,7 +3616,7 @@ add_action( 'save_post', 'fictioneer_save_post_metaboxes' ); function fictioneer_update_post_relationship_registry( $post_id ) { // Setup $registry = fictioneer_get_relationship_registry(); - $featured = fictioneer_get_field( 'fictioneer_post_featured', $post_id ); + $featured = get_post_meta( $post_id, 'fictioneer_post_featured', true ); // Update relationships $registry[ $post_id ] = []; @@ -3715,7 +3715,7 @@ function fictioneer_render_collection_data_metabox( $post ) { ); // Collection items - $item_ids = fictioneer_get_field( 'fictioneer_collection_items', $post->ID ) ?: []; + $item_ids = get_post_meta( $post->ID, 'fictioneer_collection_items', true ) ?: []; $item_ids = is_array( $item_ids ) ? $item_ids : []; $items = empty( $item_ids ) ? [] : get_posts( array( diff --git a/includes/functions/_post_updates.php b/includes/functions/_post_updates.php index 78e095db..235dc0d0 100644 --- a/includes/functions/_post_updates.php +++ b/includes/functions/_post_updates.php @@ -26,7 +26,7 @@ function fictioneer_update_modified_date_on_story_for_chapter( $post_id ) { } // Setup - $story_id = fictioneer_get_field( 'fictioneer_chapter_story', $post_id ); + $story_id = get_post_meta( $post_id, 'fictioneer_chapter_story', true ); // No linked story found if ( empty( $story_id ) || ! get_post_status( $story_id ?? 0 ) ) { @@ -97,7 +97,7 @@ function fictioneer_store_original_publish_date( $post_id, $post ) { } // Get first publish date (if set) - $first_publish_date = fictioneer_get_field( 'fictioneer_first_publish_date', $post_id ); + $first_publish_date = get_post_meta( $post_id, 'fictioneer_first_publish_date', true ); // Set if missing if ( empty( $first_publish_date ) || strtotime( $first_publish_date ) === false ) { @@ -122,7 +122,7 @@ add_action( 'save_post', 'fictioneer_store_original_publish_date', 10, 2 ); function fictioneer_get_story_changelog( $story_id ) { // Setup - $changelog = fictioneer_get_field( 'fictioneer_story_changelog', $story_id ); + $changelog = get_post_meta( $story_id, 'fictioneer_story_changelog', true ); $changelog = is_array( $changelog ) ? $changelog : []; // Initialize @@ -215,7 +215,7 @@ function fictioneer_log_story_chapter_status_changes( $new_status, $old_status, } // Story? - $story_id = fictioneer_get_field( 'fictioneer_chapter_story', $post->ID ); + $story_id = get_post_meta( $post->ID, 'fictioneer_chapter_story', true ); if ( empty( $story_id ) ) { return; @@ -282,15 +282,15 @@ function fictioneer_remove_chapter_from_story( $chapter_id ) { } // Story? - $story_id = fictioneer_get_field( 'fictioneer_chapter_story', $chapter_id ); + $story_id = get_post_meta( $chapter_id, 'fictioneer_chapter_story', true ); if ( empty( $story_id ) ) { return; } // Check chapter list - $chapters = fictioneer_get_field( 'fictioneer_story_chapters', $story_id ); - $previous = fictioneer_get_field( 'fictioneer_story_chapters', $story_id ); + $chapters = get_post_meta( $story_id, 'fictioneer_story_chapters', true ) ?: []; + $previous = get_post_meta( $story_id, 'fictioneer_story_chapters', true ) ?: []; if ( empty( $chapters ) || ! in_array( $chapter_id, $chapters ) ) { return; diff --git a/includes/functions/_query_helpers.php b/includes/functions/_query_helpers.php index 38d9a7ae..72c12c58 100644 --- a/includes/functions/_query_helpers.php +++ b/includes/functions/_query_helpers.php @@ -88,7 +88,7 @@ if ( ! function_exists( 'fictioneer_get_card_list' ) ) { if ( $post_type === 'fcn_story' ) { // Story hidden? foreach ( $all_query->posts as $candidate ) { - if ( fictioneer_get_field( 'fictioneer_story_hidden', $candidate->ID ) ) { + if ( get_post_meta( $candidate->ID, 'fictioneer_story_hidden', true ) ) { $excluded[] = $candidate->ID; } } @@ -96,8 +96,8 @@ if ( ! function_exists( 'fictioneer_get_card_list' ) ) { // Chapter hidden or excluded? foreach ( $all_query->posts as $candidate ) { if ( - fictioneer_get_field( 'fictioneer_chapter_hidden', $candidate->ID ) || - fictioneer_get_field( 'fictioneer_chapter_no_chapter', $candidate->ID ) + get_post_meta( $candidate->ID, 'fictioneer_chapter_hidden', true ) || + get_post_meta( $candidate->ID, 'fictioneer_chapter_no_chapter', true ) ) { $excluded[] = $candidate->ID; } @@ -134,7 +134,7 @@ if ( ! function_exists( 'fictioneer_get_card_list' ) ) { switch ( $post_type ) { case 'fcn_story': - if ( fictioneer_get_field( 'fictioneer_story_hidden', get_the_ID() ) ) { + if ( get_post_meta( get_the_ID(), 'fictioneer_story_hidden', true ) ) { get_template_part( 'partials/_card-hidden', null, $the_card_args ); } else { get_template_part( $card_partial, null, $the_card_args ); @@ -142,8 +142,8 @@ if ( ! function_exists( 'fictioneer_get_card_list' ) ) { break; case 'fcn_chapter': if ( - fictioneer_get_field( 'fictioneer_chapter_hidden', get_the_ID() ) || - fictioneer_get_field( 'fictioneer_chapter_no_chapter', get_the_ID() ) + get_post_meta( get_the_ID(), 'fictioneer_chapter_hidden', true ) || + get_post_meta( get_the_ID(), 'fictioneer_chapter_no_chapter', true ) ) { get_template_part( 'partials/_card-hidden', null, $the_card_args ); } else { diff --git a/includes/functions/_roles.php b/includes/functions/_roles.php index 3c208d71..4dfe0009 100644 --- a/includes/functions/_roles.php +++ b/includes/functions/_roles.php @@ -1321,7 +1321,7 @@ if ( ! current_user_can( 'manage_options' ) ) { function fictioneer_prevent_publish_date_update( $data, $postarr ) { // Setup - $first_publish_date = fictioneer_get_field( 'fictioneer_first_publish_date', $postarr['ID'] ); + $first_publish_date = get_post_meta( $postarr['ID'], 'fictioneer_first_publish_date', true ); // Remove from update array if already published once if ( ! empty( $first_publish_date ) ) { diff --git a/includes/functions/_schemas.php b/includes/functions/_schemas.php index 42128518..a0bf17d4 100644 --- a/includes/functions/_schemas.php +++ b/includes/functions/_schemas.php @@ -324,7 +324,7 @@ function fictioneer_output_schemas( $post_id = null ) { // Setup $post_id = empty( $post_id ) ? get_queried_object_id() : $post_id; - $schema = fictioneer_get_field( 'fictioneer_schema', $post_id ); + $schema = get_post_meta( $post_id, 'fictioneer_schema', true ); // No schema found... if ( ! $schema ) { diff --git a/includes/functions/_seo.php b/includes/functions/_seo.php index 22ba77c3..9fb86fc4 100644 --- a/includes/functions/_seo.php +++ b/includes/functions/_seo.php @@ -54,16 +54,16 @@ if ( ! function_exists( 'fictioneer_seo_fields' ) ) { function fictioneer_seo_fields( $post ) { // Title - $seo_title = fictioneer_get_field( 'fictioneer_seo_title', $post->ID ) ?: ''; + $seo_title = get_post_meta( $post->ID, 'fictioneer_seo_title', true ); $seo_title_placeholder = fictioneer_get_safe_title( $post->ID ); // Description (truncated if necessary) - $seo_description = fictioneer_get_field( 'fictioneer_seo_description', $post->ID ) ?: ''; + $seo_description = get_post_meta( $post->ID, 'fictioneer_seo_description', true ); $seo_description_placeholder = wp_strip_all_tags( get_the_excerpt( $post ), true ); $seo_description_placeholder = mb_strimwidth( $seo_description_placeholder, 0, 155, '…' ); // Open Graph image... - $seo_og_image = fictioneer_get_field( 'fictioneer_seo_og_image', $post->ID ); + $seo_og_image = get_post_meta( $post->ID, 'fictioneer_seo_og_image', true ); $seo_og_image_display = wp_get_attachment_url( $seo_og_image ); $image_source = ''; @@ -75,7 +75,7 @@ if ( ! function_exists( 'fictioneer_seo_fields' ) ) { // ... if not found, look for parent thumbnail... if ( ! $seo_og_image_display && $post->post_type === 'fcn_chapter' ) { - $story_id = fictioneer_get_field( 'fictioneer_chapter_story', $post->ID ); + $story_id = get_post_meta( $post->ID, 'fictioneer_chapter_story', true ); if ( $story_id && has_post_thumbnail( $story_id ) ) { $seo_og_image_display = get_the_post_thumbnail_url( $story_id ); @@ -305,14 +305,14 @@ if ( ! function_exists( 'fictioneer_get_seo_title' ) ) { } // Cached title? - $cache = fictioneer_get_field( 'fictioneer_seo_title_cache', $post_id ); + $cache = get_post_meta( $post_id, 'fictioneer_seo_title_cache', true ); if ( ! empty( $cache ) && ! $skip_cache ) { return $cache; } // Start building... - $seo_title = fictioneer_get_field( 'fictioneer_seo_title', $post_id ); + $seo_title = get_post_meta( $post_id, 'fictioneer_seo_title', true ); $seo_title = empty( $seo_title ) ? false : $seo_title; $title = fictioneer_get_safe_title( $post_id ); $default = empty( $default ) ? $title : $default; @@ -460,14 +460,14 @@ if ( ! function_exists( 'fictioneer_get_seo_description' ) ) { } // Cached description? - $cache = fictioneer_get_field( 'fictioneer_seo_description_cache', $post_id ); + $cache = get_post_meta( $post_id, 'fictioneer_seo_description_cache', true ); if ( ! empty( $cache ) && ! $skip_cache ) { return $cache; } // Start building... - $seo_description = fictioneer_get_field( 'fictioneer_seo_description', $post_id ); + $seo_description = get_post_meta( $post_id, 'fictioneer_seo_description', true ); $seo_description = empty( $seo_description ) ? false : $seo_description; $title = fictioneer_get_safe_title( $post_id ); $excerpt = wp_strip_all_tags( get_the_excerpt( $post_id ), true ); @@ -476,7 +476,7 @@ if ( ! function_exists( 'fictioneer_get_seo_description' ) ) { // Special Case: Recommendations if ( get_post_type( $post_id ) == 'fcn_recommendation' ) { - $one_sentence = fictioneer_get_field( 'fictioneer_recommendation_one_sentence', $post_id ) ?? ''; + $one_sentence = get_post_meta( $post_id, 'fictioneer_recommendation_one_sentence', true ) ?? ''; $one_sentence = trim( $one_sentence ); $default = empty( $one_sentence ) ? $default : $one_sentence; @@ -550,7 +550,7 @@ if ( ! function_exists( 'fictioneer_get_seo_image' ) ) { // Cached image? Except for site default, which can globally change! if ( ! $use_default ) { - $cache = fictioneer_get_field( 'fictioneer_seo_og_image_cache', $post_id ); + $cache = get_post_meta( $post_id, 'fictioneer_seo_og_image_cache', true ); if ( $cache ) { return $cache; @@ -559,7 +559,7 @@ if ( ! function_exists( 'fictioneer_get_seo_image' ) ) { // Get image ID if not yet set if ( ! $image_id ) { - $image_id = fictioneer_get_field( 'fictioneer_seo_og_image', $post_id ); + $image_id = get_post_meta( $post_id, 'fictioneer_seo_og_image', true ); $image_id = wp_attachment_is_image( $image_id ) ? $image_id : false; } @@ -572,7 +572,7 @@ if ( ! function_exists( 'fictioneer_get_seo_image' ) ) { // Try story thumbnail if chapter... if ( ! $image_id && get_post_type( $post_id ) == 'fcn_chapter' ) { - $story_id = fictioneer_get_field( 'fictioneer_chapter_story', $post_id ); + $story_id = get_post_meta( $post_id, 'fictioneer_chapter_story', true ); $image_id = has_post_thumbnail( $story_id ) ? get_post_thumbnail_id( $story_id ) : $image_id; } @@ -625,7 +625,7 @@ function fictioneer_output_head_seo() { $post_id = get_queried_object_id(); // In archives and search, this is the first post $post_type = get_post_type(); // In archives and search, this is the first post $post_author = $post->post_author ?? 0; - $chapter_story_id = fictioneer_get_field( 'fictioneer_chapter_story' ) ?? 0; + $chapter_story_id = get_post_meta( $post_id, 'fictioneer_chapter_story', true ); $canonical_url = wp_get_canonical_url(); // Unreliable on aggregated pages // Flags @@ -644,7 +644,7 @@ function fictioneer_output_head_seo() { // Special Case: Recommendation author if ( $post_author && $show_author && $post_type == 'fcn_recommendation' ) { - $article_author = fictioneer_get_field( 'fictioneer_recommendation_author', $post_id ) ?? $article_author; + $article_author = get_post_meta( $post_id, 'fictioneer_recommendation_author', true ) ?? $article_author; } // Special Case: Archives @@ -679,8 +679,8 @@ function fictioneer_output_head_seo() { // Get co-authors (if any) $co_authors = $post_type == 'fcn_story' ? - fictioneer_get_field( 'fictioneer_story_co_authors', $post_id ) ?? [] : - fictioneer_get_field( 'fictioneer_chapter_co_authors', $post_id ) ?? []; + get_post_meta( $post_id, 'fictioneer_story_co_authors', true ) : + get_post_meta( $post_id, 'fictioneer_chapter_co_authors', true ); // Add co-authors URL or name if ( is_array( $co_authors ) && ! empty( $co_authors ) ) { diff --git a/includes/functions/_shortcodes.php b/includes/functions/_shortcodes.php index a00bcd71..6b567d2c 100644 --- a/includes/functions/_shortcodes.php +++ b/includes/functions/_shortcodes.php @@ -898,7 +898,7 @@ function fictioneer_shortcode_chapter_list( $attr ) { // Get chapters... if ( $story_id && empty( $chapter_ids ) ) { // ... via story - $hide_icons = $hide_icons || fictioneer_get_field( 'fictioneer_story_hide_chapter_icons', $story_id ); + $hide_icons = $hide_icons || get_post_meta( $story_id, 'fictioneer_story_hide_chapter_icons', true ); $story_data = fictioneer_get_story_data( $story_id, false ); // Does not refresh comment count! $chapters = $story_data['chapter_ids']; } elseif ( ! empty( $chapter_ids ) ) { @@ -973,15 +973,15 @@ function fictioneer_shortcode_chapter_list( $attr ) { // Setup $chapter_query->the_post(); $chapter_id = get_the_ID(); - $chapter_story_id = fictioneer_get_field( 'fictioneer_chapter_story' ); + $chapter_story_id = get_post_meta( $chapter_id, 'fictioneer_chapter_story', true ); // Skip not visible chapters - if ( fictioneer_get_field( 'fictioneer_chapter_hidden' ) ) { + if ( get_post_meta( $chapter_id, 'fictioneer_chapter_hidden', true ) ) { continue; } // Check group (if any) - if ( $group && $group != strtolower( trim( fictioneer_get_field( 'fictioneer_chapter_group' ) ) ) ) { + if ( $group && $group != strtolower( trim( get_post_meta( $chapter_id, 'fictioneer_chapter_group', true ) ) ) ) { continue; } @@ -999,11 +999,11 @@ function fictioneer_shortcode_chapter_list( $attr ) { } // Data - $warning = fictioneer_get_field( 'fictioneer_chapter_warning' ); - $icon = fictioneer_get_icon_field( 'fictioneer_chapter_icon' ); - $text_icon = fictioneer_get_field( 'fictioneer_chapter_text_icon' ); - $prefix = fictioneer_get_field( 'fictioneer_chapter_prefix' ); - $words = fictioneer_get_field( '_word_count', $chapter_id ); + $warning = get_post_meta( $chapter_id, 'fictioneer_chapter_warning', true ); + $icon = fictioneer_get_icon_field( 'fictioneer_chapter_icon', $chapter_id ); + $text_icon = get_post_meta( $chapter_id, 'fictioneer_chapter_text_icon', true ); + $prefix = get_post_meta( $chapter_id, 'fictioneer_chapter_prefix', true ); + $words = get_post_meta( $chapter_id, '_word_count', true ); $title = fictioneer_get_safe_title( $chapter_id ); // Start HTML ---> ?> diff --git a/includes/functions/_sitemap.php b/includes/functions/_sitemap.php index 7d00b5ee..f062e7d6 100644 --- a/includes/functions/_sitemap.php +++ b/includes/functions/_sitemap.php @@ -209,12 +209,12 @@ function fictioneer_create_sitemap( $last_saved_id, $last_saved_post ) { } foreach ( $stories as $post ) { - if ( fictioneer_get_field( 'fictioneer_story_hidden', $post->ID ) ) { + if ( get_post_meta( $post->ID, 'fictioneer_story_hidden', true ) ) { continue; } $lastmod = get_the_modified_date( 'c', $post->ID ); - $status = fictioneer_get_field( 'fictioneer_story_status', $post->ID ); + $status = get_post_meta( $post->ID, 'fictioneer_story_status', true ); $frequency = $status == 'Ongoing' ? 'weekly' : 'monthly'; $sitemap .= fictioneer_url_node( get_permalink( $post->ID ), $lastmod, $frequency ); } @@ -240,7 +240,7 @@ function fictioneer_create_sitemap( $last_saved_id, $last_saved_post ) { } foreach( $chapters as $post ) { - if ( fictioneer_get_field( 'fictioneer_chapter_hidden', $post->ID ) ) { + if ( get_post_meta( $post->ID, 'fictioneer_chapter_hidden', true ) ) { continue; } diff --git a/includes/functions/_theme_setup.php b/includes/functions/_theme_setup.php index 6aaf0a56..e7fb210a 100644 --- a/includes/functions/_theme_setup.php +++ b/includes/functions/_theme_setup.php @@ -704,7 +704,7 @@ function fictioneer_add_custom_scripts() { ! is_archive() && ! is_search() && ! post_password_required() && - ! fictioneer_get_field( 'fictioneer_disable_commenting' ) && + ! get_post_meta( get_the_ID(), 'fictioneer_disable_commenting', true ) && comments_open() ) { wp_enqueue_script( 'dmp', get_template_directory_uri() . '/js/diff-match-patch.js', array(), null, true ); diff --git a/includes/functions/_utility.php b/includes/functions/_utility.php index 91dcf240..555a365f 100644 --- a/includes/functions/_utility.php +++ b/includes/functions/_utility.php @@ -190,7 +190,7 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) { // Check cache if ( FICTIONEER_ENABLE_STORY_DATA_META_CACHE ) { - $old_data = fictioneer_get_field( 'fictioneer_story_data_collection', $story_id ); + $old_data = get_post_meta( $story_id, 'fictioneer_story_data_collection', true ); } if ( ! empty( $old_data ) && $old_data['last_modified'] >= get_the_modified_time( 'U', $story_id ) ) { @@ -270,13 +270,13 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) { } // Setup - $chapters = fictioneer_get_field( 'fictioneer_story_chapters', $story_id ); + $chapters = get_post_meta( $story_id, 'fictioneer_story_chapters', true ) ?: []; $tags = get_the_tags( $story_id ); $fandoms = get_the_terms( $story_id, 'fcn_fandom' ); $characters = get_the_terms( $story_id, 'fcn_character' ); $warnings = get_the_terms( $story_id, 'fcn_content_warning' ); $genres = get_the_terms( $story_id, 'fcn_genre' ); - $status = fictioneer_get_field( 'fictioneer_story_status', $story_id ); + $status = get_post_meta( $story_id, 'fictioneer_story_status', true ); $icon = 'fa-solid fa-circle'; $chapter_count = 0; $word_count = 0; @@ -319,11 +319,11 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) { if ( ! empty( $chapters ) && $chapters->have_posts() ) { foreach ( $chapters->posts as $chapter ) { // This is about 50 times faster than using a meta query lol - if ( ! fictioneer_get_field( 'fictioneer_chapter_hidden', $chapter->ID ) ) { + if ( ! get_post_meta( $chapter->ID, 'fictioneer_chapter_hidden', true ) ) { // Do not count non-chapters... - if ( ! fictioneer_get_field( 'fictioneer_chapter_no_chapter', $chapter->ID ) ) { + if ( ! get_post_meta( $chapter->ID, 'fictioneer_chapter_no_chapter', true ) ) { $chapter_count += 1; - $word_count += (int) fictioneer_get_field( '_word_count', $chapter->ID ); + $word_count += (int) get_post_meta( $chapter->ID, '_word_count', true ); } // ... but they are still listed! @@ -336,7 +336,7 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) { } // Add story word count - $word_count += (int) fictioneer_get_field( '_word_count', $story_id ); + $word_count += (int) get_post_meta( $story_id, '_word_count', true ); // Prepare result $result = array( @@ -353,8 +353,8 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) { 'warnings' => $warnings, 'genres' => $genres, 'title' => fictioneer_get_safe_title( $story_id ), - 'rating' => fictioneer_get_field( 'fictioneer_story_rating', $story_id ), - 'rating_letter' => fictioneer_get_field( 'fictioneer_story_rating', $story_id )[0], + 'rating' => get_post_meta( $story_id, 'fictioneer_story_rating', true ), + 'rating_letter' => get_post_meta( $story_id, 'fictioneer_story_rating', true )[0], 'chapter_ids' => $chapter_ids, 'last_modified' => get_the_modified_time( 'U', $story_id ), 'comment_count' => $comment_count, @@ -426,7 +426,7 @@ if ( ! function_exists( 'fictioneer_get_author_statistics' ) ) { // Filter out unwanted stories (faster than meta query) $stories = array_filter( $stories, function ( $post ) { // Story hidden? - $story_hidden = fictioneer_get_field( 'fictioneer_story_hidden', $post->ID ); + $story_hidden = get_post_meta( $post->ID, 'fictioneer_story_hidden', true ); return empty( $story_hidden ) || $story_hidden === '0'; }); @@ -447,11 +447,11 @@ if ( ! function_exists( 'fictioneer_get_author_statistics' ) ) { // Filter out unwanted chapters (faster than meta query) $chapters = array_filter( $chapters, function ( $post ) { // Chapter hidden? - $chapter_hidden = fictioneer_get_field( 'fictioneer_chapter_hidden', $post->ID ); + $chapter_hidden = get_post_meta( $post->ID, 'fictioneer_chapter_hidden', true ); $not_hidden = empty( $chapter_hidden ) || $chapter_hidden === '0'; // Not a chapter? - $no_chapter = fictioneer_get_field( 'fictioneer_chapter_no_chapter', $post->ID ); + $no_chapter = get_post_meta( $post->ID, 'fictioneer_chapter_no_chapter', true ); $is_chapter = empty( $no_chapter ) || $no_chapter === '0'; // Only keep if both conditions are met @@ -463,7 +463,7 @@ if ( ! function_exists( 'fictioneer_get_author_statistics' ) ) { $comment_count = 0; foreach ( $chapters as $chapter ) { - $word_count += (int) fictioneer_get_field( '_word_count', $chapter->ID ); + $word_count += (int) get_post_meta( $chapter->ID, '_word_count', true ); $comment_count += get_comments_number( $chapter ); } @@ -791,31 +791,9 @@ if ( ! function_exists( 'fictioneer_is_editor' ) ) { // GET META FIELDS // ============================================================================= -if ( ! function_exists( 'fictioneer_get_field' ) ) { - /** - * Wrapper for get_post_meta with single value return - * - * @since Fictioneer 5.0 - * - * @param string $field Name of the meta field to retrieve. - * @param int $post_id Optional. The ID of the post the field belongs to. - * Defaults to current post ID. - * - * @return mixed The single field value. - */ - - function fictioneer_get_field( $field, $post_id = null ) { - // Setup - $post_id = $post_id ? absint( $post_id ) : get_the_ID(); - - // Retrieve post meta - return get_post_meta( $post_id, $field, true ); - } -} - if ( ! function_exists( 'fictioneer_get_content_field' ) ) { /** - * Wrapper for fictioneer_get_field with content filers applied + * Wrapper for get_post_meta() with content filers applied * * @since Fictioneer 5.0 * @@ -828,7 +806,7 @@ if ( ! function_exists( 'fictioneer_get_content_field' ) ) { function fictioneer_get_content_field( $field, $post_id = null ) { // Setup - $content = fictioneer_get_field( $field, $post_id ); + $content = get_post_meta( $post_id ?? get_the_ID(), $field, true ); // Apply default filter functions from the_content (but nothing else) $content = wptexturize( $content ); @@ -844,7 +822,7 @@ if ( ! function_exists( 'fictioneer_get_content_field' ) ) { if ( ! function_exists( 'fictioneer_get_icon_field' ) ) { /** - * Wrapper for fictioneer_get_field to get Font Awesome icon class + * Wrapper for get_post_meta() to get Font Awesome icon class * * @since Fictioneer 5.0 * @@ -857,7 +835,7 @@ if ( ! function_exists( 'fictioneer_get_icon_field' ) ) { function fictioneer_get_icon_field( $field, $post_id = null ) { // Setup - $icon = fictioneer_get_field( $field, $post_id ); + $icon = get_post_meta( $post_id ?? get_the_ID(), $field, true ); $icon_object = json_decode( $icon ); // Check for ACF Font Awesome plugin // Valid? @@ -1420,7 +1398,6 @@ if ( ! function_exists( 'fictioneer_is_commenting_disabled' ) ) { * comment section but does not allow new comments to be posted. * * @since 5.0 - * @see fictioneer_get_field() * * @param int|null $post_id Post ID the comments are for. Defaults to current post ID. * @@ -1431,17 +1408,17 @@ if ( ! function_exists( 'fictioneer_is_commenting_disabled' ) ) { // Return immediately if... if ( get_option( 'fictioneer_disable_commenting' ) || - fictioneer_get_field( 'fictioneer_disable_commenting', $post_id ) + get_post_meta( $post_id, 'fictioneer_disable_commenting', true ) ) { return true; } // Check parent story if chapter... if ( get_post_type( $post_id ) === 'fcn_chapter' ) { - $story_id = fictioneer_get_field( 'fictioneer_chapter_story', $post_id ); + $story_id = get_post_meta( $post_id, 'fictioneer_chapter_story', true ); if ( $story_id ) { - return fictioneer_get_field( 'fictioneer_disable_commenting', $story_id ) == true; + return get_post_meta( $story_id, 'fictioneer_disable_commenting', true ) == true; } } @@ -1853,7 +1830,7 @@ if ( ! function_exists( 'fictioneer_get_post_author_ids' ) ) { */ function fictioneer_get_post_author_ids( $post_id ) { - $author_ids = fictioneer_get_field( 'fictioneer_story_co_authors', $post_id ) ?? []; + $author_ids = get_post_meta( $post_id, 'fictioneer_story_co_authors', true ) ?: []; $author_ids = is_array( $author_ids ) ? $author_ids : []; array_unshift( $author_ids, get_post_field( 'post_author', $post_id ) ); diff --git a/includes/functions/_wordpress_mods.php b/includes/functions/_wordpress_mods.php index 287d83b7..3b2b09c9 100644 --- a/includes/functions/_wordpress_mods.php +++ b/includes/functions/_wordpress_mods.php @@ -369,7 +369,7 @@ function fictioneer_output_rss( $post_id = null ) { } // RSS Feed if chapter... - $story_id = fictioneer_get_field( 'fictioneer_chapter_story', $post_id ); + $story_id = get_post_meta( $post_id, 'fictioneer_chapter_story', true ); if ( $post_type == 'fcn_chapter' && ! empty( $story_id ) && ! $skip_to_default ) { $title = sprintf( @@ -1117,7 +1117,7 @@ function fictioneer_gate_unpublished_content() { // 404 chapter of unpublished story if ( $post->post_type === 'fcn_chapter' ) { - $story_id = fictioneer_get_field( 'fictioneer_chapter_story', $post->ID ); + $story_id = get_post_meta( $post->ID, 'fictioneer_chapter_story', true ); if ( ! empty( $story_id ) && diff --git a/includes/functions/hooks/_chapter_hooks.php b/includes/functions/hooks/_chapter_hooks.php index 879b4eb2..8ccc9862 100644 --- a/includes/functions/hooks/_chapter_hooks.php +++ b/includes/functions/hooks/_chapter_hooks.php @@ -42,7 +42,7 @@ function fictioneer_chapters_list( $args ) { while ( $args['chapters']->have_posts() ) { $args['chapters']->the_post(); - if ( fictioneer_get_field( 'fictioneer_chapter_hidden' ) ) { + if ( get_post_meta( get_the_ID(), 'fictioneer_chapter_hidden', true ) ) { get_template_part( 'partials/_card-hidden', null, $card_args ); } else { get_template_part( 'partials/_card-chapter', null, $card_args ); @@ -124,8 +124,8 @@ add_action( 'fictioneer_chapter_before_header', 'fictioneer_chapter_foreword', 1 function fictioneer_chapter_warnings( $args ) { // Setup - $warning = fictioneer_get_field( 'fictioneer_chapter_warning', $args['chapter_id'] ); - $warning_notes = fictioneer_get_field( 'fictioneer_chapter_warning_notes', $args['chapter_id'] ); + $warning = get_post_meta( $args['chapter_id'], 'fictioneer_chapter_warning', true ); + $warning_notes = get_post_meta( $args['chapter_id'], 'fictioneer_chapter_warning_notes', true ); // Abort conditions if ( ( ! $warning && ! $warning_notes ) || post_password_required() ) { @@ -434,7 +434,7 @@ function fictioneer_chapter_support_links( $args ) { // Abort conditions if ( post_password_required() || - fictioneer_get_field( 'fictioneer_chapter_hide_support_links', $args['chapter_id'] ) + get_post_meta( $args['chapter_id'], 'fictioneer_chapter_hide_support_links', true ) ) { return; } @@ -559,7 +559,7 @@ add_action( 'fictioneer_chapter_after_main', 'fictioneer_chapter_micro_menu', 10 function fictioneer_chapter_paragraph_tools() { // Setup - $can_comment = ! fictioneer_get_field( 'fictioneer_disable_commenting' ) && comments_open(); + $can_comment = ! get_post_meta( get_the_ID(), 'fictioneer_disable_commenting', true ) && comments_open(); // Start HTML ---> ?>
@@ -619,7 +619,7 @@ add_action( 'fictioneer_chapter_after_main', 'fictioneer_chapter_paragraph_tools function fictioneer_chapter_suggestion_tools() { // Abort if... - if ( fictioneer_get_field( 'fictioneer_disable_commenting' ) || ! comments_open() ) { + if ( get_post_meta( get_the_ID(), 'fictioneer_disable_commenting', true ) || ! comments_open() ) { return; } diff --git a/includes/functions/hooks/_general_hooks.php b/includes/functions/hooks/_general_hooks.php index 9b6d7030..6501127c 100644 --- a/includes/functions/hooks/_general_hooks.php +++ b/includes/functions/hooks/_general_hooks.php @@ -20,15 +20,15 @@ function fictioneer_add_fiction_css() { */ $custom_css = ''; - $custom_css .= fictioneer_get_field( 'fictioneer_custom_css', get_the_ID() ) ?: ''; + $custom_css .= get_post_meta( get_the_ID(), 'fictioneer_custom_css', true ); if ( get_post_type( get_the_ID() ) == 'fcn_story' ) { - $custom_css .= fictioneer_get_field( 'fictioneer_story_css', get_the_ID() ) ?: ''; + $custom_css .= get_post_meta( get_the_ID(), 'fictioneer_story_css', true ); } if ( get_post_type( get_the_ID() ) == 'fcn_chapter' ) { - $story_id = fictioneer_get_field( 'fictioneer_chapter_story', get_the_ID() ); - $custom_css .= fictioneer_get_field( 'fictioneer_story_css', $story_id ); + $story_id = get_post_meta( get_the_ID(), 'fictioneer_chapter_story', true ); + $custom_css .= get_post_meta( $story_id, 'fictioneer_story_css', true ); } if ( ! empty( $custom_css ) && ! preg_match( '# ?>
diff --git a/partials/_latest-updates-compact.php b/partials/_latest-updates-compact.php index d70f1dcc..4f71ce0f 100644 --- a/partials/_latest-updates-compact.php +++ b/partials/_latest-updates-compact.php @@ -127,7 +127,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' ); $search_list = array_reverse( $story['chapter_ids'] ); foreach ( $search_list as $chapter_id ) { - if ( fictioneer_get_field( 'fictioneer_chapter_hidden', $chapter_id ) ) { + if ( get_post_meta( $chapter_id, 'fictioneer_chapter_hidden', true ) ) { continue; } @@ -166,7 +166,9 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' ); ?> @@ -175,7 +177,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
 • '; echo get_the_date( FICTIONEER_LATEST_UPDATES_LI_DATE, $chapter_id ) ?> diff --git a/partials/_latest-updates.php b/partials/_latest-updates.php index 1954aa05..050b52e2 100644 --- a/partials/_latest-updates.php +++ b/partials/_latest-updates.php @@ -127,7 +127,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' ); $search_list = array_reverse( $story['chapter_ids'] ); foreach ( $search_list as $chapter_id ) { - if ( fictioneer_get_field( 'fictioneer_chapter_hidden', $chapter_id ) ) { + if ( get_post_meta( $chapter_id, 'fictioneer_chapter_hidden', true ) ) { continue; } @@ -168,7 +168,9 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' ); ?>
@@ -181,7 +183,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
 • '; echo get_the_date( FICTIONEER_LATEST_UPDATES_LI_DATE, $chapter_id ) ?> diff --git a/partials/_share-buttons.php b/partials/_share-buttons.php index 19d9974a..f139260f 100644 --- a/partials/_share-buttons.php +++ b/partials/_share-buttons.php @@ -20,7 +20,7 @@ defined( 'ABSPATH' ) OR exit; // Setup $feed = fictioneer_get_rss_link(); $show_feed = get_post_type() !== 'fcn_story' || - ( get_post_type() === 'fcn_story' && fictioneer_get_field( 'fictioneer_story_status', get_the_ID() ) !== 'Oneshot' ) + ( get_post_type() === 'fcn_story' && get_post_meta( get_the_ID(), 'fictioneer_story_status', true ) !== 'Oneshot' ) ?> @@ -36,7 +36,7 @@ $show_feed = get_post_type() !== 'fcn_story' || - + @@ -148,7 +150,7 @@ $disable_folding = fictioneer_get_field( 'fictioneer_story_disable_collapse' );
get_the_ID(), + 'id' => $chapter_id, 'link' => get_permalink(), 'timestamp' => get_the_time( 'c' ), 'password' => ! empty( $post->post_password ), 'list_date' => get_the_date( '', $post ), 'grid_date' => get_the_time( get_option( 'fictioneer_subitem_date_format', "M j, 'y" ) ?: "M j, 'y" ), - 'icon' => fictioneer_get_icon_field( 'fictioneer_chapter_icon' ), - 'text_icon' => fictioneer_get_field( 'fictioneer_chapter_text_icon' ), - 'prefix' => fictioneer_get_field( 'fictioneer_chapter_prefix' ), + 'icon' => fictioneer_get_icon_field( 'fictioneer_chapter_icon', $chapter_id ), + 'text_icon' => get_post_meta( $chapter_id, 'fictioneer_chapter_text_icon', true ), + 'prefix' => get_post_meta( $chapter_id, 'fictioneer_chapter_prefix', true ), 'title' => fictioneer_get_safe_title( $chapter_id ), - 'list_title' => fictioneer_get_field( 'fictioneer_chapter_list_title' ), - 'words' => fictioneer_get_field( '_word_count', $chapter_id ), - 'warning' => fictioneer_get_field( 'fictioneer_chapter_warning' ) + 'list_title' => get_post_meta( $chapter_id, 'fictioneer_chapter_list_title', true ), + 'words' => get_post_meta( $chapter_id, '_word_count', true ), + 'warning' => get_post_meta( $chapter_id, 'fictioneer_chapter_warning', true ) ); } } diff --git a/partials/_story-header.php b/partials/_story-header.php index fbdfed7e..f61111a3 100644 --- a/partials/_story-header.php +++ b/partials/_story-header.php @@ -23,12 +23,18 @@ defined( 'ABSPATH' ) OR exit; // Setup $story = $args['story_data']; $story_id = $args['story_id']; -$tax_shown = ! get_option( 'fictioneer_hide_taxonomies_on_pages' ) && $story['has_taxonomies'] && ! fictioneer_get_field( 'fictioneer_story_no_tags' ); -$thumbnail_shown = has_post_thumbnail() && ! fictioneer_get_field( 'fictioneer_story_no_thumbnail' ); +$thumbnail_shown = has_post_thumbnail() && ! get_post_meta( $story_id, 'fictioneer_story_no_thumbnail', true ); +$tax_shown = ! get_option( 'fictioneer_hide_taxonomies_on_pages' ) && + $story['has_taxonomies'] && + ! get_post_meta( $story_id, 'fictioneer_story_no_tags', true ); // Story header classes $header_classes = []; -if ( ! $tax_shown ) $header_classes[] = '_no-tax'; + +if ( ! $tax_shown ) { + $header_classes[] = '_no-tax'; +} + if ( ! $thumbnail_shown ) { $header_classes[] = '_no-thumbnail'; $header_classes[] = 'padding-top'; diff --git a/rss-rss-main.php b/rss-rss-main.php index 76d4fa2e..d00e4a64 100644 --- a/rss-rss-main.php +++ b/rss-rss-main.php @@ -27,14 +27,14 @@ $posts = get_posts( $posts = array_filter( $posts, function ( $post ) { // Chapter hidden? if ( $post->post_type === 'fcn_chapter' ) { - $chapter_hidden = fictioneer_get_field( 'fictioneer_chapter_hidden', $post->ID ); + $chapter_hidden = get_post_meta( $post->ID, 'fictioneer_chapter_hidden', true ); return empty( $chapter_hidden ) || $chapter_hidden === '0'; } // Story hidden? if ( $post->post_type === 'fcn_story' ) { - $story_hidden = fictioneer_get_field( 'fictioneer_story_hidden', $post->ID ); + $story_hidden = get_post_meta( $post->ID, 'fictioneer_story_hidden', true ); return empty( $story_hidden ) || $story_hidden === '0'; } diff --git a/rss-rss-story.php b/rss-rss-story.php index d580cff1..658fc1e4 100644 --- a/rss-rss-story.php +++ b/rss-rss-story.php @@ -15,7 +15,7 @@ // Get ID from parameter $story_id = fictioneer_validate_id( $_GET[ 'story_id' ] ?? 0, 'fcn_story' ); -$is_hidden = fictioneer_get_field( 'fictioneer_story_hidden', $story_id ?: 0 ) ?: 0; +$is_hidden = get_post_meta( $story_id ?: 0, 'fictioneer_story_hidden', true ); // Abort if not a valid story ID or password protected if ( ! $story_id || $is_hidden || post_password_required( $story_id ) ) { @@ -25,7 +25,8 @@ 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_field( 'fictioneer_story_chapters', $story_id ); +$chapters = get_post_meta( $story_id, 'fictioneer_story_chapters', true ); +$chapters = is_array( $chapters ) ? $chapters : []; // Feed title $title = sprintf( @@ -154,7 +155,7 @@ do_action( 'rss_tag_pre', 'rss2' ); } // Skip invisible chapters - if ( fictioneer_get_field( 'fictioneer_chapter_hidden' ) ) { + if ( get_post_meta( get_the_ID(), 'fictioneer_chapter_hidden', true ) ) { continue; } diff --git a/single-fcn_chapter.php b/single-fcn_chapter.php index ece27480..36e756eb 100644 --- a/single-fcn_chapter.php +++ b/single-fcn_chapter.php @@ -14,12 +14,11 @@ 'fcn_chapter' ); -if ( ! empty( $is_hidden ) ) { +if ( get_post_meta( get_the_ID(), 'fictioneer_chapter_hidden', true ) ) { $header_args['no_index'] = true; } @@ -47,7 +46,7 @@ get_header( null, $header_args ); $title = fictioneer_get_safe_title( get_the_ID() ); $this_breadcrumb = [$title, get_the_permalink()]; - $story_id = fictioneer_get_field( 'fictioneer_chapter_story', get_queried_object_id() ); + $story_id = get_post_meta( get_the_ID(), 'fictioneer_chapter_story', true ); $story_data = null; $story_post = null; @@ -91,7 +90,7 @@ get_header( null, $header_args ); if ( get_option( 'fictioneer_enable_bookmarks' ) ) { // Bookmark data $bookmark_story_title = ''; - $bookmark_title = fictioneer_get_field( 'fictioneer_chapter_list_title' ); + $bookmark_title = get_post_meta( get_the_ID(), 'fictioneer_chapter_list_title', true ); $bookmark_title = trim( wp_strip_all_tags( $bookmark_title ) ); $bookmark_title = $bookmark_title ?: $title; $bookmark_thumbnail = get_the_post_thumbnail_url( null, 'snippet' ); @@ -146,7 +145,7 @@ get_header( null, $header_args ); do_action( 'fictioneer_chapter_after_header', $hook_args ); // Password note - $password_note = fictioneer_get_content_field( 'fictioneer_chapter_password_note' ); + $password_note = fictioneer_get_content_field( 'fictioneer_chapter_password_note', get_the_ID() ); ?>
diff --git a/single-fcn_collection.php b/single-fcn_collection.php index cb6b7867..d8b01a24 100644 --- a/single-fcn_collection.php +++ b/single-fcn_collection.php @@ -33,8 +33,8 @@ get_header( null, array( 'type' => 'fcn_collection' ) ); ID ); $this_breadcrumb = [$title, get_the_permalink()]; $current_page = max( 1, get_query_var( 'pg', 1 ) ?: 1 ); // Paged not available @@ -57,8 +57,8 @@ get_header( null, array( 'type' => 'fcn_collection' ) ); foreach ( $raw_query->posts as $raw_post ) { if ( - fictioneer_get_field( 'fictioneer_story_hidden', $raw_post->ID ) || - fictioneer_get_field( 'fictioneer_chapter_hidden', $raw_post->ID ) + get_post_meta( $raw_post->ID, 'fictioneer_story_hidden', true ) || + get_post_meta( $raw_post->ID, 'fictioneer_chapter_hidden', true ) ) { continue; } diff --git a/single-fcn_story.php b/single-fcn_story.php index 73e2991f..bec32fb0 100644 --- a/single-fcn_story.php +++ b/single-fcn_story.php @@ -15,12 +15,11 @@ 'fcn_story' ); -if ( ! empty( $is_hidden ) ) { +if ( get_post_meta( get_the_ID(), 'fictioneer_story_hidden', true ) ) { $header_args['no_index'] = true; } @@ -43,7 +42,7 @@ get_header( null, $header_args ); $story = fictioneer_get_story_data( $post->ID ); $epub_name = sanitize_file_name( strtolower( get_the_title() ) ); $this_breadcrumb = [$story['title'], get_the_permalink()]; - $password_note = fictioneer_get_content_field( 'fictioneer_story_password_note' ); + $password_note = fictioneer_get_content_field( 'fictioneer_story_password_note', $post->ID ); // Flags $can_checkmarks = get_option( 'fictioneer_enable_checkmarks' );