Enable selecting column groups for player list
This commit is contained in:
@@ -72,8 +72,9 @@ class SP_Admin_Meta_Boxes {
|
||||
|
||||
// Save List Meta Boxes
|
||||
add_action( 'sportspress_process_sp_list_meta', 'SP_Meta_Box_List_Format::save', 10, 2 );
|
||||
add_action( 'sportspress_process_sp_list_meta', 'SP_Meta_Box_List_Details::save', 20, 2 );
|
||||
add_action( 'sportspress_process_sp_list_meta', 'SP_Meta_Box_List_Data::save', 30, 2 );
|
||||
add_action( 'sportspress_process_sp_list_meta', 'SP_Meta_Box_List_Columns::save', 20, 2 );
|
||||
add_action( 'sportspress_process_sp_list_meta', 'SP_Meta_Box_List_Details::save', 30, 2 );
|
||||
add_action( 'sportspress_process_sp_list_meta', 'SP_Meta_Box_List_Data::save', 40, 2 );
|
||||
|
||||
// Save Staff Meta Boxes
|
||||
add_action( 'sportspress_process_sp_staff_meta', 'SP_Meta_Box_Staff_Details::save', 10, 2 );
|
||||
@@ -139,6 +140,7 @@ class SP_Admin_Meta_Boxes {
|
||||
// Lists
|
||||
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_List_Shortcode::output', 'sp_list', 'side', 'default' );
|
||||
add_meta_box( 'sp_formatdiv', __( 'Layout', 'sportspress' ), 'SP_Meta_Box_List_Format::output', 'sp_list', 'side', 'default' );
|
||||
add_meta_box( 'sp_columnsdiv', __( 'Columns', 'sportspress' ), 'SP_Meta_Box_List_Columns::output', 'sp_list', 'side', 'default' );
|
||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_List_Details::output', 'sp_list', 'side', 'default' );
|
||||
add_meta_box( 'sp_datadiv', __( 'Player List', 'sportspress' ), 'SP_Meta_Box_List_Data::output', 'sp_list', 'normal', 'high' );
|
||||
add_meta_box( 'sp_editordiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_List_Editor::output', 'sp_list', 'normal', 'high' );
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* List Columns
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta Boxes
|
||||
* @version 0.8
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_List_Columns
|
||||
*/
|
||||
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' );
|
||||
?>
|
||||
<div id="sp-column-group-select">
|
||||
<label class="selectit">
|
||||
<input type="checkbox" name="sp_column_group[]" value="sp_performance" <?php checked( true, ( empty( $column_groups ) || in_array( 'sp_performance', $column_groups ) ) ); ?>>
|
||||
<?php _e( 'Performance', 'sportspress' ); ?>
|
||||
</label><br>
|
||||
<label class="selectit">
|
||||
<input type="checkbox" name="sp_column_group[]" value="sp_metric" <?php checked( true, ( empty( $column_groups ) || in_array( 'sp_metric', $column_groups ) ) ); ?>>
|
||||
<?php _e( 'Metrics', 'sportspress' ); ?>
|
||||
</label><br>
|
||||
<label class="selectit">
|
||||
<input type="checkbox" name="sp_column_group[]" value="sp_statistic" <?php checked( true, ( empty( $column_groups ) || in_array( 'sp_statistic', $column_groups ) ) ); ?>>
|
||||
<?php _e( 'Statistics', 'sportspress' ); ?>
|
||||
</label><br>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Save meta box data
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_column_group', sp_array_value( $_POST, 'sp_column_group', array() ) );
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ 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' );
|
||||
@@ -226,10 +227,8 @@ class SP_Player_List extends SP_Custom_Post {
|
||||
$totals[ $player_id ]['last10'] = $last10;
|
||||
endforeach;
|
||||
|
||||
$placeholders[ $player_id ] = array_merge( $totals[ $player_id ], $placeholders[ $player_id ] );
|
||||
|
||||
$args = array(
|
||||
'post_type' => array( 'sp_performance', 'sp_metric', 'sp_statistic' ),
|
||||
'post_type' => $column_groups,
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'orderby' => 'menu_order',
|
||||
|
||||
Reference in New Issue
Block a user