From 8455c99901b1154d15324c9a40607f2bb9a0276e Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Mon, 7 Nov 2016 14:16:17 +1100 Subject: [PATCH] Omit player performance with equation or text format from player statistics --- .../meta-boxes/class-sp-meta-box-equation.php | 10 +++++++-- .../class-sp-meta-box-event-performance.php | 6 ++++++ includes/class-sp-player-list.php | 15 ++++++++++++- includes/class-sp-player.php | 13 ++++++++++++ includes/sp-core-functions.php | 21 ++++++++++++++++++- 5 files changed, 61 insertions(+), 4 deletions(-) diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php index 857bbab8..383efb09 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-equation.php @@ -121,10 +121,16 @@ class SP_Meta_Box_Equation { 'orderby' => 'menu_order', 'order' => 'ASC', 'meta_query' => array( + 'relation' => 'OR', array( 'key' => 'sp_format', - 'value' => 'equation', - 'compare' => '!=', + 'value' => 'number', + 'compare' => 'NOT EXISTS', + ), + array( + 'key' => 'sp_format', + 'value' => array( 'equation', 'text' ), + 'compare' => 'NOT IN', ), ), ); diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php index ed4f4309..e0d7e9ba 100644 --- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php +++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-event-performance.php @@ -158,6 +158,12 @@ class SP_Meta_Box_Event_Performance { 'orderby' => 'menu_order', 'order' => 'ASC', 'meta_query' => array( + 'relation' => 'OR', + array( + 'key' => 'sp_format', + 'value' => 'number', + 'compare' => 'NOT EXISTS', + ), array( 'key' => 'sp_format', 'value' => 'equation', diff --git a/includes/class-sp-player-list.php b/includes/class-sp-player-list.php index 24854c0b..a79692b8 100644 --- a/includes/class-sp-player-list.php +++ b/includes/class-sp-player-list.php @@ -436,7 +436,20 @@ class SP_Player_List extends SP_Custom_Post { 'numberposts' => -1, 'posts_per_page' => -1, 'orderby' => 'menu_order', - 'order' => 'ASC' + 'order' => 'ASC', + 'meta_query' => array( + 'relation' => 'OR', + array( + 'key' => 'sp_format', + 'value' => 'number', + 'compare' => 'NOT EXISTS', + ), + array( + 'key' => 'sp_format', + 'value' => array( 'equation', 'text' ), + 'compare' => 'NOT IN', + ), + ), ); $stats = get_posts( $args ); diff --git a/includes/class-sp-player.php b/includes/class-sp-player.php index fd2ea4c4..659698b6 100644 --- a/includes/class-sp-player.php +++ b/includes/class-sp-player.php @@ -125,6 +125,19 @@ class SP_Player extends SP_Custom_Post { 'posts_per_page' => 100, 'orderby' => 'menu_order', 'order' => 'ASC', + 'meta_query' => array( + 'relation' => 'OR', + array( + 'key' => 'sp_format', + 'value' => 'number', + 'compare' => 'NOT EXISTS', + ), + array( + 'key' => 'sp_format', + 'value' => array( 'equation', 'text' ), + 'compare' => 'NOT IN', + ), + ), ); $posts = get_posts( $args ); diff --git a/includes/sp-core-functions.php b/includes/sp-core-functions.php index 1e59f388..79124e62 100644 --- a/includes/sp-core-functions.php +++ b/includes/sp-core-functions.php @@ -936,7 +936,26 @@ if ( !function_exists( 'sp_column_checklist' ) ) { $meta, 'number' => 0 ) ); if ( empty( $posts ) ): - $query = array( 'post_type' => $meta, 'numberposts' => -1, 'post_per_page' => -1, 'order' => 'ASC', 'orderby' => 'menu_order' ); + $query = array( + 'post_type' => $meta, + 'numberposts' => -1, + 'post_per_page' => -1, + 'order' => 'ASC', + 'orderby' => 'menu_order', + 'meta_query' => array( + 'relation' => 'OR', + array( + 'key' => 'sp_format', + 'value' => 'number', + 'compare' => 'NOT EXISTS', + ), + array( + 'key' => 'sp_format', + 'value' => array( 'equation', 'text' ), + 'compare' => 'NOT IN', + ), + ), + ); $posts = get_posts( $query ); endif; if ( sizeof( $posts ) ):