Display league tables on team pages close #44
This commit is contained in:
@@ -63,6 +63,7 @@ class SP_Admin_Meta_Boxes {
|
||||
add_action( 'sportspress_process_sp_team_meta', 'SP_Meta_Box_Team_Details::save', 10, 2 );
|
||||
add_action( 'sportspress_process_sp_team_meta', 'SP_Meta_Box_Team_Columns::save', 20, 2 );
|
||||
add_action( 'sportspress_process_sp_team_meta', 'SP_Meta_Box_Team_Lists::save', 30, 2 );
|
||||
add_action( 'sportspress_process_sp_team_meta', 'SP_Meta_Box_Team_Tables::save', 40, 2 );
|
||||
|
||||
// Save Table Meta Boxes
|
||||
add_action( 'sportspress_process_sp_table_meta', 'SP_Meta_Box_Table_Details::save', 10, 2 );
|
||||
@@ -141,6 +142,7 @@ class SP_Admin_Meta_Boxes {
|
||||
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' );
|
||||
endif;
|
||||
add_meta_box( 'sp_editordiv', __( 'Profile', 'sportspress' ), 'SP_Meta_Box_Team_Editor::output', 'sp_team', 'normal', 'low' );
|
||||
|
||||
@@ -161,7 +163,7 @@ class SP_Admin_Meta_Boxes {
|
||||
add_meta_box( 'sp_editordiv', __( 'Profile', 'sportspress' ), 'SP_Meta_Box_Player_Editor::output', 'sp_player', 'normal', 'low' );
|
||||
|
||||
// Lists
|
||||
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_List_Shortcode::output', 'sp_list', 'side', 'default' );
|
||||
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_List_Shortcode::output', 'sp_table', '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' );
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Team Shortcode
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 1.3
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Team_Shortcode
|
||||
*/
|
||||
class SP_Meta_Box_Team_Shortcode {
|
||||
|
||||
/**
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
?>
|
||||
<p class="howto">
|
||||
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
|
||||
</p>
|
||||
<p>
|
||||
<strong><?php _e( 'Table Columns', 'sportspress' ); ?></strong>
|
||||
</p>
|
||||
<p><input type="text" value="[team_columns <?php echo $post->ID; ?>]" readonly="readonly" class="code"></p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* Team League Tables
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin/Meta_Boxes
|
||||
* @version 1.3
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
/**
|
||||
* SP_Meta_Box_Team_Tables
|
||||
*/
|
||||
class SP_Meta_Box_Team_Tables {
|
||||
|
||||
/**
|
||||
* Output the metabox
|
||||
*/
|
||||
public static function output( $post ) {
|
||||
global $pagenow;
|
||||
|
||||
if ( $pagenow != 'post-new.php' ):
|
||||
|
||||
$team = new SP_Team( $post );
|
||||
list( $data, $checked ) = $team->tables( true );
|
||||
self::table( $data, $checked );
|
||||
|
||||
else:
|
||||
|
||||
printf( __( 'No results found.', 'sportspress' ) );
|
||||
|
||||
endif;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save meta box data
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_table', sp_array_value( $_POST, 'sp_table', array() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin edit table
|
||||
*/
|
||||
public static function table( $data = array(), $checked = array() ) {
|
||||
?>
|
||||
<div class="sp-data-table-container">
|
||||
<table class="widefat sp-data-table sp-team-table-table sp-select-all-range">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="check-column"><input class="sp-select-all" type="checkbox"></th>
|
||||
<th class="column-table">
|
||||
<?php _e( 'League Table', 'sportspress' ); ?>
|
||||
</th>
|
||||
<th class="column-players">
|
||||
<?php _e( 'Teams', 'sportspress' ); ?>
|
||||
</th>
|
||||
<th class="column-league">
|
||||
<?php _e( 'League', 'sportspress' ); ?>
|
||||
</th>
|
||||
<th class="column-season">
|
||||
<?php _e( 'Season', 'sportspress' ); ?>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if ( is_array( $data ) ):
|
||||
if ( sizeof( $data ) > 0 ):
|
||||
$i = 0;
|
||||
foreach ( $data as $table ):
|
||||
$players = array_filter( get_post_meta( $table->ID, 'sp_player' ) );
|
||||
$format = get_post_meta( $table->ID, 'sp_format', true );
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<td>
|
||||
<input type="checkbox" name="sp_table[]" id="sp_table_<?php echo $table->ID; ?>" value="<?php echo $table->ID; ?>" <?php checked( in_array( $table->ID, $checked ) ); ?>>
|
||||
</td>
|
||||
<td>
|
||||
<a href="<?php echo get_edit_post_link( $table->ID ); ?>">
|
||||
<?php echo $table->post_title; ?>
|
||||
</a>
|
||||
</td>
|
||||
<td><?php echo sizeof( $players ); ?></td>
|
||||
<td><?php echo get_the_terms ( $table->ID, 'sp_league' ) ? the_terms( $table->ID, 'sp_league' ) : '—'; ?></td>
|
||||
<td><?php echo get_the_terms ( $table->ID, 'sp_season' ) ? the_terms( $table->ID, 'sp_season' ) : '—'; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
$i++;
|
||||
endforeach;
|
||||
else:
|
||||
?>
|
||||
<tr class="sp-row alternate">
|
||||
<td colspan="6">
|
||||
<?php _e( 'No results found.', 'sportspress' ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endif;
|
||||
else:
|
||||
?>
|
||||
<tr class="sp-row alternate">
|
||||
<td colspan="5">
|
||||
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Details', 'sportspress' ) ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user