Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent singular views for WordCamps that do not have public status #972

Open
wants to merge 2 commits into
base: production
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct() {
add_action( 'plugins_loaded', array( $this, 'includes' ) );
add_action( 'init', array( $this, 'register_post_types' ) );
add_action( 'init', array( $this, 'register_post_statuses' ) );
add_filter( 'pre_get_posts', array( $this, 'query_public_statuses_on_archives' ) );
add_filter( 'pre_get_posts', array( $this, 'query_public_statuses' ) );
add_filter( 'cron_schedules', array( $this, 'add_weekly_cron_interval' ) );
}

Expand Down Expand Up @@ -80,12 +80,18 @@ abstract public static function get_public_post_statuses();
*
* @param WP_Query $query
*/
public function query_public_statuses_on_archives( $query ) {
if ( ! $query->is_post_type_archive( WCPT_POST_TYPE_ID ) ) {
public function query_public_statuses( $query ) {
if ( is_admin() ) {
return;
}

if ( is_admin() ) {
if ( ! $query->is_main_query() ) {
return;
}

// Bail if post type is something other than WordCamp.
// is_singular check breaks the frontpage so let's do it this way.
if ( ! $query->is_post_type_archive( WCPT_POST_TYPE_ID ) && ! ( isset( $query->query_vars['post_type'] ) && WCPT_POST_TYPE_ID === $query->query_vars['post_type'] ) ) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function register_post_capabilities() {
* Save the date that the camp was moved on to the official schedule
*
* It's stored in the `menu_order` field because the purpose of storing it is so we can sort the archives
* by this timestamp. See WordCamp_Loader::query_public_statuses_on_archives().
* by this timestamp. See WordCamp_Loader::query_public_statuses().
*
* Sorting by meta fields would be significantly slower, and the `menu_order` field is a good candidate for
* re-purposing because it makes semantic sense and isn't being used.
Expand Down
Loading