Adjust team columns meta box
This commit is contained in:
@@ -140,9 +140,9 @@ class SP_Admin_Meta_Boxes {
|
||||
add_meta_box( 'sp_shortcodediv', __( 'Shortcodes', 'sportspress' ), 'SP_Meta_Box_Team_Shortcode::output', 'sp_team', 'side', 'default' );
|
||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_Team_Details::output', 'sp_team', 'side', 'default' );
|
||||
if ( isset( $post ) && isset( $post->ID ) ):
|
||||
add_meta_box( 'sp_columnssdiv', __( 'Table Columns', 'sportspress' ), 'SP_Meta_Box_Team_Columns::output', 'sp_team', 'normal', 'high' );
|
||||
add_meta_box( 'sp_listsdiv', __( 'Player Lists', 'sportspress' ), 'SP_Meta_Box_Team_Lists::output', 'sp_team', 'normal', 'high' );
|
||||
add_meta_box( 'sp_tablesdiv', __( 'League Tables', 'sportspress' ), 'SP_Meta_Box_Team_Tables::output', 'sp_team', 'normal', 'high' );
|
||||
add_meta_box( 'sp_columnssdiv', __( 'Table Columns', 'sportspress' ), 'SP_Meta_Box_Team_Columns::output', 'sp_team', 'normal', 'high' );
|
||||
endif;
|
||||
add_meta_box( 'sp_editordiv', __( 'Profile', 'sportspress' ), 'SP_Meta_Box_Team_Editor::output', 'sp_team', 'normal', 'low' );
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 0.8
|
||||
* @version 1.3
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
@@ -30,43 +30,33 @@ class SP_Meta_Box_Team_Columns {
|
||||
?>
|
||||
<p><strong><?php echo $league->name; ?></strong></p>
|
||||
<?php
|
||||
list( $columns, $data, $placeholders, $merged, $leagues_seasons ) = $team->columns( $league_id, true );
|
||||
self::table( $league_id, $columns, $data, $placeholders, $merged, $leagues_seasons );
|
||||
list( $columns, $data, $placeholders ) = $team->columns( $league_id );
|
||||
self::table( $league_id, $columns, $data, $placeholders );
|
||||
|
||||
endforeach; endif;
|
||||
?>
|
||||
<p><strong><?php _e( 'Total', 'sportspress' ); ?></strong></p>
|
||||
<?php
|
||||
list( $columns, $data, $placeholders, $merged, $leagues_seasons ) = $team->columns( 0, true );
|
||||
self::table( 0, $columns, $data, $placeholders, $merged, $leagues_seasons );
|
||||
list( $columns, $data, $placeholders ) = $team->columns( 0 );
|
||||
self::table( 0, $columns, $data, $placeholders );
|
||||
}
|
||||
|
||||
/**
|
||||
* Save meta box data
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_leagues', sp_array_value( $_POST, 'sp_leagues', array() ) );
|
||||
update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin edit table
|
||||
*/
|
||||
public static function table( $league_id, $columns = array(), $data = array(), $placeholders = array(), $merged = array(), $seasons = array(), $readonly = false ) {
|
||||
public static function table( $league_id, $columns = array(), $data = array(), $placeholders = array() ) {
|
||||
?>
|
||||
<div class="sp-data-table-container">
|
||||
<table class="widefat sp-data-table sp-team-column-table sp-select-all-range">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php if ( $league_id ): ?>
|
||||
<th class="check-column">
|
||||
<?php if ( sizeof( $data ) > 1 ): ?>
|
||||
<input class="sp-select-all" type="checkbox">
|
||||
<?php else: ?>
|
||||
<input class="sp-select-all" type="checkbox" disabled>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<th><?php _e( 'Season', 'sportspress' ); ?></th>
|
||||
<?php foreach ( $columns as $label ): ?>
|
||||
<th><?php echo $label; ?></th>
|
||||
@@ -80,15 +70,6 @@ class SP_Meta_Box_Team_Columns {
|
||||
$div = get_term( $div_id, 'sp_season' );
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<?php if ( $league_id ): ?>
|
||||
<td>
|
||||
<?php if ( $div_id ): ?>
|
||||
<input type="checkbox" name="sp_leagues[<?php echo $league_id; ?>][<?php echo $div_id; ?>]" id="sp_leagues_<?php echo $league_id; ?>_<?php echo $div_id; ?>" value="1" <?php checked( sp_array_value( $seasons, $div_id, 0 ), 1 ); ?>>
|
||||
<?php else: ?>
|
||||
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<td>
|
||||
<label for="sp_leagues_<?php echo $league_id; ?>_<?php echo $div_id; ?>">
|
||||
<?php
|
||||
@@ -103,10 +84,7 @@ class SP_Meta_Box_Team_Columns {
|
||||
<td><?php
|
||||
$value = sp_array_value( sp_array_value( $data, $div_id, array() ), $column, null );
|
||||
$placeholder = sp_array_value( sp_array_value( $placeholders, $div_id, array() ), $column, 0 );
|
||||
if ( $readonly )
|
||||
echo $value ? $value : $placeholder;
|
||||
else
|
||||
echo '<input type="text" name="sp_columns[' . $league_id . '][' . $div_id . '][' . $column . ']" value="' . $value . '" placeholder="' . $placeholder . '"' . ( $readonly ? ' disabled="disabled"' : '' ) . ' />';
|
||||
echo '<input type="text" name="sp_columns[' . $league_id . '][' . $div_id . '][' . $column . ']" value="' . $value . '" placeholder="' . $placeholder . '" />';
|
||||
?></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user