Replace fictioneer_exclude_protected_posts()

This commit is contained in:
Tetrakern 2024-09-20 23:32:29 +02:00
parent 68ea6eaa78
commit 329a067da0
17 changed files with 15 additions and 83 deletions

View File

@ -359,7 +359,6 @@ Fictioneer customizes WordPress by using as many standard action and filter hook
| `post_password_required` | `fictioneer_bypass_password`, `fictioneer_expire_post_password`
| `post_stuck` | `fictioneer_prevent_post_sticky`
| `postbox_classes_{$screen_id}_{$box_id}` | `fictioneer_append_metabox_classes`
| `posts_where` | `fictioneer_exclude_protected_posts`
| `pre_comment_user_ip` | `__return_empty_string`
| `pre_get_posts` | `fictioneer_extend_taxonomy_pages`, `fictioneer_edit_others_fictioneer_posts`, `fictioneer_add_sof_to_taxonomy_query`
| `pre_insert_term` | `fictioneer_restrict_tag_creation`

View File

@ -245,28 +245,6 @@ if ( ! function_exists( 'fictioneer_append_date_query' ) ) {
}
}
// =============================================================================
// IGNORE PROTECTED POSTS FILTER
// =============================================================================
/**
* Filter to ignore protected posts
*
* Note: Filter is not added by default, only in certain places.
*
* @since 5.7.3
*
* @param string $where WHERE statement. Default empty string.
*
* @return string The updated WHERE statement.
*/
function fictioneer_exclude_protected_posts( $where = '' ) {
$where .= " AND post_password = ''";
return $where;
}
// =============================================================================
// STICKY STORIES
// =============================================================================

View File

@ -1570,7 +1570,7 @@ function fictioneer_shortcode_blog( $attr ) {
// Exclude protected
if ( $args['ignore_protected'] ) {
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
$query_args['has_password'] = false;
}
// Apply filters
@ -1590,9 +1590,6 @@ function fictioneer_shortcode_blog( $attr ) {
// Query
$blog_query = new WP_Query( $query_args );
// Remove temporary filters
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Prime author cache
if ( function_exists( 'update_post_author_caches' ) ) {
update_post_author_caches( $blog_query->posts );

View File

@ -100,7 +100,7 @@ if ( ! $args['ignore_protected'] ) {
$obfuscation = str_repeat( _x( '· ', 'Protected post content obfuscation character.', 'fictioneer' ), 256 );
$obfuscation = apply_filters( 'fictioneer_filter_obfuscation_string', $obfuscation, $post );
} else {
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
$query_args['has_password'] = false;
}
// Apply filters
@ -109,9 +109,6 @@ $query_args = apply_filters( 'fictioneer_filter_shortcode_article_cards_query_ar
// Query
$query = fictioneer_shortcode_query( $query_args );
// Remove temporary filters
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Unique ID
$unique_id = wp_unique_id( 'article-block-' );

View File

@ -108,7 +108,7 @@ if ( ! empty( $args['excluded_authors'] ) ) {
// Ignore protected?
if ( $args['ignore_protected'] ) {
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
$query_args['has_password'] = false;
}
// Apply filters
@ -117,9 +117,6 @@ $query_args = apply_filters( 'fictioneer_filter_shortcode_latest_chapters_query_
// Query chapters
$entries = fictioneer_shortcode_query( $query_args );
// Remove temporary filters
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Extra attributes
$attributes = [];

View File

@ -113,7 +113,7 @@ if ( ! empty( $args['excluded_authors'] ) ) {
// Ignore protected?
if ( $args['ignore_protected'] ) {
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
$query_args['has_password'] = false;
}
// Apply filters
@ -122,9 +122,6 @@ $query_args = apply_filters( 'fictioneer_filter_shortcode_latest_chapters_query_
// Query chapters
$entries = fictioneer_shortcode_query( $query_args );
// Remove temporary filters
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Extra attributes
$attributes = [];

View File

@ -113,7 +113,7 @@ if ( ! empty( $args['excluded_authors'] ) ) {
// Ignore protected?
if ( $args['ignore_protected'] ) {
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
$query_args['has_password'] = false;
}
// Apply filters
@ -122,9 +122,6 @@ $query_args = apply_filters( 'fictioneer_filter_shortcode_latest_chapters_query_
// Query chapters
$entries = fictioneer_shortcode_query( $query_args );
// Remove temporary filters
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Extra attributes
$attributes = [];

View File

@ -72,7 +72,7 @@ if ( ! empty( $args['excluded_authors'] ) ) {
// Ignore protected?
if ( $args['ignore_protected'] ) {
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
$query_args['has_password'] = false;
}
// Apply filters
@ -81,9 +81,6 @@ $query_args = apply_filters( 'fictioneer_filter_shortcode_latest_posts_query_arg
// Query post
$latest_entries = fictioneer_shortcode_query( $query_args );
// Remove temporary filters
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
?>
<section class="latest-posts <?php echo $args['classes']; ?>">

View File

@ -87,7 +87,7 @@ if ( ! empty( $args['excluded_authors'] ) ) {
// Ignore protected?
if ( $args['ignore_protected'] ) {
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
$query_args['has_password'] = false;
}
// Apply filters
@ -96,9 +96,6 @@ $query_args = apply_filters( 'fictioneer_filter_shortcode_latest_recommendations
// Query chapters
$entries = fictioneer_shortcode_query( $query_args );
// Remove temporary filters
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Extra attributes
$attributes = [];

View File

@ -84,7 +84,7 @@ if ( ! empty( $args['excluded_authors'] ) ) {
// Ignore protected?
if ( $args['ignore_protected'] ) {
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
$query_args['has_password'] = false;
}
// Apply filters
@ -93,9 +93,6 @@ $query_args = apply_filters( 'fictioneer_filter_shortcode_latest_recommendations
// Query recommendations
$entries = fictioneer_shortcode_query( $query_args );
// Remove temporary filters
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Extra attributes
$attributes = [];

View File

@ -112,7 +112,7 @@ if ( ! empty( $args['excluded_authors'] ) ) {
// Ignore protected?
if ( $args['ignore_protected'] ) {
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
$query_args['has_password'] = false;
}
// Apply filters
@ -121,9 +121,6 @@ $query_args = apply_filters( 'fictioneer_filter_shortcode_latest_stories_query_a
// Query stories
$entries = fictioneer_shortcode_query( $query_args );
// Remove temporary filters
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Extra attributes
$attributes = [];

View File

@ -113,7 +113,7 @@ if ( ! empty( $args['excluded_authors'] ) ) {
// Ignore protected?
if ( $args['ignore_protected'] ) {
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
$query_args['has_password'] = false;
}
// Apply filters
@ -122,9 +122,6 @@ $query_args = apply_filters( 'fictioneer_filter_shortcode_latest_stories_query_a
// Query stories
$entries = fictioneer_shortcode_query( $query_args );
// Remove temporary filters
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Extra attributes
$attributes = [];

View File

@ -113,7 +113,7 @@ if ( ! empty( $args['excluded_authors'] ) ) {
// Ignore protected?
if ( $args['ignore_protected'] ) {
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
$query_args['has_password'] = false;
}
// Apply filters
@ -122,9 +122,6 @@ $query_args = apply_filters( 'fictioneer_filter_shortcode_latest_stories_query_a
// Query stories
$entries = fictioneer_shortcode_query( $query_args );
// Remove temporary filters
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Extra attributes
$attributes = [];

View File

@ -121,7 +121,7 @@ if ( ! empty( $args['excluded_authors'] ) ) {
// Ignore protected?
if ( $args['ignore_protected'] ) {
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
$query_args['has_password'] = false;
}
// Apply filters
@ -130,9 +130,6 @@ $query_args = apply_filters( 'fictioneer_filter_shortcode_latest_updates_query_a
// Query stories
$entries = fictioneer_shortcode_query( $query_args );
// Remove temporary filters
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Extra attributes
$attributes = [];

View File

@ -124,7 +124,7 @@ if ( ! empty( $args['excluded_authors'] ) ) {
// Ignore protected?
if ( $args['ignore_protected'] ) {
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
$query_args['has_password'] = false;
}
// Apply filters
@ -133,9 +133,6 @@ $query_args = apply_filters( 'fictioneer_filter_shortcode_latest_updates_query_a
// Query stories
$entries = fictioneer_shortcode_query( $query_args );
// Remove temporary filters
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Extra attributes
$attributes = [];

View File

@ -127,7 +127,7 @@ if ( ! empty( $args['excluded_authors'] ) ) {
// Ignore protected?
if ( $args['ignore_protected'] ) {
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
$query_args['has_password'] = false;
}
// Apply filters
@ -136,9 +136,6 @@ $query_args = apply_filters( 'fictioneer_filter_shortcode_latest_updates_query_a
// Query stories
$entries = fictioneer_shortcode_query( $query_args );
// Remove temporary filters
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Extra attributes
$attributes = [];

View File

@ -84,7 +84,7 @@ if ( ! empty( $args['excluded_authors'] ) ) {
// Ignore protected?
if ( $args['ignore_protected'] ) {
add_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
$query_args['has_password'] = false;
}
// Apply filters
@ -93,9 +93,6 @@ $query_args = apply_filters( 'fictioneer_filter_shortcode_showcase_query_args',
// Query collections
$query = fictioneer_shortcode_query( $query_args );
// Remove temporary filters
remove_filter( 'posts_where', 'fictioneer_exclude_protected_posts' );
// Extra attributes
$attributes = [];