diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-columns.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-columns.php
index c86e0d33..700cab49 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-columns.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-list-columns.php
@@ -4,8 +4,8 @@
*
* @author ThemeBoy
* @category Admin
- * @package SportsPress/Admin/Meta Boxes
- * @version 0.8
+ * @package SportsPress/Admin/Meta_Boxes
+ * @version 1.1
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -19,28 +19,20 @@ class SP_Meta_Box_List_Columns {
* Output the metabox
*/
public static function output( $post ) {
- $column_groups = (array) get_post_meta( $post->ID, 'sp_column_group' );
?>
-
+
+
+ ID, 'sp_columns', true );
+ sp_column_checklist( $post->ID, 'sp_performance', 'block', $selected );
+ sp_column_checklist( $post->ID, 'sp_metric', 'none', $selected );
+ sp_column_checklist( $post->ID, 'sp_statistic', 'none', $selected );
+ ?>
+
data( true );
+ list( $columns, $data, $placeholders, $merged ) = $list->data( true );
$adjustments = $list->adjustments;
- self::table( $columns, $usecolumns, $data, $placeholders, $adjustments );
+ self::table( $columns, $data, $placeholders, $adjustments );
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
- update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) );
update_post_meta( $post_id, 'sp_adjustments', sp_array_value( $_POST, 'sp_adjustments', array() ) );
update_post_meta( $post_id, 'sp_players', sp_array_value( $_POST, 'sp_players', array() ) );
}
@@ -37,9 +36,7 @@ class SP_Meta_Box_List_Data {
/**
* Admin edit table
*/
- public static function table( $columns = array(), $usecolumns = null, $data = array(), $placeholders = array(), $adjustments = array() ) {
- if ( is_array( $usecolumns ) )
- $usecolumns = array_filter( $usecolumns );
+ public static function table( $columns = array(), $data = array(), $placeholders = array(), $adjustments = array() ) {
?>
|
@@ -52,12 +49,12 @@ class SP_Meta_Box_List_Data {
# |
|
|
$label ): ?>
+
|
@@ -92,6 +89,7 @@ class SP_Meta_Box_List_Data {
|
$label ):
+ if ( $column == 'team' ) continue;
$value = sp_array_value( $player_stats, $column, '' );
$placeholder = sp_array_value( sp_array_value( $placeholders, $player_id, array() ), $column, 0 );
?>
diff --git a/includes/class-sp-player-list.php b/includes/class-sp-player-list.php
index b69c94dd..57ba2474 100644
--- a/includes/class-sp-player-list.php
+++ b/includes/class-sp-player-list.php
@@ -41,7 +41,6 @@ class SP_Player_List extends SP_Custom_Post {
$adjustments = get_post_meta( $this->ID, 'sp_adjustments', true );
$orderby = get_post_meta( $this->ID, 'sp_orderby', true );
$order = get_post_meta( $this->ID, 'sp_order', true );
- $column_groups = (array)get_post_meta( $this->ID, 'sp_column_group' );
// Get labels from performance variables
$performance_labels = (array)sp_get_var_labels( 'sp_performance' );
@@ -242,72 +241,68 @@ class SP_Player_List extends SP_Custom_Post {
$totals[ $player_id ]['last10'] = $last10;
endforeach;
- if ( ! empty( $column_groups ) ):
+ $args = array(
+ 'post_type' => array( 'sp_performance', 'sp_metric', 'sp_statistic' ),
+ 'numberposts' => -1,
+ 'posts_per_page' => -1,
+ 'orderby' => 'menu_order',
+ 'order' => 'ASC'
+ );
+ $stats = get_posts( $args );
- $args = array(
- 'post_type' => $column_groups,
- 'numberposts' => -1,
- 'posts_per_page' => -1,
- 'orderby' => 'menu_order',
- 'order' => 'ASC'
- );
- $stats = get_posts( $args );
+ foreach ( $stats as $stat ):
+
+ // Get post meta
+ $meta = get_post_meta( $stat->ID );
+
+ // Add equation to object
+ if ( $stat->post_type == 'sp_metric' ):
+ $stat->equation = null;
+ else:
+ $stat->equation = sp_array_value( sp_array_value( $meta, 'sp_equation', array() ), 0, 0 );
+ endif;
+
+ // Add precision to object
+ $stat->precision = sp_array_value( sp_array_value( $meta, 'sp_precision', array() ), 0, 0 );
+
+ // Add column name to columns
+ $columns[ $stat->post_name ] = $stat->post_title;
+
+ endforeach;
+
+ // Fill in empty placeholder values for each player
+ foreach ( $player_ids as $player_id ):
+ if ( ! $player_id )
+ continue;
+
+ $placeholders[ $player_id ] = array_merge( sp_array_value( $totals, $player_id, array() ), array_filter( sp_array_value( $placeholders, $player_id, array() ) ) );
foreach ( $stats as $stat ):
+ if ( sp_array_value( $placeholders[ $player_id ], $stat->post_name, '' ) == '' ):
- // Get post meta
- $meta = get_post_meta( $stat->ID );
-
- // Add equation to object
- if ( $stat->post_type == 'sp_metric' ):
- $stat->equation = null;
- else:
- $stat->equation = sp_array_value( sp_array_value( $meta, 'sp_equation', array() ), 0, 0 );
- endif;
-
- // Add precision to object
- $stat->precision = sp_array_value( sp_array_value( $meta, 'sp_precision', array() ), 0, 0 );
-
- // Add column name to columns
- $columns[ $stat->post_name ] = $stat->post_title;
-
- endforeach;
-
- // Fill in empty placeholder values for each player
- foreach ( $player_ids as $player_id ):
- if ( ! $player_id )
- continue;
-
- $placeholders[ $player_id ] = array_merge( sp_array_value( $totals, $player_id, array() ), array_filter( sp_array_value( $placeholders, $player_id, array() ) ) );
-
- foreach ( $stats as $stat ):
- if ( sp_array_value( $placeholders[ $player_id ], $stat->post_name, '' ) == '' ):
-
- if ( $stat->equation === null ):
- $placeholder = sp_array_value( sp_array_value( $adjustments, $player_id, array() ), $stat->post_name, null );
- if ( $placeholder == null ):
- $placeholder = '-';
- endif;
- else:
- // Solve
- $placeholder = sp_solve( $stat->equation, $placeholders[ $player_id ], $stat->precision );
-
- // Adjustments
- $adjustment = sp_array_value( $adjustments, $player_id, array() );
-
- if ( $adjustment != 0 ):
- $placeholder += sp_array_value( $adjustment, $stat->post_name, 0 );
- $placeholder = number_format( $placeholder, $stat->precision );
- endif;
+ if ( $stat->equation === null ):
+ $placeholder = sp_array_value( sp_array_value( $adjustments, $player_id, array() ), $stat->post_name, null );
+ if ( $placeholder == null ):
+ $placeholder = '-';
endif;
+ else:
+ // Solve
+ $placeholder = sp_solve( $stat->equation, $placeholders[ $player_id ], $stat->precision );
- $placeholders[ $player_id ][ $stat->post_name ] = $placeholder;
+ // Adjustments
+ $adjustment = sp_array_value( $adjustments, $player_id, array() );
+
+ if ( $adjustment != 0 ):
+ $placeholder += sp_array_value( $adjustment, $stat->post_name, 0 );
+ $placeholder = number_format( $placeholder, $stat->precision );
+ endif;
endif;
- endforeach;
+ $placeholders[ $player_id ][ $stat->post_name ] = $placeholder;
+ endif;
endforeach;
- endif;
+ endforeach;
// Merge the data and placeholders arrays
$merged = array();
@@ -348,7 +343,15 @@ class SP_Player_List extends SP_Custom_Post {
endforeach;
if ( $admin ):
- return array( $columns, $this->columns, $data, $placeholders, $merged );
+ $labels = array();
+ foreach( $this->columns as $key ):
+ if ( $key == 'team' ):
+ $labels[ $key ] = __( 'Team', 'sportspress' );
+ elseif ( array_key_exists( $key, $columns ) ):
+ $labels[ $key ] = $columns[ $key ];
+ endif;
+ endforeach;
+ return array( $labels, $data, $placeholders, $merged );
else:
if ( ! is_array( $this->columns ) )
$this->columns = array();