Use fictioneer_get_field everwhere
I might actually remove it later on because it does not safe space anyway, but at least it is consistent for now.
This commit is contained in:
parent
25726ab3b0
commit
e0176eac59
@ -205,7 +205,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( get_post_meta( $chapter_id, '_word_count', true ) );
|
||||
$chapter['words'] = intval( fictioneer_get_field( '_word_count', $chapter_id ) );
|
||||
$chapter['nonChapter'] = ! empty( $no_chapter );
|
||||
|
||||
if ( ! empty( $rating ) ) {
|
||||
|
@ -47,11 +47,11 @@ if ( ! function_exists( 'fictioneer_download_epub' ) ) {
|
||||
// Count downloads per ePUB version
|
||||
if ( $story_id ) {
|
||||
// Download counter(s)
|
||||
$downloads = get_post_meta( $story_id, 'fictioneer_epub_downloads', true );
|
||||
$downloads = fictioneer_get_field( 'fictioneer_epub_downloads', $story_id );
|
||||
$downloads = is_array( $downloads ) ? $downloads : [];
|
||||
|
||||
// Generate version key based on timestamp
|
||||
$key = md5( get_post_meta( $story_id, 'fictioneer_epub_timestamp', true ) );
|
||||
$key = md5( fictioneer_get_field( 'fictioneer_epub_timestamp', $story_id ) );
|
||||
|
||||
// Is this version already tracked?
|
||||
$downloads[ $key ] = ( $downloads[ $key ] ?? 0 ) + 1;
|
||||
@ -1043,7 +1043,7 @@ function fictioneer_generate_epub() {
|
||||
$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 = get_post_meta( $story_id, 'fictioneer_epub_timestamp', true );
|
||||
$epub_last_built = fictioneer_get_field( 'fictioneer_epub_timestamp', $story_id );
|
||||
$toc_list = [];
|
||||
$ncx_list = [];
|
||||
$opf_list = [];
|
||||
|
@ -54,7 +54,7 @@ function fictioneer_get_metabox_checkbox( $post, $meta_key, $label, $args = [] )
|
||||
|
||||
<div class="fictioneer-meta-checkbox__checkbox">
|
||||
<input type="hidden" name="<?php echo $meta_key; ?>" value="0" autocomplete="off">
|
||||
<input type="checkbox" id="<?php echo $meta_key; ?>" name="<?php echo $meta_key; ?>" value="1" autocomplete="off" <?php checked( get_post_meta( $post->ID, $meta_key, true ), 1 ); ?> <?php echo $attributes; ?> <?php echo $required; ?>>
|
||||
<input type="checkbox" id="<?php echo $meta_key; ?>" name="<?php echo $meta_key; ?>" value="1" autocomplete="off" <?php checked( fictioneer_get_field( $meta_key, $post->ID ), 1 ); ?> <?php echo $attributes; ?> <?php echo $required; ?>>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" focusable="false"><path d="M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"></path></svg>
|
||||
</div>
|
||||
|
||||
@ -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( get_post_meta( $post->ID, $meta_key, true ) );
|
||||
$meta_value = esc_attr( fictioneer_get_field( $meta_key, $post->ID ) );
|
||||
$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( get_post_meta( $post->ID, $meta_key, true ) );
|
||||
$meta_value = esc_attr( fictioneer_get_field( $meta_key, $post->ID ) );
|
||||
$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 = get_post_meta( $post->ID, $meta_key, true );
|
||||
$array = fictioneer_get_field( $meta_key, $post->ID );
|
||||
$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 = get_post_meta( $post->ID, $meta_key, true );
|
||||
$selected = absint( fictioneer_get_field( $meta_key, $post->ID ) );
|
||||
$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 = get_post_meta( $post->ID, $meta_key, true );
|
||||
$meta_value = fictioneer_get_field( $meta_key, $post->ID );
|
||||
$label = strval( $args['label'] ?? '' );
|
||||
$description = strval( $args['description'] ?? '' );
|
||||
$placeholder = strval( $args['placeholder'] ?? '' );
|
||||
@ -366,14 +366,13 @@ function fictioneer_get_metabox_textarea( $post, $meta_key, $args = [] ) {
|
||||
|
||||
function fictioneer_get_metabox_image( $post, $meta_key, $args = [] ) {
|
||||
// Setup
|
||||
$meta_value = get_post_meta( $post->ID, $meta_key, true );
|
||||
$meta_value = fictioneer_get_field( $meta_key, $post->ID );
|
||||
$label = strval( $args['label'] ?? '' );
|
||||
$description = strval( $args['description'] ?? '' );
|
||||
$upload = strval( $args['button'] ?? _x( 'Set image', 'Metabox image upload button.', 'fictioneer' ) );
|
||||
$replace = _x( 'Replace', 'Metabox image upload button.', 'fictioneer' );
|
||||
$remove = _x( 'Remove', 'Metabox image remove button.', 'fictioneer' );
|
||||
$image_id = get_post_meta( $post->ID, $meta_key, true );
|
||||
$image_url = wp_get_attachment_url( $image_id );
|
||||
$image_url = wp_get_attachment_url( $meta_value );
|
||||
$image_css = $image_url ? "style='background-image: url(\"{$image_url}\");'" : '';
|
||||
|
||||
ob_start();
|
||||
@ -426,7 +425,7 @@ function fictioneer_get_metabox_image( $post, $meta_key, $args = [] ) {
|
||||
|
||||
function fictioneer_get_metabox_ebook( $post, $meta_key, $args = [] ) {
|
||||
// Setup
|
||||
$meta_value = get_post_meta( $post->ID, $meta_key, true );
|
||||
$meta_value = fictioneer_get_field( $meta_key, $post->ID );
|
||||
$file_path = get_attached_file( $meta_value );
|
||||
$label = strval( $args['label'] ?? '' );
|
||||
$description = strval( $args['description'] ?? '' );
|
||||
@ -524,7 +523,7 @@ function fictioneer_get_metabox_ebook( $post, $meta_key, $args = [] ) {
|
||||
|
||||
function fictioneer_get_metabox_tokens( $post, $meta_key, $options, $args = [] ) {
|
||||
// Setup
|
||||
$array = get_post_meta( $post->ID, $meta_key, true );
|
||||
$array = fictioneer_get_field( $meta_key, $post->ID );
|
||||
$array = is_array( $array ) ? $array : [];
|
||||
$list = esc_attr( implode( ', ', $array ) );
|
||||
$label = strval( $args['label'] ?? '' );
|
||||
@ -596,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( get_post_meta( $post->ID, $meta_key, true ) );
|
||||
$meta_value = esc_attr( fictioneer_get_field( $meta_key, $post->ID ) );
|
||||
$label = strval( $args['label'] ?? '' );
|
||||
$description = strval( $args['description'] ?? '' );
|
||||
$placeholder = strval( $args['placeholder'] ?? '' );
|
||||
@ -668,7 +667,7 @@ function fictioneer_get_metabox_icons( $post, $meta_key, $args = [] ) {
|
||||
|
||||
function fictioneer_get_metabox_editor( $post, $meta_key, $args = [] ) {
|
||||
// Setup
|
||||
$meta_value = get_post_meta( $post->ID, $meta_key, true );
|
||||
$meta_value = fictioneer_get_field( $meta_key, $post->ID );
|
||||
$label = strval( $args['label'] ?? '' );
|
||||
$description = strval( $args['description'] ?? '' );
|
||||
$required = ( $args['required'] ?? 0 ) ? 'required' : '';
|
||||
@ -963,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 ( get_post_meta( $chapter->ID, 'fictioneer_chapter_hidden', true ) ) {
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_hidden', $chapter->ID ) ) {
|
||||
$title = "{$title} (" . _x( 'Unlisted', 'Chapter assignment flag.', 'fictioneer' ) . ")";
|
||||
}
|
||||
|
||||
@ -1052,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 ( get_post_meta( $chapter->ID, 'fictioneer_chapter_hidden', true ) ) {
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_hidden', $chapter->ID ) ) {
|
||||
$title = "{$title} (" . _x( 'Unlisted', 'Chapter assignment flag.', 'fictioneer' ) . ")";
|
||||
}
|
||||
|
||||
@ -1130,11 +1129,11 @@ function fictioneer_get_relationship_chapter_details( $chapter ) {
|
||||
// Build
|
||||
$info[] = empty( $text_icon ) ? sprintf( '<i class="%s"></i>', $icon ) : "<strong>{$text_icon}</strong>";
|
||||
|
||||
if ( get_post_meta( $chapter->ID, 'fictioneer_chapter_hidden', true ) ) {
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_hidden', $chapter->ID ) ) {
|
||||
$flags[] = _x( 'Unlisted', 'Chapter assignment flag.', 'fictioneer' );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $chapter->ID, 'fictioneer_chapter_no_chapter', true ) ) {
|
||||
if ( fictioneer_get_field( 'fictioneer_chapter_no_chapter', $chapter->ID ) ) {
|
||||
$flags[] = _x( 'No Chapter', 'Chapter assignment flag.', 'fictioneer' );
|
||||
}
|
||||
|
||||
@ -1906,7 +1905,8 @@ function fictioneer_render_story_data_metabox( $post ) {
|
||||
);
|
||||
|
||||
// Chapters
|
||||
$chapter_ids = get_post_meta( $post->ID, 'fictioneer_story_chapters', true ) ?: [];
|
||||
$chapter_ids = fictioneer_get_field( 'fictioneer_story_chapters', $post->ID ) ?: [];
|
||||
$chapter_ids = is_array( $chapter_ids ) ? $chapter_ids : [];
|
||||
$chapters = empty( $chapter_ids ) ? [] : get_posts(
|
||||
array(
|
||||
'post_type' => 'fcn_chapter',
|
||||
@ -1936,7 +1936,8 @@ 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 = get_post_meta( $post->ID, 'fictioneer_story_custom_pages', true ) ?: [];
|
||||
$page_ids = fictioneer_get_field( 'fictioneer_story_custom_pages', $post->ID ) ?: [];
|
||||
$page_ids = is_array( $page_ids ) ? $page_ids : [];
|
||||
$pages = empty( $page_ids ) ? [] : get_posts(
|
||||
array(
|
||||
'post_type' => 'page',
|
||||
@ -2567,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 = get_post_meta( $post->ID, 'fictioneer_chapter_story', true );
|
||||
$current_story_id = fictioneer_get_field( 'fictioneer_chapter_story', $post->ID );
|
||||
$output = [];
|
||||
|
||||
// --- Add fields ------------------------------------------------------------
|
||||
@ -2843,8 +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 = get_post_meta( $post_id, 'fictioneer_chapter_story', true );
|
||||
$current_story_id = absint( $current_story_id );
|
||||
$current_story_id = absint( fictioneer_get_field( 'fictioneer_chapter_story', $post_id ) );
|
||||
|
||||
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 = get_post_meta( $story_id, 'fictioneer_story_chapters', true );
|
||||
$story_chapters = fictioneer_get_field( 'fictioneer_story_chapters', $story_id );
|
||||
|
||||
// Prepare chapter array if null (or broken)
|
||||
if ( ! is_array( $story_chapters ) ) {
|
||||
@ -3483,7 +3483,8 @@ function fictioneer_render_featured_content_metabox( $post ) {
|
||||
// --- Add fields --------------------------------------------------------------
|
||||
|
||||
// Featured items
|
||||
$item_ids = get_post_meta( $post->ID, 'fictioneer_post_featured', true ) ?: [];
|
||||
$item_ids = fictioneer_get_field( 'fictioneer_post_featured', $post->ID ) ?: [];
|
||||
$item_ids = is_array( $item_ids ) ? $item_ids : [];
|
||||
$items = empty( $item_ids ) ? [] : get_posts(
|
||||
array(
|
||||
'post_type' => ['post', 'fcn_story', 'fcn_chapter', 'fcn_collection', 'fcn_recommendation'],
|
||||
@ -3714,7 +3715,8 @@ function fictioneer_render_collection_data_metabox( $post ) {
|
||||
);
|
||||
|
||||
// Collection items
|
||||
$item_ids = get_post_meta( $post->ID, 'fictioneer_collection_items', true ) ?: [];
|
||||
$item_ids = fictioneer_get_field( 'fictioneer_collection_items', $post->ID ) ?: [];
|
||||
$item_ids = is_array( $item_ids ) ? $item_ids : [];
|
||||
$items = empty( $item_ids ) ? [] : get_posts(
|
||||
array(
|
||||
'post_type' => ['post', 'page', 'fcn_story', 'fcn_chapter', 'fcn_collection', 'fcn_recommendation'],
|
||||
|
@ -122,7 +122,7 @@ add_action( 'save_post', 'fictioneer_store_original_publish_date', 10, 2 );
|
||||
|
||||
function fictioneer_get_story_changelog( $story_id ) {
|
||||
// Setup
|
||||
$changelog = get_post_meta( $story_id, 'fictioneer_story_changelog', true );
|
||||
$changelog = fictioneer_get_field( 'fictioneer_story_changelog', $story_id );
|
||||
$changelog = is_array( $changelog ) ? $changelog : [];
|
||||
|
||||
// Initialize
|
||||
|
@ -324,7 +324,7 @@ function fictioneer_output_schemas( $post_id = null ) {
|
||||
|
||||
// Setup
|
||||
$post_id = empty( $post_id ) ? get_queried_object_id() : $post_id;
|
||||
$schema = get_post_meta( $post_id, 'fictioneer_schema', true ) ?? false;
|
||||
$schema = fictioneer_get_field( 'fictioneer_schema', $post_id );
|
||||
|
||||
// No schema found...
|
||||
if ( ! $schema ) {
|
||||
|
@ -54,16 +54,16 @@ if ( ! function_exists( 'fictioneer_seo_fields' ) ) {
|
||||
|
||||
function fictioneer_seo_fields( $post ) {
|
||||
// Title
|
||||
$seo_title = get_post_meta( $post->ID, 'fictioneer_seo_title', true ) ?: '';
|
||||
$seo_title = fictioneer_get_field( 'fictioneer_seo_title', $post->ID ) ?: '';
|
||||
$seo_title_placeholder = fictioneer_get_safe_title( $post->ID );
|
||||
|
||||
// Description (truncated if necessary)
|
||||
$seo_description = get_post_meta( $post->ID, 'fictioneer_seo_description', true ) ?: '';
|
||||
$seo_description = fictioneer_get_field( 'fictioneer_seo_description', $post->ID ) ?: '';
|
||||
$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 = get_post_meta( $post->ID, 'fictioneer_seo_og_image', true );
|
||||
$seo_og_image = fictioneer_get_field( 'fictioneer_seo_og_image', $post->ID );
|
||||
$seo_og_image_display = wp_get_attachment_url( $seo_og_image );
|
||||
$image_source = '';
|
||||
|
||||
@ -305,14 +305,14 @@ if ( ! function_exists( 'fictioneer_get_seo_title' ) ) {
|
||||
}
|
||||
|
||||
// Cached title?
|
||||
$cache = get_post_meta( $post_id, 'fictioneer_seo_title_cache', true );
|
||||
$cache = fictioneer_get_field( 'fictioneer_seo_title_cache', $post_id );
|
||||
|
||||
if ( ! empty( $cache ) && ! $skip_cache ) {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
// Start building...
|
||||
$seo_title = get_post_meta( $post_id, 'fictioneer_seo_title', true );
|
||||
$seo_title = fictioneer_get_field( 'fictioneer_seo_title', $post_id );
|
||||
$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 = get_post_meta( $post_id, 'fictioneer_seo_description_cache', true );
|
||||
$cache = fictioneer_get_field( 'fictioneer_seo_description_cache', $post_id );
|
||||
|
||||
if ( ! empty( $cache ) && ! $skip_cache ) {
|
||||
return $cache;
|
||||
}
|
||||
|
||||
// Start building...
|
||||
$seo_description = get_post_meta( $post_id, 'fictioneer_seo_description', true );
|
||||
$seo_description = fictioneer_get_field( 'fictioneer_seo_description', $post_id );
|
||||
$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 );
|
||||
@ -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 = get_post_meta( $post_id, 'fictioneer_seo_og_image_cache', true );
|
||||
$cache = fictioneer_get_field( 'fictioneer_seo_og_image_cache', $post_id );
|
||||
|
||||
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 = get_post_meta( $post_id, 'fictioneer_seo_og_image', true );
|
||||
$image_id = fictioneer_get_field( 'fictioneer_seo_og_image', $post_id );
|
||||
$image_id = wp_attachment_is_image( $image_id ) ? $image_id : false;
|
||||
}
|
||||
|
||||
|
@ -1003,7 +1003,7 @@ function fictioneer_shortcode_chapter_list( $attr ) {
|
||||
$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 = get_post_meta( $chapter_id, '_word_count', true );
|
||||
$words = fictioneer_get_field( '_word_count', $chapter_id );
|
||||
$title = fictioneer_get_safe_title( $chapter_id );
|
||||
|
||||
// Start HTML ---> ?>
|
||||
|
@ -190,7 +190,7 @@ if ( ! function_exists( 'fictioneer_get_story_data' ) ) {
|
||||
|
||||
// Check cache
|
||||
if ( FICTIONEER_ENABLE_STORY_DATA_META_CACHE ) {
|
||||
$old_data = get_post_meta( $story_id, 'fictioneer_story_data_collection', true );
|
||||
$old_data = fictioneer_get_field( 'fictioneer_story_data_collection', $story_id );
|
||||
}
|
||||
|
||||
if ( ! empty( $old_data ) && $old_data['last_modified'] >= get_the_modified_time( 'U', $story_id ) ) {
|
||||
@ -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 = get_post_meta( $post->ID, 'fictioneer_story_hidden', true );
|
||||
$story_hidden = fictioneer_get_field( 'fictioneer_story_hidden', $post->ID );
|
||||
|
||||
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 = get_post_meta( $post->ID, 'fictioneer_chapter_hidden', true );
|
||||
$chapter_hidden = fictioneer_get_field( 'fictioneer_chapter_hidden', $post->ID );
|
||||
$not_hidden = empty( $chapter_hidden ) || $chapter_hidden === '0';
|
||||
|
||||
// Not a chapter?
|
||||
$no_chapter = get_post_meta( $post->ID, 'fictioneer_chapter_no_chapter', true );
|
||||
$no_chapter = fictioneer_get_field( 'fictioneer_chapter_no_chapter', $post->ID );
|
||||
$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) get_post_meta( $chapter->ID, '_word_count', true );
|
||||
$word_count += (int) fictioneer_get_field( '_word_count', $chapter->ID );
|
||||
$comment_count += get_comments_number( $chapter );
|
||||
}
|
||||
|
||||
@ -793,7 +793,7 @@ if ( ! function_exists( 'fictioneer_is_editor' ) ) {
|
||||
|
||||
if ( ! function_exists( 'fictioneer_get_field' ) ) {
|
||||
/**
|
||||
* Wrapper for get_post_meta
|
||||
* Wrapper for get_post_meta with single value return
|
||||
*
|
||||
* @since Fictioneer 5.0
|
||||
*
|
||||
@ -806,8 +806,7 @@ if ( ! function_exists( 'fictioneer_get_field' ) ) {
|
||||
|
||||
function fictioneer_get_field( $field, $post_id = null ) {
|
||||
// Setup
|
||||
$post_id = absint( $post_id );
|
||||
$post_id = $post_id ? $post_id : get_the_ID();
|
||||
$post_id = $post_id ? absint( $post_id ) : get_the_ID();
|
||||
|
||||
// Retrieve post meta
|
||||
return get_post_meta( $post_id, $field, true );
|
||||
|
@ -65,7 +65,7 @@ if ( ! function_exists( 'fictioneer_build_chapter_schema' ) ) {
|
||||
$schema = fictioneer_get_schema_node_root();
|
||||
$story_id = fictioneer_get_field( 'fictioneer_chapter_story', $post_id );
|
||||
$image_data = fictioneer_get_schema_primary_image( $post_id );
|
||||
$word_count = intval( get_post_meta( $post_id, '_word_count', true ) );
|
||||
$word_count = intval( fictioneer_get_field( '_word_count', $post_id ) );
|
||||
$page_description = fictioneer_get_seo_description( $post_id );
|
||||
$page_title = fictioneer_get_seo_title( $post_id, array( 'skip_cache' => true ) );
|
||||
|
||||
|
@ -91,11 +91,11 @@ if ( ! function_exists( 'fictioneer_build_chapters_schema' ) ) {
|
||||
// Filter out invalid chapters (faster than meta query)
|
||||
$list = array_filter( $list, function ( $post ) {
|
||||
// Chapter hidden?
|
||||
$chapter_hidden = get_post_meta( $post->ID, 'fictioneer_chapter_hidden', true );
|
||||
$chapter_hidden = fictioneer_get_field( 'fictioneer_chapter_hidden', $post->ID );
|
||||
$not_hidden = empty( $chapter_hidden ) || $chapter_hidden === '0';
|
||||
|
||||
// Not a chapter?
|
||||
$no_chapter = get_post_meta( $post->ID, 'fictioneer_chapter_no_chapter', true );
|
||||
$no_chapter = fictioneer_get_field('fictioneer_chapter_no_chapter', $post->ID );
|
||||
$is_chapter = empty( $no_chapter ) || $no_chapter === '0';
|
||||
|
||||
// Only keep if both conditions are met
|
||||
|
@ -91,7 +91,7 @@ if ( ! function_exists( 'fictioneer_build_stories_schema' ) ) {
|
||||
// Filter out invalid chapters (faster than meta query)
|
||||
$list = array_filter( $list, function ( $post ) {
|
||||
// Chapter hidden?
|
||||
$story_hidden = get_post_meta( $post->ID, 'fictioneer_story_hidden', true );
|
||||
$story_hidden = fictioneer_get_field( 'fictioneer_story_hidden', $post->ID );
|
||||
return empty( $story_hidden ) || $story_hidden === '0';
|
||||
});
|
||||
|
||||
|
@ -104,7 +104,7 @@ class Fictioneer_Epubs_Table extends WP_List_Table {
|
||||
|
||||
if ( $story ) {
|
||||
$story_data = fictioneer_get_story_data( $story->ID, false );
|
||||
$download_stats = get_post_meta( $story->ID, 'fictioneer_epub_downloads', true );
|
||||
$download_stats = fictioneer_get_field( 'fictioneer_epub_downloads', $story->ID );
|
||||
$download_stats = is_array( $download_stats ) ? $download_stats : [0];
|
||||
$downloads_version = end( $download_stats );
|
||||
$downloads_total = array_sum( $download_stats );
|
||||
|
@ -76,12 +76,12 @@ class Fictioneer_Seo_Table extends WP_List_Table {
|
||||
}
|
||||
|
||||
public function column_default( $item, $column_name ) {
|
||||
$schema = get_post_meta( $item->ID, 'fictioneer_schema', true );
|
||||
$schema = fictioneer_get_field( 'fictioneer_schema', $item->ID );
|
||||
$schema_text = stripslashes( json_encode( json_decode( $schema ), JSON_PRETTY_PRINT ) );
|
||||
|
||||
switch ( $column_name ) {
|
||||
case 'title':
|
||||
$image = get_post_meta( $item->ID, 'fictioneer_seo_og_image_cache', true );
|
||||
$image = fictioneer_get_field( 'fictioneer_seo_og_image_cache', $item->ID );
|
||||
$image_url = $image ? $image['url'] : get_template_directory_uri() . '/img/no_image_placeholder.svg';
|
||||
$link = get_the_permalink( $item->ID );
|
||||
$title = mb_strimwidth( fictioneer_get_seo_title( $item->ID ), 0, 48, '…' );
|
||||
@ -131,7 +131,7 @@ class Fictioneer_Seo_Table extends WP_List_Table {
|
||||
$row_class = '';
|
||||
|
||||
// Setup
|
||||
$schema = get_post_meta( $item->ID, 'fictioneer_schema', true );
|
||||
$schema = fictioneer_get_field( 'fictioneer_schema', $item->ID );
|
||||
|
||||
// Add class or not
|
||||
if ( ! $schema ) {
|
||||
|
@ -251,7 +251,7 @@ if ( ! function_exists( 'fictioneer_query_followed_chapters' ) ) {
|
||||
// Filter out hidden chapters (faster than meta query, highly unlikely to eliminate all)
|
||||
$chapters = array_filter( $all_chapters, function ( $candidate ) {
|
||||
// Chapter hidden?
|
||||
$chapter_hidden = get_post_meta( $candidate->ID, 'fictioneer_chapter_hidden', true );
|
||||
$chapter_hidden = fictioneer_get_field( 'fictioneer_chapter_hidden', $candidate->ID );
|
||||
|
||||
// Only keep if not hidden
|
||||
return empty( $chapter_hidden ) || $chapter_hidden === '0';
|
||||
|
@ -191,7 +191,7 @@ $show_type = $args['show_type'] ?? false;
|
||||
|
||||
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
||||
esc_attr__( 'Words', 'fictioneer' ) . '"></i> ' .
|
||||
fictioneer_shorten_number( get_post_meta( get_the_ID(), '_word_count', true ) );
|
||||
fictioneer_shorten_number( fictioneer_get_field( '_word_count', get_the_ID() ) );
|
||||
|
||||
if ( ( $args['orderby'] ?? 0 ) === 'date' ) {
|
||||
$footer_items['publish_date'] = '<i class="card-footer-icon fa-solid fa-clock" title="' .
|
||||
|
@ -79,7 +79,7 @@ if ( ! empty( $items ) ) {
|
||||
case 'fcn_chapter':
|
||||
if ( ! in_array( $item->ID, $processed_ids ) ) {
|
||||
$chapter_count += 1;
|
||||
$word_count += (int) get_post_meta( $item->ID, '_word_count', true );
|
||||
$word_count += (int) fictioneer_get_field( '_word_count', $item->ID );
|
||||
$processed_ids[] = $item->ID;
|
||||
}
|
||||
break;
|
||||
@ -118,7 +118,7 @@ if ( ! empty( $items ) ) {
|
||||
|
||||
if ( ! in_array( $chapter->ID, $processed_ids ) ) {
|
||||
$chapter_count += 1;
|
||||
$word_count += (int) get_post_meta( $chapter->ID, '_word_count', true );
|
||||
$word_count += (int) fictioneer_get_field( '_word_count', $chapter->ID );
|
||||
$processed_ids[] = $chapter->ID;
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ $is_sticky = FICTIONEER_ENABLE_STICKY_CARDS &&
|
||||
<?php
|
||||
printf(
|
||||
'%1$s<span class="hide-below-480"> %2$s</span><span class="separator-dot"> • </span>%3$s',
|
||||
fictioneer_shorten_number( get_post_meta( $chapter->ID, '_word_count', true ) ),
|
||||
fictioneer_shorten_number( fictioneer_get_field( '_word_count', $chapter->ID ) ),
|
||||
__( 'Words', 'fictioneer' ),
|
||||
strtotime( '-1 days' ) < strtotime( get_the_date( '', $chapter->ID ) ) ?
|
||||
__( 'New', 'fictioneer' ) : get_the_time( FICTIONEER_CARD_STORY_LI_DATE, $chapter->ID )
|
||||
|
@ -180,7 +180,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
<?php
|
||||
printf(
|
||||
_x( '%1$s Words on %2$s', 'Small card: {n} Words on {Date}.', 'fictioneer' ),
|
||||
fictioneer_shorten_number( get_post_meta( $post->ID, '_word_count', true ) ),
|
||||
fictioneer_shorten_number( fictioneer_get_field( '_word_count', $post->ID ) ),
|
||||
get_the_time( FICTIONEER_LATEST_CHAPTERS_FOOTER_DATE )
|
||||
);
|
||||
?>
|
||||
|
@ -204,7 +204,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
|
||||
$footer_items['words'] = '<i class="card-footer-icon fa-solid fa-font" title="' .
|
||||
esc_attr__( 'Words', 'fictioneer' ) . '"></i> ' .
|
||||
fictioneer_shorten_number( get_post_meta( $post->ID, '_word_count', true ) );
|
||||
fictioneer_shorten_number( fictioneer_get_field( '_word_count', $post->ID ) );
|
||||
|
||||
if ( $args['orderby'] == 'modified' ) {
|
||||
$footer_items['modified_date'] = '<i class="card-footer-icon fa-regular fa-clock" title="' .
|
||||
|
@ -196,7 +196,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
</div>
|
||||
<div class="card__right">
|
||||
<?php
|
||||
echo fictioneer_shorten_number( get_post_meta( $chapter_id, '_word_count', true ) );
|
||||
echo fictioneer_shorten_number( fictioneer_get_field( '_word_count', $chapter_id ) );
|
||||
echo '<span class="separator-dot"> • </span>';
|
||||
echo get_the_date( FICTIONEER_LATEST_UPDATES_LI_DATE, $chapter_id )
|
||||
?>
|
||||
|
@ -193,7 +193,7 @@ remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
|
||||
</div>
|
||||
<div class="card__right">
|
||||
<?php
|
||||
echo fictioneer_shorten_number( get_post_meta( $chapter_id, '_word_count', true ) );
|
||||
echo fictioneer_shorten_number( fictioneer_get_field( '_word_count', $chapter_id ) );
|
||||
echo '<span class="separator-dot"> • </span>';
|
||||
echo get_the_date( FICTIONEER_LATEST_UPDATES_LI_DATE, $chapter_id )
|
||||
?>
|
||||
|
@ -204,7 +204,7 @@ $disable_folding = fictioneer_get_field( 'fictioneer_story_disable_collapse' );
|
||||
'prefix' => fictioneer_get_field( 'fictioneer_chapter_prefix' ),
|
||||
'title' => fictioneer_get_safe_title( $chapter_id ),
|
||||
'list_title' => fictioneer_get_field( 'fictioneer_chapter_list_title' ),
|
||||
'words' => get_post_meta( $chapter_id, '_word_count', true ),
|
||||
'words' => fictioneer_get_field( '_word_count', $chapter_id ),
|
||||
'warning' => fictioneer_get_field( 'fictioneer_chapter_warning' )
|
||||
);
|
||||
}
|
||||
|
@ -27,14 +27,14 @@ $posts = get_posts(
|
||||
$posts = array_filter( $posts, function ( $post ) {
|
||||
// Chapter hidden?
|
||||
if ( $post->post_type === 'fcn_chapter' ) {
|
||||
$chapter_hidden = get_post_meta( $post->ID, 'fictioneer_chapter_hidden', true );
|
||||
$chapter_hidden = fictioneer_get_field( 'fictioneer_chapter_hidden', $post->ID );
|
||||
|
||||
return empty( $chapter_hidden ) || $chapter_hidden === '0';
|
||||
}
|
||||
|
||||
// Story hidden?
|
||||
if ( $post->post_type === 'fcn_story' ) {
|
||||
$story_hidden = get_post_meta( $post->ID, 'fictioneer_story_hidden', true );
|
||||
$story_hidden = fictioneer_get_field( 'fictioneer_story_hidden', $post->ID );
|
||||
|
||||
return empty( $story_hidden ) || $story_hidden === '0';
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user