[wp-trac] [WordPress Trac] #43238: `suppress_filters` not set in `pre_get_posts` hook
WordPress Trac
noreply at wordpress.org
Tue Feb 6 23:34:18 UTC 2018
#43238: `suppress_filters` not set in `pre_get_posts` hook
-------------------------------+------------------------------
Reporter: adampatterson | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 4.9.4
Severity: normal | Resolution:
Keywords: reporter-feedback | Focuses:
-------------------------------+------------------------------
Comment (by adampatterson):
I fixed my original issue, but I still think that supress_filters is
supposed to be present.
{{{#!php
<?php
function show_draft_posts( $query ) {
if ( is_admin() ) {
return $query;
}
if ( user_can( wp_get_current_user(), 'administrator' ) ) {
if ( array_key_exists( 'suppress_filters', $query->query_vars )
and $query->query_vars['suppress_filters'] ) {
return $query;
}
$query->set( 'post_status', [ 'publish', 'draft' ] );
return $query;
}
}
add_filter( 'pre_get_posts', 'show_draft_posts' );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/43238#comment:7>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list