Apply players (individual sport) mode throughout
This commit is contained in:
@@ -28,8 +28,10 @@ class SP_Admin_Importers {
|
||||
* Add menu items
|
||||
*/
|
||||
public function register_importers() {
|
||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
||||
register_importer( 'sp_event_csv', __( 'SportsPress Events (CSV)', 'sportspress' ), __( 'Import <strong>events</strong> from a csv file.', 'sportspress'), array( $this, 'events_importer' ) );
|
||||
register_importer( 'sp_team_csv', __( 'SportsPress Teams (CSV)', 'sportspress' ), __( 'Import <strong>teams</strong> from a csv file.', 'sportspress'), array( $this, 'teams_importer' ) );
|
||||
}
|
||||
register_importer( 'sp_player_csv', __( 'SportsPress Players (CSV)', 'sportspress' ), __( 'Import <strong>players</strong> from a csv file.', 'sportspress'), array( $this, 'players_importer' ) );
|
||||
register_importer( 'sp_staff_csv', __( 'SportsPress Staff (CSV)', 'sportspress' ), __( 'Import <strong>staff</strong> from a csv file.', 'sportspress'), array( $this, 'staff_importer' ) );
|
||||
}
|
||||
|
||||
@@ -131,6 +131,7 @@ class SP_Admin_Sample_Data {
|
||||
/*
|
||||
* Insert teams
|
||||
*/
|
||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
||||
foreach ( $teams as $index => $team ) {
|
||||
$post['post_title'] = $team['name'];
|
||||
$post['post_type'] = 'sp_team';
|
||||
@@ -159,6 +160,7 @@ class SP_Admin_Sample_Data {
|
||||
update_post_meta( $id, 'sp_abbreviation', $team['abbreviation'] );
|
||||
update_post_meta( $id, 'sp_url', $team['url'] );
|
||||
}
|
||||
}
|
||||
|
||||
// Define players
|
||||
$players = array(
|
||||
@@ -345,6 +347,7 @@ class SP_Admin_Sample_Data {
|
||||
/*
|
||||
* Insert events
|
||||
*/
|
||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
||||
for ( $index = 0; $index < 6; $index ++ ) {
|
||||
// Determine team index and post status
|
||||
$i = $index % 3;
|
||||
@@ -463,10 +466,12 @@ class SP_Admin_Sample_Data {
|
||||
update_post_meta( $id, 'sp_format', 'league' );
|
||||
update_post_meta( $id, 'sp_video', $event_videos[ $i ] );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert calendar
|
||||
*/
|
||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
||||
$post = array(
|
||||
'post_title' => _x( 'Fixtures & Results', 'example', 'sportspress' ),
|
||||
'post_type' => 'sp_calendar',
|
||||
@@ -493,10 +498,12 @@ class SP_Admin_Sample_Data {
|
||||
update_post_meta( $id, 'sp_team', 0 );
|
||||
update_post_meta( $id, 'sp_order', 'ASC' );
|
||||
update_post_meta( $id, 'sp_columns', $columns );
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert league table
|
||||
*/
|
||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
||||
$leagues = get_terms( 'sp_league', array( 'hide_empty' => 0, 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) );
|
||||
$league = reset( $leagues );
|
||||
$seasons = get_terms( 'sp_season', array( 'hide_empty' => 0, 'orderby' => 'id', 'order' => 'ASC', 'number' => 1 ) );
|
||||
@@ -538,10 +545,12 @@ class SP_Admin_Sample_Data {
|
||||
sp_update_post_meta_recursive( $id, 'sp_team', $inserted_ids['sp_team'] );
|
||||
update_post_meta( $id, 'sp_columns', $columns );
|
||||
update_post_meta( $id, 'sp_highlight', reset( $inserted_ids['sp_team'] ) );
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert player list for each team
|
||||
*/
|
||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
||||
foreach ( $inserted_ids['sp_team'] as $index => $team_id ) {
|
||||
$post = array(
|
||||
'post_title' => get_the_title( $team_id ) . ' ' . _x( 'Roster', 'example', 'sportspress' ),
|
||||
@@ -584,6 +593,7 @@ class SP_Admin_Sample_Data {
|
||||
update_post_meta( $id, 'sp_order', 'ASC' );
|
||||
update_post_meta( $id, 'sp_team', $team_id );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert player list for player ranking
|
||||
@@ -620,11 +630,13 @@ class SP_Admin_Sample_Data {
|
||||
/*
|
||||
* Update player list and league table per team
|
||||
*/
|
||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
||||
foreach ( $inserted_ids['sp_team'] as $index => $team_id ) {
|
||||
update_post_meta( $team_id, 'sp_list', sp_array_value( $inserted_ids['sp_list'], $index, 0 ) );
|
||||
update_post_meta( $team_id, 'sp_table', sp_array_value( $inserted_ids['sp_table'], 0 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes sample SportsPress data
|
||||
|
||||
@@ -34,7 +34,10 @@ class SP_Admin_Settings {
|
||||
$settings[] = include( 'settings/class-sp-settings-modules.php' );
|
||||
$settings[] = include( 'settings/class-sp-settings-general.php' );
|
||||
$settings[] = include( 'settings/class-sp-settings-events.php' );
|
||||
|
||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) )
|
||||
$settings[] = include( 'settings/class-sp-settings-teams.php' );
|
||||
|
||||
$settings[] = include( 'settings/class-sp-settings-players.php' );
|
||||
$settings[] = include( 'settings/class-sp-settings-staff.php' );
|
||||
|
||||
|
||||
@@ -194,14 +194,16 @@ class SP_Admin_Welcome {
|
||||
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress', 'tab' => 'general' ), 'admin.php' ) ) ); ?>"><i class="dashicons dashicons-edit"></i> <?php _e( 'Change', 'sportspress' ); ?></a>
|
||||
|
||||
<h4><?php _e( 'Mode', 'sportspress' ); ?></h4>
|
||||
<?php echo ( 'team' == get_option( 'sportspress_mode', 'team' ) ? __( 'Teams', 'sportspress' ) : __( 'Players', 'sportspress' ) ); ?>
|
||||
<?php echo ( 'team' == get_option( 'sportspress_mode', 'team' ) ? __( 'Teams', 'sportspress' ) : __( 'Players', 'sportspress' ) . ' ' . __( '(Beta)', 'sportspress' ) ); ?>
|
||||
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress', 'tab' => 'general' ), 'admin.php' ) ) ); ?>"><i class="dashicons dashicons-edit"></i> <?php _e( 'Change', 'sportspress' ); ?></a>
|
||||
|
||||
<h4><?php _e( 'Next Steps', 'sportspress' ); ?></h4>
|
||||
<p><?php _e( 'We’ve assembled some links to get you started:', 'sportspress' ); ?></p>
|
||||
<div class="sportspress-steps">
|
||||
<ul>
|
||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
||||
<li><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => 'sp_team' ), 'edit.php' ) ) ); ?>" class="welcome-icon sp-welcome-icon dashicons-shield-alt"><?php _e( 'Add New Team', 'sportspress' ); ?></a></li>
|
||||
<?php } ?>
|
||||
<li><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => 'sp_player' ), 'edit.php' ) ) ); ?>" class="welcome-icon sp-welcome-icon dashicons-groups"><?php _e( 'Add New Player', 'sportspress' ); ?></a></li>
|
||||
<li><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => 'sp_event' ), 'edit.php' ) ) ); ?>" class="welcome-icon sp-welcome-icon dashicons-calendar"><?php _e( 'Add New Event', 'sportspress' ); ?></a></li>
|
||||
</ul>
|
||||
@@ -265,7 +267,7 @@ class SP_Admin_Welcome {
|
||||
'type' => 'radio',
|
||||
'options' => array(
|
||||
'team' => __( 'Teams', 'sportspress' ),
|
||||
'player' => __( 'Players', 'sportspress' ),
|
||||
'player' => __( 'Players', 'sportspress' ) . ' ' . __( '(Beta)', 'sportspress' ),
|
||||
),
|
||||
'desc_tip' => _x( 'Who competes in events?', 'mode setting description', 'sportspress' ),
|
||||
),
|
||||
|
||||
@@ -129,8 +129,14 @@ class SP_Admin_Meta_Boxes {
|
||||
if ( 'yes' == get_option( 'sportspress_load_videos_module', 'yes' ) ) {
|
||||
add_meta_box( 'sp_videodiv', __( 'Video', 'sportspress' ), 'SP_Meta_Box_Event_Video::output', 'sp_event', 'side', 'low' );
|
||||
}
|
||||
$teams = array_filter( sp_array_value( $post_meta, 'sp_team', array() ), array( $this, 'positive' ) );
|
||||
if ( ! empty( $teams ) ) {
|
||||
add_meta_box( 'sp_resultsdiv', __( 'Team Results', 'sportspress' ), 'SP_Meta_Box_Event_Results::output', 'sp_event', 'normal', 'high' );
|
||||
}
|
||||
$players = array_filter( sp_array_value( $post_meta, 'sp_player', array() ), array( $this, 'positive' ) );
|
||||
if ( ! empty( $players ) ) {
|
||||
add_meta_box( 'sp_performancediv', __( 'Player Performance', 'sportspress' ), 'SP_Meta_Box_Event_Performance::output', 'sp_event', 'normal', 'high' );
|
||||
}
|
||||
add_meta_box( 'sp_editordiv', __( 'Article', 'sportspress' ), 'SP_Meta_Box_Event_Editor::output', 'sp_event', 'normal', 'low' );
|
||||
|
||||
if ( 'yes' == get_option( 'sportspress_load_calendars_module', 'yes' ) ) {
|
||||
@@ -263,6 +269,13 @@ class SP_Admin_Meta_Boxes {
|
||||
do_action( 'sportspress_process_' . $post->post_type . '_meta', $post_id, $post );
|
||||
}
|
||||
|
||||
/*
|
||||
* Array filter removes values that are not positive.
|
||||
*/
|
||||
public function positive( $var = 0 ) {
|
||||
return $var > 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
new SP_Admin_Meta_Boxes();
|
||||
|
||||
@@ -104,6 +104,7 @@ class SP_Meta_Box_Calendar_Details {
|
||||
endif;
|
||||
?>
|
||||
</p>
|
||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
||||
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<?php
|
||||
@@ -119,6 +120,7 @@ class SP_Meta_Box_Calendar_Details {
|
||||
endif;
|
||||
?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
<p><strong><?php _e( 'Sort Order', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<select name="sp_order">
|
||||
@@ -141,7 +143,9 @@ class SP_Meta_Box_Calendar_Details {
|
||||
update_post_meta( $post_id, 'sp_date', sp_array_value( $_POST, 'sp_date', 0 ) );
|
||||
update_post_meta( $post_id, 'sp_date_from', sp_array_value( $_POST, 'sp_date_from', null ) );
|
||||
update_post_meta( $post_id, 'sp_date_to', sp_array_value( $_POST, 'sp_date_to', null ) );
|
||||
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', 0 ) );
|
||||
update_post_meta( $post_id, 'sp_order', sp_array_value( $_POST, 'sp_order', array() ) );
|
||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
||||
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', 0 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,9 +87,7 @@ class SP_Meta_Box_Event_Teams {
|
||||
* Save meta box data
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
|
||||
}
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) );
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_staff', sp_array_value( $_POST, 'sp_staff', array() ) );
|
||||
}
|
||||
|
||||
@@ -52,10 +52,12 @@ class SP_Meta_Box_List_Data {
|
||||
<?php echo 'number' == $orderby ? '#' : __( 'Rank', 'sportspress' ); ?>
|
||||
</label></th>
|
||||
<th><?php _e( 'Player', 'sportspress' ); ?></th>
|
||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
||||
<th><label for="sp_columns_team">
|
||||
<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 } ?>
|
||||
<?php foreach ( $columns as $key => $label ): ?>
|
||||
<?php if ( in_array( $key, array( 'number', 'team' ) ) ) continue; ?>
|
||||
<th><label for="sp_columns_<?php echo $key; ?>">
|
||||
@@ -100,6 +102,7 @@ class SP_Meta_Box_List_Data {
|
||||
<a class="button button-primary sp-save"><?php _e( 'Save', 'sportspress' ); ?></a>
|
||||
</span>
|
||||
</td>
|
||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
||||
<td>
|
||||
<?php
|
||||
$selected = sp_array_value( $player_stats, 'team', get_post_meta( get_the_ID(), 'sp_team', true ) );
|
||||
@@ -115,6 +118,7 @@ class SP_Meta_Box_List_Data {
|
||||
wp_dropdown_pages( $args );
|
||||
?>
|
||||
</td>
|
||||
<?php } ?>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
if ( in_array( $column, array( 'number', 'team' ) ) ) continue;
|
||||
$value = sp_array_value( $player_stats, $column, '' );
|
||||
|
||||
@@ -62,6 +62,7 @@ class SP_Meta_Box_List_Details {
|
||||
endif;
|
||||
?>
|
||||
</p>
|
||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
||||
<p><strong><?php _e( 'Team', 'sportspress' ); ?></strong></p>
|
||||
<p class="sp-tab-select">
|
||||
<?php
|
||||
@@ -77,6 +78,7 @@ class SP_Meta_Box_List_Details {
|
||||
endif;
|
||||
?>
|
||||
</p>
|
||||
<?php } ?>
|
||||
<p><strong><?php _e( 'Grouping', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<select name="sp_grouping">
|
||||
@@ -126,7 +128,9 @@ class SP_Meta_Box_List_Details {
|
||||
* Save meta box data
|
||||
*/
|
||||
public static function save( $post_id, $post ) {
|
||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
||||
update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) );
|
||||
}
|
||||
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
|
||||
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
||||
update_post_meta( $post_id, 'sp_grouping', sp_array_value( $_POST, 'sp_grouping', array() ) );
|
||||
|
||||
@@ -83,6 +83,7 @@ class SP_Meta_Box_Player_Details {
|
||||
sp_dropdown_taxonomies( $args );
|
||||
?></p>
|
||||
|
||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
||||
<p><strong><?php _e( 'Current Teams', 'sportspress' ); ?></strong></p>
|
||||
<p><?php
|
||||
$args = array(
|
||||
@@ -112,6 +113,7 @@ class SP_Meta_Box_Player_Details {
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?></p>
|
||||
<?php } ?>
|
||||
|
||||
<p><strong><?php _e( 'Competitions', 'sportspress' ); ?></strong></p>
|
||||
<p><?php
|
||||
@@ -151,8 +153,10 @@ class SP_Meta_Box_Player_Details {
|
||||
public static function save( $post_id, $post ) {
|
||||
update_post_meta( $post_id, 'sp_number', sp_array_value( $_POST, 'sp_number', '' ) );
|
||||
update_post_meta( $post_id, 'sp_nationality', sp_array_value( $_POST, 'sp_nationality', '' ) );
|
||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array() ) );
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_past_team', sp_array_value( $_POST, 'sp_past_team', array() ) );
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sp_array_value( $_POST, 'sp_current_team', array() ) ), sp_array_value( $_POST, 'sp_past_team', array() ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,7 @@ class SP_Meta_Box_Player_Statistics {
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _e( 'Season', 'sportspress' ); ?></th>
|
||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ): ?>
|
||||
<?php if ( $league_id ): ?>
|
||||
<th>
|
||||
<?php if ( $has_checkboxes ): ?>
|
||||
@@ -73,6 +74,7 @@ class SP_Meta_Box_Player_Statistics {
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php foreach ( $columns as $key => $label ): if ( $key == 'team' ) continue; ?>
|
||||
<th><?php echo $label; ?></th>
|
||||
<?php endforeach; ?>
|
||||
@@ -87,18 +89,29 @@ class SP_Meta_Box_Player_Statistics {
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<td>
|
||||
<?php if ( 'team' != get_option( 'sportspress_mode', 'team' ) && 0 !== $div_id ): ?>
|
||||
<label>
|
||||
<?php $value = sp_array_value( $leagues, $div_id, '-1' ); ?>
|
||||
<input type="checkbox" name="sp_leagues[<?php echo $league_id; ?>][<?php echo $div_id; ?>]" value="1" <?php checked( $value ); ?>>
|
||||
<?php
|
||||
if ( 'WP_Error' == get_class( $div ) ) _e( 'Total', 'sportspress' );
|
||||
else echo $div->name;
|
||||
?>
|
||||
</label>
|
||||
<?php else: ?>
|
||||
<?php
|
||||
if ( 'WP_Error' == get_class( $div ) ) _e( 'Total', 'sportspress' );
|
||||
else echo $div->name;
|
||||
?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ): ?>
|
||||
<?php if ( $league_id ): ?>
|
||||
<?php if ( $div_id == 0 ): ?>
|
||||
<td> </td>
|
||||
<?php else: ?>
|
||||
<td>
|
||||
<?php $value = sp_array_value( $leagues, $div_id, '-1' ); ?>
|
||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
||||
<?php
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
@@ -127,12 +140,10 @@ class SP_Meta_Box_Player_Statistics {
|
||||
_e( '— None —', 'sportspress' );
|
||||
endif;
|
||||
?>
|
||||
<?php } else { ?>
|
||||
<input type="checkbox" name="sp_leagues[<?php echo $league_id; ?>][<?php echo $div_id; ?>]" value="0" <?php checked( 0, $value ); ?>>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php foreach ( $columns as $column => $label ): if ( $column == 'team' ) continue;
|
||||
?>
|
||||
<td><?php
|
||||
|
||||
@@ -81,6 +81,7 @@ class SP_Meta_Box_Staff_Details {
|
||||
<?php endforeach; ?>
|
||||
</select></p>
|
||||
|
||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
||||
<p><strong><?php _e( 'Current Teams', 'sportspress' ); ?></strong></p>
|
||||
<p><?php
|
||||
$args = array(
|
||||
@@ -110,6 +111,7 @@ class SP_Meta_Box_Staff_Details {
|
||||
);
|
||||
sp_dropdown_pages( $args );
|
||||
?></p>
|
||||
<?php } ?>
|
||||
|
||||
<p><strong><?php _e( 'Competitions', 'sportspress' ); ?></strong></p>
|
||||
<p><?php
|
||||
@@ -149,8 +151,11 @@ class SP_Meta_Box_Staff_Details {
|
||||
public static function save( $post_id, $post ) {
|
||||
wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_role', null ), 'sp_role', false );
|
||||
update_post_meta( $post_id, 'sp_nationality', sp_array_value( $_POST, 'sp_nationality', '' ) );
|
||||
|
||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_current_team', sp_array_value( $_POST, 'sp_current_team', array() ) );
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_past_team', sp_array_value( $_POST, 'sp_past_team', array() ) );
|
||||
sp_update_post_meta_recursive( $post_id, 'sp_team', array_merge( array( sp_array_value( $_POST, 'sp_current_team', array() ) ), sp_array_value( $_POST, 'sp_past_team', array() ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ class SP_Settings_General extends SP_Settings_Page {
|
||||
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
|
||||
add_action( 'sportspress_admin_field_timezone', array( $this, 'timezone_setting' ) );
|
||||
add_action( 'sportspress_admin_field_frontend_styles', array( $this, 'frontend_styles_setting' ) );
|
||||
add_action( 'sportspress_admin_field_current_mode', array( $this, 'current_mode_setting' ) );
|
||||
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
|
||||
}
|
||||
|
||||
@@ -64,10 +65,12 @@ class SP_Settings_General extends SP_Settings_Page {
|
||||
'type' => 'radio',
|
||||
'options' => array(
|
||||
'team' => __( 'Teams', 'sportspress' ),
|
||||
'player' => __( 'Players', 'sportspress' ),
|
||||
'player' => __( 'Players', 'sportspress' ) . ' ' . __( '(Beta)', 'sportspress' ),
|
||||
),
|
||||
'desc_tip' => _x( 'Who competes in events?', 'mode setting description', 'sportspress' ),
|
||||
),
|
||||
|
||||
array( 'type' => 'current_mode' ),
|
||||
)),
|
||||
|
||||
array(
|
||||
@@ -335,6 +338,21 @@ class SP_Settings_General extends SP_Settings_Page {
|
||||
<input name="' . esc_attr( $id ). '" id="' . esc_attr( $id ) . '" type="text" value="' . esc_attr( $value ) . '" class="colorpick" /> <div id="colorPickerDiv_' . esc_attr( $id ) . '" class="colorpickdiv"></div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Output script to refresh page when mode is changed.
|
||||
*/
|
||||
function current_mode_setting() {
|
||||
?>
|
||||
<input type="hidden" name="sportspress_current_mode" value="<?php echo get_option( 'sportspress_mode', 'team' ); ?>">
|
||||
<?php if ( sp_array_value( $_POST, 'sportspress_mode', 'team' ) !== sp_array_value( $_POST, 'sportspress_current_mode', 'team' ) ) { ?>
|
||||
<script type="text/javascript">
|
||||
window.onload = function() {
|
||||
window.location = window.location.href;
|
||||
}
|
||||
</script>
|
||||
<?php }
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
@@ -167,7 +167,8 @@ class SP_Settings_Modules extends SP_Settings_Page {
|
||||
<img src="<?php echo $theme->get_screenshot(); ?>" class="sp-theme-screenshot">
|
||||
<p><?php _e( '<strong>Your theme does not declare SportsPress support</strong> – if you encounter layout issues please read our integration guide or choose a SportsPress theme :)', 'sportspress' ); ?></p>
|
||||
<p class="sp-module-actions">
|
||||
<a class="button" href="http://themeboy.com/sportspress/themes/" target="_blank"><?php _e( 'Need a Better Theme?', 'sportspress' ); ?></a>
|
||||
<span><?php _e( 'Free', 'sportspress' ); ?></span>
|
||||
<a class="button" href="<?php echo add_query_arg( array( 'theme' => 'rookie' ), admin_url( 'theme-install.php' ) ); ?>" target="_blank"><?php _e( 'Install Rookie Theme', 'sportspress' ); ?></a>
|
||||
</p>
|
||||
</td></tr>
|
||||
</tbody>
|
||||
@@ -194,6 +195,7 @@ class SP_Settings_Modules extends SP_Settings_Page {
|
||||
|
||||
<div class="sp-modules-main">
|
||||
<?php foreach ( SP()->modules->data as $section => $modules ) { ?>
|
||||
<?php if ( 'team' == $section && 'team' != get_option( 'sportspress_mode', 'team' ) ) continue; ?>
|
||||
<table class="sp-modules-table widefat" cellspacing="0">
|
||||
<thead>
|
||||
<tr><th>
|
||||
|
||||
@@ -21,6 +21,8 @@ function sp_get_screen_ids() {
|
||||
'widgets',
|
||||
'dashboard',
|
||||
'dashboard_page_sp-about',
|
||||
'dashboard_page_sp-credits',
|
||||
'dashboard_page_sp-translators',
|
||||
'toplevel_page_sportspress',
|
||||
'edit-sp_result',
|
||||
'sp_result',
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<?php
|
||||
@@ -128,6 +129,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } ?>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<?php
|
||||
@@ -179,6 +181,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) { ?>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<?php
|
||||
@@ -235,6 +238,7 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php } ?>
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
@@ -450,7 +450,7 @@ class SP_Player_List extends SP_Custom_Post {
|
||||
foreach( $this->columns as $key ):
|
||||
if ( $key == 'number' ):
|
||||
$labels[ $key ] = '#';
|
||||
elseif ( $key == 'team' ):
|
||||
elseif ( $key == 'team' && 'team' == get_option( 'sportspress_mode', 'team' ) ):
|
||||
$labels[ $key ] = __( 'Team', 'sportspress' );
|
||||
elseif ( array_key_exists( $key, $columns ) ):
|
||||
$labels[ $key ] = $columns[ $key ];
|
||||
@@ -469,7 +469,7 @@ class SP_Player_List extends SP_Custom_Post {
|
||||
$labels = array();
|
||||
if ( in_array( 'number', $this->columns ) ) $labels['number'] = '#';
|
||||
$labels['name'] = __( 'Player', 'sportspress' );
|
||||
if ( in_array( 'team', $this->columns ) ) $labels['team'] = __( 'Team', 'sportspress' );
|
||||
if ( in_array( 'team', $this->columns ) && 'team' == get_option( 'sportspress_mode', 'team' ) ) $labels['team'] = __( 'Team', 'sportspress' );
|
||||
|
||||
$merged[0] = array_merge( $labels, $columns );
|
||||
return $merged;
|
||||
|
||||
@@ -429,6 +429,7 @@ class SP_Post_types {
|
||||
);
|
||||
}
|
||||
|
||||
if ( 'team' == get_option( 'sportspress_mode', 'team' ) ) {
|
||||
register_post_type( 'sp_team',
|
||||
apply_filters( 'sportspress_register_post_type_team',
|
||||
array(
|
||||
@@ -491,6 +492,7 @@ class SP_Post_types {
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
register_post_type( 'sp_player',
|
||||
apply_filters( 'sportspress_register_post_type_player',
|
||||
|
||||
@@ -61,8 +61,15 @@ if ( is_array( $teams ) ):
|
||||
|
||||
$totals = array();
|
||||
|
||||
if ( $team_id ) {
|
||||
if ( 0 < $team_id ) {
|
||||
$data = sp_array_combine( $players, sp_array_value( $performance, $team_id, array() ) );
|
||||
} elseif ( 0 == $team_id ) {
|
||||
$data = array();
|
||||
foreach ( $players as $player_id ) {
|
||||
if ( isset( $performance[ $player_id ][ $player_id ] ) ) {
|
||||
$data[ $player_id ] = $performance[ $player_id ][ $player_id ];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$data = sp_array_value( array_values( $performance ), $index );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user