Enable selecting columns to display in player list
This commit is contained in:
@@ -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' );
|
||||
?>
|
||||
<ul id="sp-column-group-select">
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input type="checkbox" name="sp_column_group[]" value="sp_performance" <?php checked( true, in_array( 'sp_performance', $column_groups ) ); ?>>
|
||||
<?php _e( 'Performance', 'sportspress' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input type="checkbox" name="sp_column_group[]" value="sp_metric" <?php checked( true, in_array( 'sp_metric', $column_groups ) ); ?>>
|
||||
<?php _e( 'Metrics', 'sportspress' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
<li>
|
||||
<label class="selectit">
|
||||
<input type="checkbox" name="sp_column_group[]" value="sp_statistic" <?php checked( true, in_array( 'sp_statistic', $column_groups ) ); ?>>
|
||||
<?php _e( 'Statistics', 'sportspress' ); ?>
|
||||
</label>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="sp-instance">
|
||||
<ul id="sp_column-tabs" class="wp-tab-bar sp-tab-bar">
|
||||
<li class="wp-tab-active"><a href="#sp_performance-all"><?php _e( 'Performance', 'sportspress' ); ?></a></li>
|
||||
<li class="wp-tab"><a href="#sp_metric-all"><?php _e( 'Metrics', 'sportspress' ); ?></a></li>
|
||||
<li class="wp-tab"><a href="#sp_statistic-all"><?php _e( 'Statistics', 'sportspress' ); ?></a></li>
|
||||
</ul>
|
||||
<?php
|
||||
$selected = (array)get_post_meta( $post->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 );
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
@@ -48,6 +40,6 @@ class SP_Meta_Box_List_Columns {
|
||||
* 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() ) );
|
||||
update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) );
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta Boxes
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 1.0.2
|
||||
*/
|
||||
|
||||
@@ -20,16 +20,15 @@ class SP_Meta_Box_List_Data {
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
$list = new SP_Player_List( $post );
|
||||
list( $columns, $usecolumns, $data, $placeholders, $merged ) = $list->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() ) {
|
||||
?>
|
||||
<ul class="subsubsub sp-table-bar">
|
||||
<li><a href="#sp-table-values" class="current"><?php _e( 'Values', 'sportspress' ); ?></a></li> |
|
||||
@@ -52,12 +49,12 @@ class SP_Meta_Box_List_Data {
|
||||
<th>#</th>
|
||||
<th><?php _e( 'Player', 'sportspress' ); ?></th>
|
||||
<th><label for="sp_columns_team">
|
||||
<input type="checkbox" name="sp_columns[]" value="team" id="sp_columns_team" <?php checked( ! is_array( $usecolumns ) || in_array( 'team', $usecolumns ) ); ?>>
|
||||
<input type="checkbox" name="sp_columns[]" value="team" id="sp_columns_team" <?php checked( ! is_array( $columns ) || array_key_exists( 'team', $columns ) ); ?>>
|
||||
<?php _e( 'Team', 'sportspress' ); ?>
|
||||
</label></th>
|
||||
<?php foreach ( $columns as $key => $label ): ?>
|
||||
<?php if ( $key == 'team' ) continue; ?>
|
||||
<th><label for="sp_columns_<?php echo $key; ?>">
|
||||
<input type="checkbox" name="sp_columns[]" value="<?php echo $key; ?>" id="sp_columns_<?php echo $key; ?>" <?php checked( ! is_array( $usecolumns ) || in_array( $key, $usecolumns ) ); ?>>
|
||||
<?php echo $label; ?>
|
||||
</label></th>
|
||||
<?php endforeach; ?>
|
||||
@@ -92,6 +89,7 @@ class SP_Meta_Box_List_Data {
|
||||
</td>
|
||||
<td><?php echo get_the_title( $team ); ?></td>
|
||||
<?php foreach( $columns as $column => $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 );
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user