Add options for the extended meta queries
I think this should be easier to reach.
This commit is contained in:
parent
a35ebe7900
commit
e159b952f3
@ -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.
|
||||
|
16
chapters.php
16
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)
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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' );
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
@ -719,6 +719,24 @@
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="fictioneer-card__row">
|
||||
<?php
|
||||
fictioneer_settings_label_checkbox(
|
||||
'fictioneer_disable_extended_story_list_meta_queries',
|
||||
__( 'Faster, but increases your database. Add <strong>[Story Hidden]</strong> fields under <strong>Tools > Database Tools</strong> afterwards.', 'fictioneer' )
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
||||
<div class="fictioneer-card__row">
|
||||
<?php
|
||||
fictioneer_settings_label_checkbox(
|
||||
'fictioneer_disable_extended_chapter_list_meta_queries',
|
||||
__( 'Faster, but increases your database. Add <strong>[Chapter Hidden]</strong> fields under <strong>Tools > Database Tools</strong> afterwards.', 'fictioneer' )
|
||||
);
|
||||
?>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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?
|
||||
|
@ -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?
|
||||
|
@ -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?
|
||||
|
@ -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?
|
||||
|
@ -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?
|
||||
|
@ -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?
|
||||
|
16
stories.php
16
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?
|
||||
|
Loading…
x
Reference in New Issue
Block a user