diff --git a/INSTALLATION.md b/INSTALLATION.md index f043b04a..8166f32a 100644 --- a/INSTALLATION.md +++ b/INSTALLATION.md @@ -1245,12 +1245,4 @@ define( 'CONSTANT_NAME', value ); | FICTIONEER_ORDER_STORIES_BY_LATEST_CHAPTER | boolean | Whether to order updated stories based on the latest chapter added, excluding stories without chapters. Default `false`. | FICTIONEER_ENABLE_STORY_CHANGELOG | boolean | Whether changes to the story chapter list should be logged. Default `true`. | FICTIONEER_ENABLE_BROWSER_NOTES | boolean | Whether to inform visitors of missing browser features. Default `true`. -| FICTIONEER_EXTEND_STORY_META_QUERY | boolean | Whether to use the extended meta query for stories. Default `true`. -| FICTIONEER_EXTEND_CHAPTER_META_QUERY | boolean | Whether to use the extended meta query for chapters. Default `true`. | FICTIONEER_EXAMPLE_CHAPTER_ICONS | array | Collection of example Font Awesome icon class strings. - -#### FICTIONEER_EXTEND_STORY_META_QUERY & FICTIONEER_EXTEND_CHAPTER_META_QUERY - -These two constants technically make querying **lists** of stories and chapters slower, in exchange for keeping your database smaller. This is a long-lasting grievance with WordPress queries, which exclude posts that lack requested meta fields even if they evaluate to false. Accounting for that is expensive, but saving those otherwise superfluous meta fields can add thousands of rows to your database, slowing down your site as well. This is a tradeoff and if you have proper caching, the impact is negligible. - -If you would rather have faster queries but store more rows in your database, you can set these constants to `false`. Once you have done this, head to **Fictioneer > Tools > Database Tools** and add the missing **[Story Hidden]** and **[Chapter Hidden]** fields, otherwise your lists will be empty. Also purge the theme caches. Anything else is taken care of by the theme, like allowing the fields to be stored in the future. diff --git a/chapters.php b/chapters.php index bf86ace9..990d39b1 100644 --- a/chapters.php +++ b/chapters.php @@ -37,7 +37,14 @@ $query_args = array( ); // Use extended meta query? -if ( FICTIONEER_EXTEND_CHAPTER_META_QUERY ) { +if ( get_option( 'fictioneer_disable_extended_chapter_list_meta_queries' ) ) { + $query_args['meta_query'] = array( + array( + 'key' => 'fictioneer_chapter_hidden', + 'value' => '0' + ) + ); +} else { $query_args['meta_query'] = array( 'relation' => 'OR', array( @@ -49,13 +56,6 @@ if ( FICTIONEER_EXTEND_CHAPTER_META_QUERY ) { 'compare' => 'NOT EXISTS' ) ); -} else { - $query_args['meta_query'] = array( - array( - 'key' => 'fictioneer_chapter_hidden', - 'value' => '0' - ) - ); } // Append date query (if any) diff --git a/functions.php b/functions.php index 628bcf39..d42ffbd2 100644 --- a/functions.php +++ b/functions.php @@ -381,16 +381,6 @@ if ( ! defined( 'FICTIONEER_ENABLE_BROWSER_NOTES' ) ) { define( 'FICTIONEER_ENABLE_BROWSER_NOTES', true ); } -// Boolean: Enable extended story meta query -if ( ! defined( 'FICTIONEER_EXTEND_STORY_META_QUERY' ) ) { - define( 'FICTIONEER_EXTEND_STORY_META_QUERY', true ); -} - -// Boolean: Enable extended chapter meta query -if ( ! defined( 'FICTIONEER_EXTEND_CHAPTER_META_QUERY' ) ) { - define( 'FICTIONEER_EXTEND_CHAPTER_META_QUERY', true ); -} - /* * Arrays */ diff --git a/includes/functions/_query_helpers.php b/includes/functions/_query_helpers.php index 7f94d2d2..68b1b335 100644 --- a/includes/functions/_query_helpers.php +++ b/includes/functions/_query_helpers.php @@ -332,7 +332,7 @@ function fictioneer_allow_falsy_chapter_hidden( $allowed ) { return $allowed; } -if ( ! FICTIONEER_EXTEND_CHAPTER_META_QUERY ) { +if ( get_option( 'fictioneer_disable_extended_chapter_list_meta_queries' ) ) { add_filter( 'fictioneer_filter_falsy_meta_allow_list', 'fictioneer_allow_falsy_chapter_hidden' ); } @@ -351,7 +351,7 @@ function fictioneer_allow_falsy_story_hidden( $allowed ) { return $allowed; } -if ( ! FICTIONEER_EXTEND_STORY_META_QUERY ) { +if ( get_option( 'fictioneer_disable_extended_story_list_meta_queries' ) ) { add_filter( 'fictioneer_filter_falsy_meta_allow_list', 'fictioneer_allow_falsy_story_hidden' ); } diff --git a/includes/functions/settings/_register_settings.php b/includes/functions/settings/_register_settings.php index 7dc92612..393ae047 100644 --- a/includes/functions/settings/_register_settings.php +++ b/includes/functions/settings/_register_settings.php @@ -663,6 +663,20 @@ define( 'FICTIONEER_OPTIONS', array( 'sanitize_callback' => 'fictioneer_sanitize_checkbox', 'label' => __( 'Enable age confirmation modal for posts', 'fictioneer' ), 'default' => 0 + ), + 'fictioneer_disable_extended_story_list_meta_queries' => array( + 'name' => 'fictioneer_disable_extended_story_list_meta_queries', + 'group' => 'fictioneer-settings-general-group', + 'sanitize_callback' => 'fictioneer_sanitize_checkbox', + 'label' => __( 'Disable extended story list meta queries', 'fictioneer' ), + 'default' => 0 + ), + 'fictioneer_disable_extended_chapter_list_meta_queries' => array( + 'name' => 'fictioneer_disable_extended_chapter_list_meta_queries', + 'group' => 'fictioneer-settings-general-group', + 'sanitize_callback' => 'fictioneer_sanitize_checkbox', + 'label' => __( 'Disable extended chapter list meta queries', 'fictioneer' ), + 'default' => 0 ) ), 'integers' => array( diff --git a/includes/functions/settings/_settings_page_general.php b/includes/functions/settings/_settings_page_general.php index edb0971f..b284cee6 100644 --- a/includes/functions/settings/_settings_page_general.php +++ b/includes/functions/settings/_settings_page_general.php @@ -719,6 +719,24 @@ ?> +
+ [Story Hidden] fields under Tools > Database Tools afterwards.', 'fictioneer' ) + ); + ?> +
+ +
+ [Chapter Hidden] fields under Tools > Database Tools afterwards.', 'fictioneer' ) + ); + ?> +
+ diff --git a/partials/_latest-chapters-compact.php b/partials/_latest-chapters-compact.php index 5529975c..06100a26 100644 --- a/partials/_latest-chapters-compact.php +++ b/partials/_latest-chapters-compact.php @@ -49,7 +49,14 @@ $query_args = array( ); // Use extended meta query? -if ( FICTIONEER_EXTEND_CHAPTER_META_QUERY ) { +if ( get_option( 'fictioneer_disable_extended_chapter_list_meta_queries' ) ) { + $query_args['meta_query'] = array( + array( + 'key' => 'fictioneer_chapter_hidden', + 'value' => '0' + ) + ); +} else { $query_args['meta_query'] = array( 'relation' => 'OR', array( @@ -61,13 +68,6 @@ if ( FICTIONEER_EXTEND_CHAPTER_META_QUERY ) { 'compare' => 'NOT EXISTS' ) ); -} else { - $query_args['meta_query'] = array( - array( - 'key' => 'fictioneer_chapter_hidden', - 'value' => '0' - ) - ); } // Author? diff --git a/partials/_latest-chapters.php b/partials/_latest-chapters.php index 741f9020..f4a4ab40 100644 --- a/partials/_latest-chapters.php +++ b/partials/_latest-chapters.php @@ -50,7 +50,14 @@ $query_args = array( ); // Use extended meta query? -if ( FICTIONEER_EXTEND_CHAPTER_META_QUERY ) { +if ( get_option( 'fictioneer_disable_extended_chapter_list_meta_queries' ) ) { + $query_args['meta_query'] = array( + array( + 'key' => 'fictioneer_chapter_hidden', + 'value' => '0' + ) + ); +} else { $query_args['meta_query'] = array( 'relation' => 'OR', array( @@ -62,13 +69,6 @@ if ( FICTIONEER_EXTEND_CHAPTER_META_QUERY ) { 'compare' => 'NOT EXISTS' ) ); -} else { - $query_args['meta_query'] = array( - array( - 'key' => 'fictioneer_chapter_hidden', - 'value' => '0' - ) - ); } // Author? diff --git a/partials/_latest-stories-compact.php b/partials/_latest-stories-compact.php index bcdc7d4b..d2447a11 100644 --- a/partials/_latest-stories-compact.php +++ b/partials/_latest-stories-compact.php @@ -47,7 +47,14 @@ $query_args = array( ); // Use extended meta query? -if ( FICTIONEER_EXTEND_STORY_META_QUERY ) { +if ( get_option( 'fictioneer_disable_extended_story_list_meta_queries' ) ) { + $query_args['meta_query'] = array( + array( + 'key' => 'fictioneer_story_hidden', + 'value' => '0' + ) + ); +} else { $query_args['meta_query'] = array( 'relation' => 'OR', array( @@ -59,13 +66,6 @@ if ( FICTIONEER_EXTEND_STORY_META_QUERY ) { 'compare' => 'NOT EXISTS' ) ); -} else { - $query_args['meta_query'] = array( - array( - 'key' => 'fictioneer_story_hidden', - 'value' => '0' - ) - ); } // Author? diff --git a/partials/_latest-stories.php b/partials/_latest-stories.php index ffb002a7..512c249f 100644 --- a/partials/_latest-stories.php +++ b/partials/_latest-stories.php @@ -44,7 +44,14 @@ $query_args = array( ); // Use extended meta query? -if ( FICTIONEER_EXTEND_STORY_META_QUERY ) { +if ( get_option( 'fictioneer_disable_extended_story_list_meta_queries' ) ) { + $query_args['meta_query'] = array( + array( + 'key' => 'fictioneer_story_hidden', + 'value' => '0' + ) + ); +} else { $query_args['meta_query'] = array( 'relation' => 'OR', array( @@ -56,13 +63,6 @@ if ( FICTIONEER_EXTEND_STORY_META_QUERY ) { 'compare' => 'NOT EXISTS' ) ); -} else { - $query_args['meta_query'] = array( - array( - 'key' => 'fictioneer_story_hidden', - 'value' => '0' - ) - ); } // Author? diff --git a/partials/_latest-updates-compact.php b/partials/_latest-updates-compact.php index 01a0a485..962a5818 100644 --- a/partials/_latest-updates-compact.php +++ b/partials/_latest-updates-compact.php @@ -50,7 +50,14 @@ $query_args = array( ); // Use extended meta query? -if ( FICTIONEER_EXTEND_STORY_META_QUERY ) { +if ( get_option( 'fictioneer_disable_extended_story_list_meta_queries' ) ) { + $query_args['meta_query'] = array( + array( + 'key' => 'fictioneer_story_hidden', + 'value' => '0' + ) + ); +} else { $query_args['meta_query'] = array( 'relation' => 'OR', array( @@ -62,13 +69,6 @@ if ( FICTIONEER_EXTEND_STORY_META_QUERY ) { 'compare' => 'NOT EXISTS' ) ); -} else { - $query_args['meta_query'] = array( - array( - 'key' => 'fictioneer_story_hidden', - 'value' => '0' - ) - ); } // Author? diff --git a/partials/_latest-updates.php b/partials/_latest-updates.php index b17c1fa7..3d37eba9 100644 --- a/partials/_latest-updates.php +++ b/partials/_latest-updates.php @@ -51,7 +51,14 @@ $query_args = array( ); // Use extended meta query? -if ( FICTIONEER_EXTEND_STORY_META_QUERY ) { +if ( get_option( 'fictioneer_disable_extended_story_list_meta_queries' ) ) { + $query_args['meta_query'] = array( + array( + 'key' => 'fictioneer_story_hidden', + 'value' => '0' + ) + ); +} else { $query_args['meta_query'] = array( 'relation' => 'OR', array( @@ -63,13 +70,6 @@ if ( FICTIONEER_EXTEND_STORY_META_QUERY ) { 'compare' => 'NOT EXISTS' ) ); -} else { - $query_args['meta_query'] = array( - array( - 'key' => 'fictioneer_story_hidden', - 'value' => '0' - ) - ); } // Author? diff --git a/stories.php b/stories.php index d2cb359b..3245bfb4 100644 --- a/stories.php +++ b/stories.php @@ -38,7 +38,14 @@ $query_args = array ( ); // Use extended meta query? -if ( FICTIONEER_EXTEND_STORY_META_QUERY ) { +if ( get_option( 'fictioneer_disable_extended_story_list_meta_queries' ) ) { + $query_args['meta_query'] = array( + array( + 'key' => 'fictioneer_story_hidden', + 'value' => '0' + ) + ); +} else { $query_args['meta_query'] = array( 'relation' => 'OR', array( @@ -50,13 +57,6 @@ if ( FICTIONEER_EXTEND_STORY_META_QUERY ) { 'compare' => 'NOT EXISTS' ) ); -} else { - $query_args['meta_query'] = array( - array( - 'key' => 'fictioneer_story_hidden', - 'value' => '0' - ) - ); } // Order by latest chapter update timestamp?