Add league taxonomy
This commit is contained in:
@@ -229,11 +229,14 @@ if ( !function_exists( 'sportspress_dropdown_pages' ) ) {
|
||||
'meta_value' => null,
|
||||
'authors' => null,
|
||||
'exclude_tree' => null,
|
||||
'post_type' => 'page'
|
||||
'post_type' => 'page',
|
||||
'values' => 'post_name',
|
||||
);
|
||||
$args = array_merge( $defaults, $args );
|
||||
$name = $args['name'];
|
||||
unset( $args['name'] );
|
||||
$values = $args['values'];
|
||||
unset( $args['values'] );
|
||||
$posts = get_posts( $args );
|
||||
if ( $posts ) {
|
||||
printf( '<select name="%s" class="postform">', $name );
|
||||
@@ -244,7 +247,11 @@ if ( !function_exists( 'sportspress_dropdown_pages' ) ) {
|
||||
printf( '<option value="-1">%s</option>', $args['show_option_none'] );
|
||||
}
|
||||
foreach ( $posts as $post ) {
|
||||
printf( '<option value="%s" %s>%s</option>', $post->post_name, selected( true, $args['selected'] == $post->post_name, false ), $post->post_title );
|
||||
if ( $values == 'ID' ):
|
||||
printf( '<option value="%s" %s>%s</option>', $post->ID, selected( true, $args['selected'] == $post->ID, false ), $post->post_title );
|
||||
else:
|
||||
printf( '<option value="%s" %s>%s</option>', $post->post_name, selected( true, $args['selected'] == $post->post_name, false ), $post->post_title );
|
||||
endif;
|
||||
}
|
||||
print( '</select>' );
|
||||
}
|
||||
@@ -671,13 +678,14 @@ if ( !function_exists( 'sportspress_edit_team_columns_table' ) ) {
|
||||
}
|
||||
|
||||
if ( !function_exists( 'sportspress_edit_player_statistics_table' ) ) {
|
||||
function sportspress_edit_player_statistics_table( $team_id, $columns = array(), $data = array(), $placeholders = array() ) {
|
||||
function sportspress_edit_player_statistics_table( $league_id, $columns = array(), $data = array(), $placeholders = array() ) {
|
||||
?>
|
||||
<div class="sp-data-table-container">
|
||||
<table class="widefat sp-data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php _e( 'Season', 'sportspress' ); ?></th>
|
||||
<th><?php _e( 'Team', 'sportspress' ); ?></th>
|
||||
<?php foreach ( $columns as $label ): ?>
|
||||
<th><?php echo $label; ?></th>
|
||||
<?php endforeach; ?>
|
||||
@@ -694,11 +702,26 @@ if ( !function_exists( 'sportspress_edit_player_statistics_table' ) ) {
|
||||
<td>
|
||||
<?php echo $div->name; ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
$value = sportspress_array_value( $div_stats, 'team', '-1' );
|
||||
$args = array(
|
||||
'post_type' => 'sp_team',
|
||||
'name' => 'sp_statistics[' . $league_id . '][' . $div_id . '][team]',
|
||||
'show_option_none' => __( '-- Select --', 'sportspress' ),
|
||||
'sort_order' => 'ASC',
|
||||
'sort_column' => 'menu_order',
|
||||
'selected' => $value,
|
||||
'values' => 'ID',
|
||||
);
|
||||
sportspress_dropdown_pages( $args );
|
||||
?>
|
||||
</td>
|
||||
<?php foreach( $columns as $column => $label ):
|
||||
$value = sportspress_array_value( $div_stats, $column, '' );
|
||||
$placeholder = sportspress_array_value( sportspress_array_value( $placeholders, $div_id, array() ), $column, 0 );
|
||||
?>
|
||||
<td><input type="text" name="sp_statistics[<?php echo $team_id; ?>][<?php echo $div_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
|
||||
<td><input type="text" name="sp_statistics[<?php echo $league_id; ?>][<?php echo $div_id; ?>][<?php echo $column; ?>]" value="<?php echo $value; ?>" placeholder="<?php echo $placeholder; ?>" /></td>
|
||||
<?php endforeach; ?>
|
||||
</tr>
|
||||
<?php
|
||||
@@ -1031,12 +1054,18 @@ if ( !function_exists( 'sportspress_solve' ) ) {
|
||||
|
||||
if ( !function_exists( 'sportspress_get_calendar_data' ) ) {
|
||||
function sportspress_get_calendar_data( $post_id ) {
|
||||
$leagues = get_the_terms( $post_id, 'sp_league' );
|
||||
$seasons = get_the_terms( $post_id, 'sp_season' );
|
||||
$venues = get_the_terms( $post_id, 'sp_venue' );
|
||||
|
||||
if ( ! $seasons || ! $venues )
|
||||
if ( ! $leagues || ! $seasons || ! $venues )
|
||||
return array();
|
||||
|
||||
$league_ids = array();
|
||||
foreach( $leagues as $league ):
|
||||
$league_ids[] = $league->term_id;
|
||||
endforeach;
|
||||
|
||||
$season_ids = array();
|
||||
foreach( $seasons as $season ):
|
||||
$season_ids[] = $season->term_id;
|
||||
@@ -1053,7 +1082,14 @@ if ( !function_exists( 'sportspress_get_calendar_data' ) ) {
|
||||
'posts_per_page' => -1,
|
||||
'orderby' => 'post_date',
|
||||
'order' => 'ASC',
|
||||
'post_status' => 'any',
|
||||
'tax_query' => array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'id',
|
||||
'terms' => $league_ids
|
||||
),
|
||||
array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'field' => 'id',
|
||||
@@ -1073,8 +1109,215 @@ if ( !function_exists( 'sportspress_get_calendar_data' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'sportspress_get_team_columns_data' ) ) {
|
||||
function sportspress_get_team_columns_data( $post_id, $league_id, $breakdown = false ) {
|
||||
|
||||
$seasons = (array)get_the_terms( $post_id, 'sp_season' );
|
||||
$columns = (array)get_post_meta( $post_id, 'sp_columns', true );
|
||||
|
||||
// Equation Operating System
|
||||
$eos = new eqEOS();
|
||||
|
||||
// Get labels from result variables
|
||||
$result_labels = (array)sportspress_get_var_labels( 'sp_result' );
|
||||
|
||||
// Get labels from outcome variables
|
||||
$outcome_labels = (array)sportspress_get_var_labels( 'sp_outcome' );
|
||||
|
||||
// Generate array of all season ids and season names
|
||||
$div_ids = array();
|
||||
$season_names = array();
|
||||
foreach ( $seasons as $season ):
|
||||
if ( is_object( $season ) && property_exists( $season, 'term_id' ) && property_exists( $season, 'name' ) ):
|
||||
$div_ids[] = $season->term_id;
|
||||
$season_names[ $season->term_id ] = $season->name;
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
// Get all leagues populated with columns where available
|
||||
$data = sportspress_array_combine( $div_ids, $columns );
|
||||
|
||||
// Get equations from column variables
|
||||
$equations = sportspress_get_var_equations( 'sp_column' );
|
||||
|
||||
// Initialize placeholders array
|
||||
$placeholders = array();
|
||||
|
||||
foreach ( $div_ids as $div_id ):
|
||||
|
||||
$totals = array( 'eventsplayed' => 0, 'streak' => 0, 'last10' => null );
|
||||
|
||||
foreach ( $result_labels as $key => $value ):
|
||||
$totals[ $key . 'for' ] = 0;
|
||||
$totals[ $key . 'against' ] = 0;
|
||||
endforeach;
|
||||
|
||||
foreach ( $outcome_labels as $key => $value ):
|
||||
$totals[ $key ] = 0;
|
||||
endforeach;
|
||||
|
||||
// Initialize streaks counter
|
||||
$streak = array( 'name' => '', 'count' => 0, 'fire' => 1 );
|
||||
|
||||
// Initialize last 10 counter
|
||||
$last10 = array();
|
||||
|
||||
// Add outcome types to last 10 counter
|
||||
foreach( $outcome_labels as $key => $value ):
|
||||
$last10[ $key ] = 0;
|
||||
endforeach;
|
||||
|
||||
// Get all events involving the team in current season
|
||||
$args = array(
|
||||
'post_type' => 'sp_event',
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'order' => 'ASC',
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'sp_team',
|
||||
'value' => $post_id
|
||||
)
|
||||
),
|
||||
'tax_query' => array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'id',
|
||||
'terms' => $league_id
|
||||
),
|
||||
array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'field' => 'id',
|
||||
'terms' => $div_id
|
||||
)
|
||||
)
|
||||
);
|
||||
$events = get_posts( $args );
|
||||
|
||||
foreach( $events as $event ):
|
||||
$results = (array)get_post_meta( $event->ID, 'sp_results', true );
|
||||
foreach ( $results as $team_id => $team_result ):
|
||||
foreach ( $team_result as $key => $value ):
|
||||
if ( $team_id == $post_id ):
|
||||
if ( $key == 'outcome' ):
|
||||
|
||||
// Increment events played and outcome count
|
||||
if ( array_key_exists( $value, $totals ) ):
|
||||
$totals['eventsplayed']++;
|
||||
$totals[ $value ]++;
|
||||
endif;
|
||||
|
||||
if ( $value && $value != '-1' ):
|
||||
|
||||
// Add to streak counter
|
||||
if ( $streak['fire'] && ( $streak['name'] == '' || $streak['name'] == $value ) ):
|
||||
$streak['name'] = $value;
|
||||
$streak['count'] ++;
|
||||
else:
|
||||
$streak['fire'] = 0;
|
||||
endif;
|
||||
|
||||
// Add to last 10 counter if sum is less than 10
|
||||
if ( array_key_exists( $value, $last10 ) && array_sum( $last10 ) < 10 ):
|
||||
$last10[ $value ] ++;
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
else:
|
||||
if ( array_key_exists( $key . 'for', $totals ) ):
|
||||
$totals[ $key . 'for' ] += $value;
|
||||
endif;
|
||||
endif;
|
||||
else:
|
||||
if ( $key != 'outcome' ):
|
||||
if ( array_key_exists( $key . 'against', $totals ) ):
|
||||
$totals[ $key . 'against' ] += $value;
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
endforeach;
|
||||
endforeach;
|
||||
endforeach;
|
||||
|
||||
// Compile streaks counter and add to totals
|
||||
$args=array(
|
||||
'name' => $streak['name'],
|
||||
'post_type' => 'sp_outcome',
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => 1
|
||||
);
|
||||
$outcomes = get_posts( $args );
|
||||
|
||||
if ( $outcomes ):
|
||||
$outcome = $outcomes[0];
|
||||
$totals['streak'] = $outcome->post_title . $streak['count'];
|
||||
endif;
|
||||
|
||||
// Add last 10 to totals
|
||||
$totals['last10'] = $last10;
|
||||
|
||||
// Generate array of placeholder values for each league
|
||||
$placeholders[ $div_id ] = array();
|
||||
foreach ( $equations as $key => $value ):
|
||||
if ( $totals['eventsplayed'] > 0 ):
|
||||
$placeholders[ $div_id ][ $key ] = sportspress_solve( $value, $totals );
|
||||
else:
|
||||
$placeholders[ $div_id ][ $key ] = 0;
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
endforeach;
|
||||
|
||||
// Get columns from column variables
|
||||
$columns = sportspress_get_var_labels( 'sp_column' );
|
||||
|
||||
// Merge the data and placeholders arrays
|
||||
$merged = array();
|
||||
|
||||
foreach( $placeholders as $season_id => $season_data ):
|
||||
|
||||
$include = sportspress_array_value( sportspress_array_value( $data, $season_id, array() ), 'include', 0 );
|
||||
|
||||
if ( ! $include && false ) #todo
|
||||
continue;
|
||||
|
||||
$season_name = sportspress_array_value( $season_names, $season_id, ' ' );
|
||||
|
||||
// Add season name to row
|
||||
$merged[ $season_id ] = array(
|
||||
'name' => $season_name
|
||||
);
|
||||
|
||||
foreach( $season_data as $key => $value ):
|
||||
|
||||
// Use static data if key exists and value is not empty, else use placeholder
|
||||
if ( array_key_exists( $season_id, $data ) && array_key_exists( $key, $data[ $season_id ] ) && $data[ $season_id ][ $key ] != '' ):
|
||||
$merged[ $season_id ][ $key ] = $data[ $season_id ][ $key ];
|
||||
else:
|
||||
$merged[ $season_id ][ $key ] = $value;
|
||||
endif;
|
||||
|
||||
endforeach;
|
||||
|
||||
endforeach;
|
||||
|
||||
if ( $breakdown ):
|
||||
return array( $columns, $data, $placeholders, $merged );
|
||||
else:
|
||||
$labels = array_merge( array( 'name' => __( 'Season', 'sportspress' ) ), $columns );
|
||||
$merged[0] = $labels;
|
||||
return $merged;
|
||||
endif;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( !function_exists( 'sportspress_get_league_table_data' ) ) {
|
||||
function sportspress_get_league_table_data( $post_id, $breakdown = false ) {
|
||||
$league_id = sportspress_get_the_term_id( $post_id, 'sp_league', 0 );
|
||||
$div_id = sportspress_get_the_term_id( $post_id, 'sp_season', 0 );
|
||||
$team_ids = (array)get_post_meta( $post_id, 'sp_team', false );
|
||||
$table_stats = (array)get_post_meta( $post_id, 'sp_teams', true );
|
||||
@@ -1139,6 +1382,12 @@ if ( !function_exists( 'sportspress_get_league_table_data' ) ) {
|
||||
'posts_per_page' => -1,
|
||||
'order' => 'ASC',
|
||||
'tax_query' => array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'id',
|
||||
'terms' => $league_id
|
||||
),
|
||||
array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'field' => 'id',
|
||||
@@ -1341,6 +1590,7 @@ if ( !function_exists( 'sportspress_get_league_table_data' ) ) {
|
||||
|
||||
if ( !function_exists( 'sportspress_get_player_list_data' ) ) {
|
||||
function sportspress_get_player_list_data( $post_id, $breakdown = false ) {
|
||||
$league_id = sportspress_get_the_term_id( $post_id, 'sp_league', 0 );
|
||||
$div_id = sportspress_get_the_term_id( $post_id, 'sp_season', 0 );
|
||||
$team_id = get_post_meta( $post_id, 'sp_team', true );
|
||||
$player_ids = (array)get_post_meta( $post_id, 'sp_player', false );
|
||||
@@ -1379,8 +1629,8 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) {
|
||||
$placeholders[ $player_id ] = array();
|
||||
|
||||
// Add static statistics to placeholders
|
||||
if ( array_key_exists( $team_id, $static ) && array_key_exists( $div_id, $static[ $team_id ] ) ):
|
||||
$placeholders[ $player_id ] = $static[ $team_id ][ $div_id ];
|
||||
if ( array_key_exists( $league_id, $static ) && array_key_exists( $div_id, $static[ $league_id ] ) ):
|
||||
$placeholders[ $player_id ] = $static[ $league_id ][ $div_id ];
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
@@ -1389,6 +1639,12 @@ if ( !function_exists( 'sportspress_get_player_list_data' ) ) {
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'tax_query' => array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'id',
|
||||
'terms' => $league_id
|
||||
),
|
||||
array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'field' => 'id',
|
||||
@@ -1569,7 +1825,7 @@ if ( !function_exists( 'sportspress_get_player_metrics_data' ) ) {
|
||||
}
|
||||
|
||||
if ( !function_exists( 'sportspress_get_player_statistics_data' ) ) {
|
||||
function sportspress_get_player_statistics_data( $post_id, $team_id, $breakdown = false ) {
|
||||
function sportspress_get_player_statistics_data( $post_id, $league_id, $breakdown = false ) {
|
||||
|
||||
$seasons = (array)get_the_terms( $post_id, 'sp_season' );
|
||||
$stats = (array)get_post_meta( $post_id, 'sp_statistics', true );
|
||||
@@ -1590,13 +1846,15 @@ if ( !function_exists( 'sportspress_get_player_statistics_data' ) ) {
|
||||
$tempdata = array();
|
||||
|
||||
// Get all seasons populated with stats where available
|
||||
$tempdata = sportspress_array_combine( $div_ids, sportspress_array_value( $stats, $team_id, array() ) );
|
||||
$tempdata = sportspress_array_combine( $div_ids, sportspress_array_value( $stats, $league_id, array() ) );
|
||||
|
||||
// Get equations from statistics variables
|
||||
$equations = sportspress_get_var_equations( 'sp_statistic' );
|
||||
|
||||
foreach ( $div_ids as $div_id ):
|
||||
|
||||
$team_id = sportspress_array_value( sportspress_array_value( sportspress_array_value( $stats, $league_id, array() ), $div_id, 0 ), 'team', '-1' );
|
||||
|
||||
$totals = array( 'eventsattended' => 0, 'eventsplayed' => 0 );
|
||||
|
||||
foreach ( $statistic_labels as $key => $value ):
|
||||
@@ -1619,6 +1877,12 @@ if ( !function_exists( 'sportspress_get_player_statistics_data' ) ) {
|
||||
)
|
||||
),
|
||||
'tax_query' => array(
|
||||
'relation' => 'AND',
|
||||
array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'field' => 'id',
|
||||
'terms' => $league_id
|
||||
),
|
||||
array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'field' => 'id',
|
||||
@@ -1627,9 +1891,10 @@ if ( !function_exists( 'sportspress_get_player_statistics_data' ) ) {
|
||||
)
|
||||
);
|
||||
$events = get_posts( $args );
|
||||
|
||||
foreach( $events as $event ):
|
||||
$totals['eventsattended']++;
|
||||
$totals['eventsplayed']++; // TODO: create tab for substitutes in sidebar
|
||||
$totals['eventsplayed']++;
|
||||
$team_statistics = (array)get_post_meta( $event->ID, 'sp_players', true );
|
||||
if ( array_key_exists( $team_id, $team_statistics ) ):
|
||||
$players = sportspress_array_value( $team_statistics, $team_id, array() );
|
||||
@@ -1676,8 +1941,20 @@ if ( !function_exists( 'sportspress_get_player_statistics_data' ) ) {
|
||||
|
||||
foreach( $placeholders as $season_id => $season_data ):
|
||||
|
||||
$team_id = sportspress_array_value( sportspress_array_value( $tempdata, $season_id, array() ), 'team', 0 );
|
||||
|
||||
if ( ! $team_id || $team_id == '-1' )
|
||||
continue;
|
||||
|
||||
$team_name = get_the_title( $team_id );
|
||||
|
||||
$season_name = sportspress_array_value( $season_names, $season_id, ' ' );
|
||||
|
||||
// Add season name to row
|
||||
$merged[ $season_id ] = array( 'name' => sportspress_array_value( $season_names, $season_id, ' ' ) );
|
||||
$merged[ $season_id ] = array(
|
||||
'name' => $season_name,
|
||||
'team' => $team_name
|
||||
);
|
||||
|
||||
foreach( $season_data as $key => $value ):
|
||||
|
||||
@@ -1695,7 +1972,7 @@ if ( !function_exists( 'sportspress_get_player_statistics_data' ) ) {
|
||||
if ( $breakdown ):
|
||||
return array( $columns, $tempdata, $placeholders, $merged );
|
||||
else:
|
||||
$labels = array_merge( array( 'name' => __( 'Season', 'sportspress' ) ), $columns );
|
||||
$labels = array_merge( array( 'name' => __( 'Season', 'sportspress' ), 'team' => __( 'Team', 'sportspress' ) ), $columns );
|
||||
$merged[0] = $labels;
|
||||
return $merged;
|
||||
endif;
|
||||
|
||||
@@ -3,202 +3,202 @@ function sportspress_define_countries_global() {
|
||||
global $sportspress_countries;
|
||||
|
||||
$sportspress_countries = array(
|
||||
'AD' => __( "Andorra", 'sportspress' ),
|
||||
'AE' => __( "United Arab Emirates", 'sportspress' ),
|
||||
'AF' => __( "Afghanistan", 'sportspress' ),
|
||||
'AG' => __( "Antigua and Barbuda", 'sportspress' ),
|
||||
'AL' => __( "Albania", 'sportspress' ),
|
||||
'AM' => __( "Armenia", 'sportspress' ),
|
||||
'AO' => __( "Angola", 'sportspress' ),
|
||||
'AR' => __( "Argentina", 'sportspress' ),
|
||||
'AT' => __( "Austria", 'sportspress' ),
|
||||
'AU' => __( "Australia", 'sportspress' ),
|
||||
'AZ' => __( "Azerbaijan", 'sportspress' ),
|
||||
'BA' => __( "Bosnia and Herzegovina", 'sportspress' ),
|
||||
'BB' => __( "Barbados", 'sportspress' ),
|
||||
'BD' => __( "Bangladesh", 'sportspress' ),
|
||||
'BE' => __( "Belgium", 'sportspress' ),
|
||||
'BF' => __( "Burkina Faso", 'sportspress' ),
|
||||
'BG' => __( "Bulgaria", 'sportspress' ),
|
||||
'BH' => __( "Bahrain", 'sportspress' ),
|
||||
'BI' => __( "Burundi", 'sportspress' ),
|
||||
'BJ' => __( "Benin", 'sportspress' ),
|
||||
'BN' => __( "Brunei", 'sportspress' ),
|
||||
'BO' => __( "Bolivia", 'sportspress' ),
|
||||
'BR' => __( "Brazil", 'sportspress' ),
|
||||
'BS' => __( "Bahamas", 'sportspress' ),
|
||||
'BT' => __( "Bhutan", 'sportspress' ),
|
||||
'BW' => __( "Botswana", 'sportspress' ),
|
||||
'BY' => __( "Belarus", 'sportspress' ),
|
||||
'BZ' => __( "Belize", 'sportspress' ),
|
||||
'CA' => __( "Canada", 'sportspress' ),
|
||||
'CD' => __( "Democratic Republic of the Congo", 'sportspress' ),
|
||||
'CF' => __( "Central African Republic", 'sportspress' ),
|
||||
'CG' => __( "Republic of the Congo", 'sportspress' ),
|
||||
'CH' => __( "Switzerland", 'sportspress' ),
|
||||
'CI' => __( "Cote d'Ivoire", 'sportspress' ),
|
||||
'CL' => __( "Chile", 'sportspress' ),
|
||||
'CM' => __( "Cameroon", 'sportspress' ),
|
||||
'CN' => __( "China", 'sportspress' ),
|
||||
'CO' => __( "Colombia", 'sportspress' ),
|
||||
'CR' => __( "Costa Rica", 'sportspress' ),
|
||||
'CU' => __( "Cuba", 'sportspress' ),
|
||||
'CV' => __( "Cape Verde", 'sportspress' ),
|
||||
'CY' => __( "Cyprus", 'sportspress' ),
|
||||
'CZ' => __( "Czech Republic", 'sportspress' ),
|
||||
'DE' => __( "Germany", 'sportspress' ),
|
||||
'DJ' => __( "Djibouti", 'sportspress' ),
|
||||
'DK' => __( "Denmark", 'sportspress' ),
|
||||
'DM' => __( "Dominica", 'sportspress' ),
|
||||
'DO' => __( "Dominican Republic", 'sportspress' ),
|
||||
'DZ' => __( "Algeria", 'sportspress' ),
|
||||
'EC' => __( "Ecuador", 'sportspress' ),
|
||||
'EE' => __( "Estonia", 'sportspress' ),
|
||||
'EG' => __( "Egypt", 'sportspress' ),
|
||||
'EH' => __( "Western Sahara", 'sportspress' ),
|
||||
'ER' => __( "Eritrea", 'sportspress' ),
|
||||
'ES' => __( "Spain", 'sportspress' ),
|
||||
'ET' => __( "Ethiopia", 'sportspress' ),
|
||||
'FI' => __( "Finland", 'sportspress' ),
|
||||
'FJ' => __( "Fiji", 'sportspress' ),
|
||||
'FM' => __( "Micronesia", 'sportspress' ),
|
||||
'FR' => __( "France", 'sportspress' ),
|
||||
'GA' => __( "Gabon", 'sportspress' ),
|
||||
'GB' => __( "United Kingdom", 'sportspress' ),
|
||||
'GD' => __( "Grenada", 'sportspress' ),
|
||||
'GE' => __( "Georgia", 'sportspress' ),
|
||||
'GH' => __( "Ghana", 'sportspress' ),
|
||||
'GM' => __( "Gambia", 'sportspress' ),
|
||||
'GN' => __( "Guinea", 'sportspress' ),
|
||||
'GQ' => __( "Equatorial Guinea", 'sportspress' ),
|
||||
'GR' => __( "Greece", 'sportspress' ),
|
||||
'GT' => __( "Guatemala", 'sportspress' ),
|
||||
'GW' => __( "Guinea-Bissau", 'sportspress' ),
|
||||
'GY' => __( "Guyana", 'sportspress' ),
|
||||
'HK' => __( "Hong Kong", 'sportspress' ),
|
||||
'HN' => __( "Honduras", 'sportspress' ),
|
||||
'HR' => __( "Croatia", 'sportspress' ),
|
||||
'HT' => __( "Haiti", 'sportspress' ),
|
||||
'HU' => __( "Hungary", 'sportspress' ),
|
||||
'ID' => __( "Indonesia", 'sportspress' ),
|
||||
'IE' => __( "Ireland", 'sportspress' ),
|
||||
'IL' => __( "Israel", 'sportspress' ),
|
||||
'IN' => __( "India", 'sportspress' ),
|
||||
'IQ' => __( "Iraq", 'sportspress' ),
|
||||
'IR' => __( "Iran", 'sportspress' ),
|
||||
'IS' => __( "Iceland", 'sportspress' ),
|
||||
'IT' => __( "Italy", 'sportspress' ),
|
||||
'JM' => __( "Jamaica", 'sportspress' ),
|
||||
'JO' => __( "Jordan", 'sportspress' ),
|
||||
'JP' => __( "Japan", 'sportspress' ),
|
||||
'KE' => __( "Kenya", 'sportspress' ),
|
||||
'KG' => __( "Kyrgyzstan", 'sportspress' ),
|
||||
'KH' => __( "Cambodia", 'sportspress' ),
|
||||
'KI' => __( "Kiribati", 'sportspress' ),
|
||||
'KM' => __( "Comoros", 'sportspress' ),
|
||||
'KN' => __( "Saint Kitts and Nevis", 'sportspress' ),
|
||||
'KP' => __( "North Korea", 'sportspress' ),
|
||||
'KR' => __( "South Korea", 'sportspress' ),
|
||||
'KW' => __( "Kuwait", 'sportspress' ),
|
||||
'KZ' => __( "Kazakhstan", 'sportspress' ),
|
||||
'LA' => __( "Laos", 'sportspress' ),
|
||||
'LB' => __( "Lebanon", 'sportspress' ),
|
||||
'LC' => __( "Saint Lucia", 'sportspress' ),
|
||||
'LI' => __( "Liechtenstein", 'sportspress' ),
|
||||
'LK' => __( "Sri Lanka", 'sportspress' ),
|
||||
'LR' => __( "Liberia", 'sportspress' ),
|
||||
'LS' => __( "Lesotho", 'sportspress' ),
|
||||
'LT' => __( "Lithuania", 'sportspress' ),
|
||||
'LU' => __( "Luxembourg", 'sportspress' ),
|
||||
'LV' => __( "Latvia", 'sportspress' ),
|
||||
'LY' => __( "Libya", 'sportspress' ),
|
||||
'MA' => __( "Morocco", 'sportspress' ),
|
||||
'MC' => __( "Monaco", 'sportspress' ),
|
||||
'MD' => __( "Moldova", 'sportspress' ),
|
||||
'ME' => __( "Montenegro", 'sportspress' ),
|
||||
'MG' => __( "Madagascar", 'sportspress' ),
|
||||
'MH' => __( "Marshall Islands", 'sportspress' ),
|
||||
'MK' => __( "Macedonia", 'sportspress' ),
|
||||
'ML' => __( "Mali", 'sportspress' ),
|
||||
'MM' => __( "Myanmar", 'sportspress' ),
|
||||
'MN' => __( "Mongolia", 'sportspress' ),
|
||||
'MO' => __( "Macau", 'sportspress' ),
|
||||
'MR' => __( "Mauritania", 'sportspress' ),
|
||||
'MT' => __( "Malta", 'sportspress' ),
|
||||
'MU' => __( "Mauritius", 'sportspress' ),
|
||||
'MV' => __( "Maldives", 'sportspress' ),
|
||||
'MW' => __( "Malawi", 'sportspress' ),
|
||||
'MX' => __( "Mexico", 'sportspress' ),
|
||||
'MY' => __( "Malaysia", 'sportspress' ),
|
||||
'MZ' => __( "Mozambique", 'sportspress' ),
|
||||
'NA' => __( "Namibia", 'sportspress' ),
|
||||
'NE' => __( "Niger", 'sportspress' ),
|
||||
'NG' => __( "Nigeria", 'sportspress' ),
|
||||
'NI' => __( "Nicaragua", 'sportspress' ),
|
||||
'NL' => __( "Netherlands", 'sportspress' ),
|
||||
'NO' => __( "Norway", 'sportspress' ),
|
||||
'NP' => __( "Nepal", 'sportspress' ),
|
||||
'NR' => __( "Nauru", 'sportspress' ),
|
||||
'NZ' => __( "New Zealand", 'sportspress' ),
|
||||
'OM' => __( "Oman", 'sportspress' ),
|
||||
'PA' => __( "Panama", 'sportspress' ),
|
||||
'PE' => __( "Peru", 'sportspress' ),
|
||||
'PG' => __( "Papua New Guinea", 'sportspress' ),
|
||||
'PH' => __( "Philippines", 'sportspress' ),
|
||||
'PK' => __( "Pakistan", 'sportspress' ),
|
||||
'PL' => __( "Poland", 'sportspress' ),
|
||||
'PT' => __( "Portugal", 'sportspress' ),
|
||||
'PW' => __( "Palau", 'sportspress' ),
|
||||
'PY' => __( "Paraguay", 'sportspress' ),
|
||||
'QA' => __( "Qatar", 'sportspress' ),
|
||||
'RO' => __( "Romania", 'sportspress' ),
|
||||
'RS' => __( "Serbia", 'sportspress' ),
|
||||
'RU' => __( "Russia", 'sportspress' ),
|
||||
'RW' => __( "Rwanda", 'sportspress' ),
|
||||
'SA' => __( "Saudi Arabia", 'sportspress' ),
|
||||
'SB' => __( "Solomon Islands", 'sportspress' ),
|
||||
'SC' => __( "Seychelles", 'sportspress' ),
|
||||
'SD' => __( "Sudan", 'sportspress' ),
|
||||
'SE' => __( "Sweden", 'sportspress' ),
|
||||
'SG' => __( "Singapore", 'sportspress' ),
|
||||
'SI' => __( "Slovenia", 'sportspress' ),
|
||||
'SK' => __( "Slovakia", 'sportspress' ),
|
||||
'SL' => __( "Sierra Leone", 'sportspress' ),
|
||||
'SM' => __( "San Marino", 'sportspress' ),
|
||||
'SN' => __( "Senegal", 'sportspress' ),
|
||||
'SO' => __( "Somalia", 'sportspress' ),
|
||||
'SR' => __( "Suriname", 'sportspress' ),
|
||||
'ST' => __( "Sao Tome and Principe", 'sportspress' ),
|
||||
'SV' => __( "El Salvador", 'sportspress' ),
|
||||
'SZ' => __( "Swaziland", 'sportspress' ),
|
||||
'TD' => __( "Chad", 'sportspress' ),
|
||||
'TG' => __( "Togo", 'sportspress' ),
|
||||
'TH' => __( "Thailand", 'sportspress' ),
|
||||
'TJ' => __( "Tajikistan", 'sportspress' ),
|
||||
'TL' => __( "East Timor", 'sportspress' ),
|
||||
'TM' => __( "Turkmenistan", 'sportspress' ),
|
||||
'TN' => __( "Tunisia", 'sportspress' ),
|
||||
'TO' => __( "Tonga", 'sportspress' ),
|
||||
'TR' => __( "Turkey", 'sportspress' ),
|
||||
'TT' => __( "Trinidad and Tobago", 'sportspress' ),
|
||||
'TV' => __( "Tuvalu", 'sportspress' ),
|
||||
'TW' => __( "Taiwan", 'sportspress' ),
|
||||
'TZ' => __( "Tanzania", 'sportspress' ),
|
||||
'UA' => __( "Ukraine", 'sportspress' ),
|
||||
'UG' => __( "Uganda", 'sportspress' ),
|
||||
'US' => __( "United States", 'sportspress' ),
|
||||
'UY' => __( "Uruguay", 'sportspress' ),
|
||||
'UZ' => __( "Uzbekistan", 'sportspress' ),
|
||||
'VA' => __( "Vatican City", 'sportspress' ),
|
||||
'VC' => __( "Saint Vincent and the Grenadines", 'sportspress' ),
|
||||
'VE' => __( "Venezuela", 'sportspress' ),
|
||||
'VN' => __( "Vietnam", 'sportspress' ),
|
||||
'VU' => __( "Vanuatu", 'sportspress' ),
|
||||
'WS' => __( "Samoa", 'sportspress' ),
|
||||
'YE' => __( "Yemen", 'sportspress' ),
|
||||
'ZA' => __( "South Africa", 'sportspress' ),
|
||||
'ZM' => __( "Zambia", 'sportspress' ),
|
||||
'ZW' => __( "Zimbabwe", 'sportspress' ),
|
||||
'AD' => __( "Andorra", 'countries' ),
|
||||
'AE' => __( "United Arab Emirates", 'countries' ),
|
||||
'AF' => __( "Afghanistan", 'countries' ),
|
||||
'AG' => __( "Antigua and Barbuda", 'countries' ),
|
||||
'AL' => __( "Albania", 'countries' ),
|
||||
'AM' => __( "Armenia", 'countries' ),
|
||||
'AO' => __( "Angola", 'countries' ),
|
||||
'AR' => __( "Argentina", 'countries' ),
|
||||
'AT' => __( "Austria", 'countries' ),
|
||||
'AU' => __( "Australia", 'countries' ),
|
||||
'AZ' => __( "Azerbaijan", 'countries' ),
|
||||
'BA' => __( "Bosnia and Herzegovina", 'countries' ),
|
||||
'BB' => __( "Barbados", 'countries' ),
|
||||
'BD' => __( "Bangladesh", 'countries' ),
|
||||
'BE' => __( "Belgium", 'countries' ),
|
||||
'BF' => __( "Burkina Faso", 'countries' ),
|
||||
'BG' => __( "Bulgaria", 'countries' ),
|
||||
'BH' => __( "Bahrain", 'countries' ),
|
||||
'BI' => __( "Burundi", 'countries' ),
|
||||
'BJ' => __( "Benin", 'countries' ),
|
||||
'BN' => __( "Brunei", 'countries' ),
|
||||
'BO' => __( "Bolivia", 'countries' ),
|
||||
'BR' => __( "Brazil", 'countries' ),
|
||||
'BS' => __( "Bahamas", 'countries' ),
|
||||
'BT' => __( "Bhutan", 'countries' ),
|
||||
'BW' => __( "Botswana", 'countries' ),
|
||||
'BY' => __( "Belarus", 'countries' ),
|
||||
'BZ' => __( "Belize", 'countries' ),
|
||||
'CA' => __( "Canada", 'countries' ),
|
||||
'CD' => __( "Democratic Republic of the Congo", 'countries' ),
|
||||
'CF' => __( "Central African Republic", 'countries' ),
|
||||
'CG' => __( "Republic of the Congo", 'countries' ),
|
||||
'CH' => __( "Switzerland", 'countries' ),
|
||||
'CI' => __( "Cote d'Ivoire", 'countries' ),
|
||||
'CL' => __( "Chile", 'countries' ),
|
||||
'CM' => __( "Cameroon", 'countries' ),
|
||||
'CN' => __( "China", 'countries' ),
|
||||
'CO' => __( "Colombia", 'countries' ),
|
||||
'CR' => __( "Costa Rica", 'countries' ),
|
||||
'CU' => __( "Cuba", 'countries' ),
|
||||
'CV' => __( "Cape Verde", 'countries' ),
|
||||
'CY' => __( "Cyprus", 'countries' ),
|
||||
'CZ' => __( "Czech Republic", 'countries' ),
|
||||
'DE' => __( "Germany", 'countries' ),
|
||||
'DJ' => __( "Djibouti", 'countries' ),
|
||||
'DK' => __( "Denmark", 'countries' ),
|
||||
'DM' => __( "Dominica", 'countries' ),
|
||||
'DO' => __( "Dominican Republic", 'countries' ),
|
||||
'DZ' => __( "Algeria", 'countries' ),
|
||||
'EC' => __( "Ecuador", 'countries' ),
|
||||
'EE' => __( "Estonia", 'countries' ),
|
||||
'EG' => __( "Egypt", 'countries' ),
|
||||
'EH' => __( "Western Sahara", 'countries' ),
|
||||
'ER' => __( "Eritrea", 'countries' ),
|
||||
'ES' => __( "Spain", 'countries' ),
|
||||
'ET' => __( "Ethiopia", 'countries' ),
|
||||
'FI' => __( "Finland", 'countries' ),
|
||||
'FJ' => __( "Fiji", 'countries' ),
|
||||
'FM' => __( "Micronesia", 'countries' ),
|
||||
'FR' => __( "France", 'countries' ),
|
||||
'GA' => __( "Gabon", 'countries' ),
|
||||
'GB' => __( "United Kingdom", 'countries' ),
|
||||
'GD' => __( "Grenada", 'countries' ),
|
||||
'GE' => __( "Georgia", 'countries' ),
|
||||
'GH' => __( "Ghana", 'countries' ),
|
||||
'GM' => __( "Gambia", 'countries' ),
|
||||
'GN' => __( "Guinea", 'countries' ),
|
||||
'GQ' => __( "Equatorial Guinea", 'countries' ),
|
||||
'GR' => __( "Greece", 'countries' ),
|
||||
'GT' => __( "Guatemala", 'countries' ),
|
||||
'GW' => __( "Guinea-Bissau", 'countries' ),
|
||||
'GY' => __( "Guyana", 'countries' ),
|
||||
'HK' => __( "Hong Kong", 'countries' ),
|
||||
'HN' => __( "Honduras", 'countries' ),
|
||||
'HR' => __( "Croatia", 'countries' ),
|
||||
'HT' => __( "Haiti", 'countries' ),
|
||||
'HU' => __( "Hungary", 'countries' ),
|
||||
'ID' => __( "Indonesia", 'countries' ),
|
||||
'IE' => __( "Ireland", 'countries' ),
|
||||
'IL' => __( "Israel", 'countries' ),
|
||||
'IN' => __( "India", 'countries' ),
|
||||
'IQ' => __( "Iraq", 'countries' ),
|
||||
'IR' => __( "Iran", 'countries' ),
|
||||
'IS' => __( "Iceland", 'countries' ),
|
||||
'IT' => __( "Italy", 'countries' ),
|
||||
'JM' => __( "Jamaica", 'countries' ),
|
||||
'JO' => __( "Jordan", 'countries' ),
|
||||
'JP' => __( "Japan", 'countries' ),
|
||||
'KE' => __( "Kenya", 'countries' ),
|
||||
'KG' => __( "Kyrgyzstan", 'countries' ),
|
||||
'KH' => __( "Cambodia", 'countries' ),
|
||||
'KI' => __( "Kiribati", 'countries' ),
|
||||
'KM' => __( "Comoros", 'countries' ),
|
||||
'KN' => __( "Saint Kitts and Nevis", 'countries' ),
|
||||
'KP' => __( "North Korea", 'countries' ),
|
||||
'KR' => __( "South Korea", 'countries' ),
|
||||
'KW' => __( "Kuwait", 'countries' ),
|
||||
'KZ' => __( "Kazakhstan", 'countries' ),
|
||||
'LA' => __( "Laos", 'countries' ),
|
||||
'LB' => __( "Lebanon", 'countries' ),
|
||||
'LC' => __( "Saint Lucia", 'countries' ),
|
||||
'LI' => __( "Liechtenstein", 'countries' ),
|
||||
'LK' => __( "Sri Lanka", 'countries' ),
|
||||
'LR' => __( "Liberia", 'countries' ),
|
||||
'LS' => __( "Lesotho", 'countries' ),
|
||||
'LT' => __( "Lithuania", 'countries' ),
|
||||
'LU' => __( "Luxembourg", 'countries' ),
|
||||
'LV' => __( "Latvia", 'countries' ),
|
||||
'LY' => __( "Libya", 'countries' ),
|
||||
'MA' => __( "Morocco", 'countries' ),
|
||||
'MC' => __( "Monaco", 'countries' ),
|
||||
'MD' => __( "Moldova", 'countries' ),
|
||||
'ME' => __( "Montenegro", 'countries' ),
|
||||
'MG' => __( "Madagascar", 'countries' ),
|
||||
'MH' => __( "Marshall Islands", 'countries' ),
|
||||
'MK' => __( "Macedonia", 'countries' ),
|
||||
'ML' => __( "Mali", 'countries' ),
|
||||
'MM' => __( "Myanmar", 'countries' ),
|
||||
'MN' => __( "Mongolia", 'countries' ),
|
||||
'MO' => __( "Macau", 'countries' ),
|
||||
'MR' => __( "Mauritania", 'countries' ),
|
||||
'MT' => __( "Malta", 'countries' ),
|
||||
'MU' => __( "Mauritius", 'countries' ),
|
||||
'MV' => __( "Maldives", 'countries' ),
|
||||
'MW' => __( "Malawi", 'countries' ),
|
||||
'MX' => __( "Mexico", 'countries' ),
|
||||
'MY' => __( "Malaysia", 'countries' ),
|
||||
'MZ' => __( "Mozambique", 'countries' ),
|
||||
'NA' => __( "Namibia", 'countries' ),
|
||||
'NE' => __( "Niger", 'countries' ),
|
||||
'NG' => __( "Nigeria", 'countries' ),
|
||||
'NI' => __( "Nicaragua", 'countries' ),
|
||||
'NL' => __( "Netherlands", 'countries' ),
|
||||
'NO' => __( "Norway", 'countries' ),
|
||||
'NP' => __( "Nepal", 'countries' ),
|
||||
'NR' => __( "Nauru", 'countries' ),
|
||||
'NZ' => __( "New Zealand", 'countries' ),
|
||||
'OM' => __( "Oman", 'countries' ),
|
||||
'PA' => __( "Panama", 'countries' ),
|
||||
'PE' => __( "Peru", 'countries' ),
|
||||
'PG' => __( "Papua New Guinea", 'countries' ),
|
||||
'PH' => __( "Philippines", 'countries' ),
|
||||
'PK' => __( "Pakistan", 'countries' ),
|
||||
'PL' => __( "Poland", 'countries' ),
|
||||
'PT' => __( "Portugal", 'countries' ),
|
||||
'PW' => __( "Palau", 'countries' ),
|
||||
'PY' => __( "Paraguay", 'countries' ),
|
||||
'QA' => __( "Qatar", 'countries' ),
|
||||
'RO' => __( "Romania", 'countries' ),
|
||||
'RS' => __( "Serbia", 'countries' ),
|
||||
'RU' => __( "Russia", 'countries' ),
|
||||
'RW' => __( "Rwanda", 'countries' ),
|
||||
'SA' => __( "Saudi Arabia", 'countries' ),
|
||||
'SB' => __( "Solomon Islands", 'countries' ),
|
||||
'SC' => __( "Seychelles", 'countries' ),
|
||||
'SD' => __( "Sudan", 'countries' ),
|
||||
'SE' => __( "Sweden", 'countries' ),
|
||||
'SG' => __( "Singapore", 'countries' ),
|
||||
'SI' => __( "Slovenia", 'countries' ),
|
||||
'SK' => __( "Slovakia", 'countries' ),
|
||||
'SL' => __( "Sierra Leone", 'countries' ),
|
||||
'SM' => __( "San Marino", 'countries' ),
|
||||
'SN' => __( "Senegal", 'countries' ),
|
||||
'SO' => __( "Somalia", 'countries' ),
|
||||
'SR' => __( "Suriname", 'countries' ),
|
||||
'ST' => __( "Sao Tome and Principe", 'countries' ),
|
||||
'SV' => __( "El Salvador", 'countries' ),
|
||||
'SZ' => __( "Swaziland", 'countries' ),
|
||||
'TD' => __( "Chad", 'countries' ),
|
||||
'TG' => __( "Togo", 'countries' ),
|
||||
'TH' => __( "Thailand", 'countries' ),
|
||||
'TJ' => __( "Tajikistan", 'countries' ),
|
||||
'TL' => __( "East Timor", 'countries' ),
|
||||
'TM' => __( "Turkmenistan", 'countries' ),
|
||||
'TN' => __( "Tunisia", 'countries' ),
|
||||
'TO' => __( "Tonga", 'countries' ),
|
||||
'TR' => __( "Turkey", 'countries' ),
|
||||
'TT' => __( "Trinidad and Tobago", 'countries' ),
|
||||
'TV' => __( "Tuvalu", 'countries' ),
|
||||
'TW' => __( "Taiwan", 'countries' ),
|
||||
'TZ' => __( "Tanzania", 'countries' ),
|
||||
'UA' => __( "Ukraine", 'countries' ),
|
||||
'UG' => __( "Uganda", 'countries' ),
|
||||
'US' => __( "United States", 'countries' ),
|
||||
'UY' => __( "Uruguay", 'countries' ),
|
||||
'UZ' => __( "Uzbekistan", 'countries' ),
|
||||
'VA' => __( "Vatican City", 'countries' ),
|
||||
'VC' => __( "Saint Vincent and the Grenadines", 'countries' ),
|
||||
'VE' => __( "Venezuela", 'countries' ),
|
||||
'VN' => __( "Vietnam", 'countries' ),
|
||||
'VU' => __( "Vanuatu", 'countries' ),
|
||||
'WS' => __( "Samoa", 'countries' ),
|
||||
'YE' => __( "Yemen", 'countries' ),
|
||||
'ZA' => __( "South Africa", 'countries' ),
|
||||
'ZM' => __( "Zambia", 'countries' ),
|
||||
'ZW' => __( "Zimbabwe", 'countries' ),
|
||||
);
|
||||
|
||||
asort( $sportspress_countries );
|
||||
|
||||
@@ -24,11 +24,17 @@ function sportspress_admin_menu( $position ) {
|
||||
$menu[ $position ] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
|
||||
endif;
|
||||
|
||||
// Remove "Seasons" link from Players submenu
|
||||
// Remove "Leagues" link from Players submenu
|
||||
unset( $submenu['edit.php?post_type=sp_player'][15] );
|
||||
|
||||
// Remove "Seasons" link from Staff submenu
|
||||
// Remove "Seasons" link from Players submenu
|
||||
unset( $submenu['edit.php?post_type=sp_player'][16] );
|
||||
|
||||
// Remove "Leagues" link from Staff submenu
|
||||
unset( $submenu['edit.php?post_type=sp_staff'][15] );
|
||||
|
||||
// Remove "Seasons" link from Staff submenu
|
||||
unset( $submenu['edit.php?post_type=sp_staff'][16] );
|
||||
|
||||
}
|
||||
add_action( 'admin_menu', 'sportspress_admin_menu' );
|
||||
add_action( 'admin_menu', 'sportspress_admin_menu' );
|
||||
|
||||
@@ -69,6 +69,9 @@ function sportspress_manage_posts_custom_column( $column, $post_id ) {
|
||||
case 'sp_event':
|
||||
echo get_post_meta ( $post_id, 'sp_event' ) ? sizeof( get_post_meta ( $post_id, 'sp_event' ) ) : '—';
|
||||
break;
|
||||
case 'sp_league':
|
||||
echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—';
|
||||
break;
|
||||
case 'sp_season':
|
||||
echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—';
|
||||
break;
|
||||
|
||||
@@ -32,6 +32,9 @@ function sportspress_save_post( $post_id ) {
|
||||
// Update staff array
|
||||
sportspress_update_post_meta_recursive( $post_id, 'sp_staff', sportspress_array_value( $_POST, 'sp_staff', array() ) );
|
||||
|
||||
// Update league taxonomy
|
||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
|
||||
|
||||
// Update season taxonomy
|
||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
||||
|
||||
@@ -113,6 +116,9 @@ function sportspress_save_post( $post_id ) {
|
||||
// Update teams array
|
||||
update_post_meta( $post_id, 'sp_teams', sportspress_array_value( $_POST, 'sp_teams', array() ) );
|
||||
|
||||
// Update league taxonomy
|
||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
|
||||
|
||||
// Update season taxonomy
|
||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
||||
|
||||
@@ -129,6 +135,9 @@ function sportspress_save_post( $post_id ) {
|
||||
// Update team array
|
||||
update_post_meta( $post_id, 'sp_team', sportspress_array_value( $_POST, 'sp_team', array() ) );
|
||||
|
||||
// Update league taxonomy
|
||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_league', 0 ), 'sp_league' );
|
||||
|
||||
// Update season taxonomy
|
||||
wp_set_post_terms( $post_id, sportspress_array_value( $_POST, 'sp_season', 0 ), 'sp_season' );
|
||||
|
||||
|
||||
@@ -1,10 +1,30 @@
|
||||
<?php
|
||||
function sportspress_the_content( $content ) {
|
||||
if ( is_singular( 'sp_team' ) && in_the_loop() ):
|
||||
|
||||
if ( is_singular( 'sp_event' ) && in_the_loop() ):
|
||||
|
||||
global $post;
|
||||
|
||||
// Display event details
|
||||
$content = sportspress_event_details( $post->ID ) . $content;
|
||||
|
||||
elseif ( is_singular( 'sp_calendar' ) && in_the_loop() ):
|
||||
|
||||
global $post;
|
||||
|
||||
// Display events calendar
|
||||
$content = sportspress_events_calendar( $post->ID ) . $content;
|
||||
|
||||
elseif ( is_singular( 'sp_team' ) && in_the_loop() ):
|
||||
|
||||
global $post;
|
||||
|
||||
// Display team columns
|
||||
$content = sportspress_team_columns( $post->ID ) . $content;
|
||||
|
||||
elseif ( is_singular( 'sp_table' ) && in_the_loop() ):
|
||||
|
||||
global $post;
|
||||
global $post;
|
||||
|
||||
// Display league table
|
||||
$content = sportspress_league_table( $post->ID ) . $content;
|
||||
@@ -21,7 +41,7 @@ function sportspress_the_content( $content ) {
|
||||
|
||||
global $post;
|
||||
|
||||
// Display player list
|
||||
// Display player metrics and statistics
|
||||
$content = sportspress_player_metrics( $post->ID ) . sportspress_player_statistics( $post->ID ) . $content;
|
||||
|
||||
endif;
|
||||
|
||||
@@ -24,8 +24,9 @@ function sportspress_calendar_edit_columns() {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
'sp_venue' => __( 'Venues', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
|
||||
@@ -45,18 +45,33 @@ function sportspress_event_meta_init( $post ) {
|
||||
}
|
||||
|
||||
function sportspress_event_details_meta( $post ) {
|
||||
$league_id = sportspress_get_the_term_id( $post->ID, 'sp_league', 0 );
|
||||
$season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
|
||||
$venue_id = sportspress_get_the_term_id( $post->ID, 'sp_venue', 0 );
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $league_id,
|
||||
'value' => 'term_id',
|
||||
'show_option_none' => __( '-- Not set --', 'sportspress' ),
|
||||
);
|
||||
sportspress_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
|
||||
<p class="sp-tab-select" data-sp-target="sp_teamdiv">
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $season_id,
|
||||
'value' => 'term_id',
|
||||
'show_option_none' => __( '-- Not set --', 'sportspress' ),
|
||||
);
|
||||
sportspress_dropdown_taxonomies( $args );
|
||||
?>
|
||||
@@ -69,6 +84,7 @@ function sportspress_event_details_meta( $post ) {
|
||||
'name' => 'sp_venue',
|
||||
'selected' => $venue_id,
|
||||
'value' => 'term_id',
|
||||
'show_option_none' => __( '-- Not set --', 'sportspress' ),
|
||||
);
|
||||
sportspress_dropdown_taxonomies( $args );
|
||||
?>
|
||||
@@ -79,7 +95,6 @@ function sportspress_event_details_meta( $post ) {
|
||||
|
||||
function sportspress_event_team_meta( $post ) {
|
||||
$teams = (array)get_post_meta( $post->ID, 'sp_team', false );
|
||||
$players = (array)get_post_meta( $post->ID, 'sp_player', false );
|
||||
foreach ( $teams as $key => $value ):
|
||||
?>
|
||||
<div class="sp-clone">
|
||||
@@ -177,8 +192,9 @@ function sportspress_event_edit_columns() {
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Event', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
'sp_venue' => __( 'Venues', 'sportspress' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_venue' => __( 'Venue', 'sportspress' ),
|
||||
'sp_kickoff' => __( 'Date/Time', 'sportspress' )
|
||||
);
|
||||
return $columns;
|
||||
|
||||
@@ -25,8 +25,9 @@ function sportspress_list_edit_columns() {
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title' ),
|
||||
'sp_player' => __( 'Players', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' )
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_team' => __( 'Team', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
@@ -44,10 +45,23 @@ function sportspress_list_meta_init( $post ) {
|
||||
}
|
||||
|
||||
function sportspress_list_player_meta( $post ) {
|
||||
$league_id = sportspress_get_the_term_id( $post->ID, 'sp_league', 0 );
|
||||
$season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
|
||||
$team_id = get_post_meta( $post->ID, 'sp_team', true );
|
||||
?>
|
||||
<div>
|
||||
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $league_id,
|
||||
'value' => 'term_id'
|
||||
);
|
||||
sportspress_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
|
||||
<p class="sp-tab-select">
|
||||
<?php
|
||||
|
||||
@@ -25,6 +25,7 @@ function sportspress_player_edit_columns() {
|
||||
'title' => __( 'Name', 'sportspress' ),
|
||||
'sp_position' => __( 'Positions', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
@@ -32,12 +33,9 @@ function sportspress_player_edit_columns() {
|
||||
add_filter( 'manage_edit-sp_player_columns', 'sportspress_player_edit_columns' );
|
||||
|
||||
function sportspress_player_meta_init( $post ) {
|
||||
$teams = (array)get_post_meta( $post->ID, 'sp_team', false );
|
||||
$leagues = get_the_terms( $post->ID, 'sp_league' );
|
||||
$seasons = (array)get_the_terms( $post->ID, 'sp_season' );
|
||||
|
||||
// First one is empty
|
||||
unset( $teams[0] );
|
||||
|
||||
remove_meta_box( 'submitdiv', 'sp_player', 'side' );
|
||||
add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'sp_player', 'side', 'high' );
|
||||
remove_meta_box( 'postimagediv', 'sp_player', 'side' );
|
||||
@@ -45,7 +43,7 @@ function sportspress_player_meta_init( $post ) {
|
||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'sportspress_player_details_meta', 'sp_player', 'side', 'high' );
|
||||
add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sportspress_player_team_meta', 'sp_player', 'side', 'high' );
|
||||
|
||||
if ( $teams && ! empty( $teams ) && $seasons && is_array( $seasons ) && is_object( $seasons[0] ) ):
|
||||
if ( $leagues && ! empty( $leagues ) && $seasons && is_array( $seasons ) && is_object( $seasons[0] ) ):
|
||||
add_meta_box( 'sp_statsdiv', __( 'Player Statistics', 'sportspress' ), 'sportspress_player_stats_meta', 'sp_player', 'normal', 'high' );
|
||||
endif;
|
||||
|
||||
@@ -98,28 +96,22 @@ function sportspress_player_team_meta( $post ) {
|
||||
}
|
||||
|
||||
function sportspress_player_stats_meta( $post ) {
|
||||
$team_ids = (array)get_post_meta( $post->ID, 'sp_team', false );
|
||||
$leagues = get_the_terms( $post->ID, 'sp_league' );
|
||||
|
||||
// First one is empty
|
||||
unset( $team_ids[0] );
|
||||
$league_num = sizeof( $leagues );
|
||||
|
||||
// Initialize placeholders array
|
||||
$placeholders = array();
|
||||
|
||||
$team_num = sizeof( $team_ids );
|
||||
|
||||
// Loop through statistics for each team
|
||||
foreach ( $team_ids as $team_id ):
|
||||
// Loop through statistics for each league
|
||||
foreach ( $leagues as $league ):
|
||||
|
||||
if ( $team_num > 1 ):
|
||||
if ( $league_num > 1 ):
|
||||
?>
|
||||
<p><strong><?php echo get_the_title( $team_id ); ?></strong></p>
|
||||
<p><strong><?php echo $league->name; ?></strong></p>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
list( $columns, $data, $placeholders, $merged ) = sportspress_get_player_statistics_data( $post->ID, $team_id, true );
|
||||
list( $columns, $data, $placeholders, $merged ) = sportspress_get_player_statistics_data( $post->ID, $league->term_id, true );
|
||||
|
||||
sportspress_edit_player_statistics_table( $team_id, $columns, $data, $placeholders );
|
||||
sportspress_edit_player_statistics_table( $league->term_id, $columns, $data, $placeholders );
|
||||
|
||||
endforeach;
|
||||
}
|
||||
|
||||
@@ -43,6 +43,7 @@ function sportspress_staff_edit_columns() {
|
||||
'title' => __( 'Name', 'sportspress' ),
|
||||
'sp_position' => __( 'Positions', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
|
||||
@@ -24,8 +24,9 @@ function sportspress_table_edit_columns() {
|
||||
$columns = array(
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'title' => __( 'Title' ),
|
||||
'sp_league' => __( 'League', 'sportspress' ),
|
||||
'sp_season' => __( 'Season', 'sportspress' ),
|
||||
'sp_team' => __( 'Teams', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
@@ -43,20 +44,35 @@ function sportspress_table_meta_init( $post ) {
|
||||
}
|
||||
|
||||
function sportspress_table_team_meta( $post, $test ) {
|
||||
$league_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
|
||||
$league_id = sportspress_get_the_term_id( $post->ID, 'sp_league', 0 );
|
||||
$season_id = sportspress_get_the_term_id( $post->ID, 'sp_season', 0 );
|
||||
?>
|
||||
<div>
|
||||
<p class="sp-tab-select">
|
||||
<p><strong><?php _e( 'League', 'sportspress' ); ?></strong></p>
|
||||
<p>
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'taxonomy' => 'sp_league',
|
||||
'name' => 'sp_league',
|
||||
'selected' => $league_id,
|
||||
'value' => 'term_id'
|
||||
);
|
||||
sportspress_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Season', 'sportspress' ); ?></strong></p>
|
||||
<p class="sp-tab-select">
|
||||
<?php
|
||||
$args = array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'name' => 'sp_season',
|
||||
'selected' => $season_id,
|
||||
'value' => 'term_id'
|
||||
);
|
||||
sportspress_dropdown_taxonomies( $args );
|
||||
?>
|
||||
</p>
|
||||
<p><strong><?php _e( 'Teams', 'sportspress' ); ?></strong></p>
|
||||
<?php
|
||||
sportspress_post_checklist( $post->ID, 'sp_team', 'block', 'sp_season' );
|
||||
sportspress_post_adder( 'sp_team' );
|
||||
|
||||
@@ -20,14 +20,15 @@ function sportspress_team_post_init() {
|
||||
add_action( 'init', 'sportspress_team_post_init' );
|
||||
|
||||
function sportspress_team_meta_init( $post ) {
|
||||
$leagues = (array)get_the_terms( $post->ID, 'sp_season' );
|
||||
$leagues = (array)get_the_terms( $post->ID, 'sp_league' );
|
||||
$seasons = (array)get_the_terms( $post->ID, 'sp_season' );
|
||||
|
||||
remove_meta_box( 'submitdiv', 'sp_team', 'side' );
|
||||
add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'sp_team', 'side', 'high' );
|
||||
remove_meta_box( 'postimagediv', 'sp_team', 'side' );
|
||||
add_meta_box( 'postimagediv', __( 'Logo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_team', 'side', 'high' );
|
||||
|
||||
if ( $leagues && $leagues != array(0) ):
|
||||
if ( $leagues && $leagues != array(0) && $seasons && $seasons != array(0) ):
|
||||
add_meta_box( 'sp_columnssdiv', __( 'Table Columns', 'sportspress' ), 'sportspress_team_columns_meta', 'sp_team', 'normal', 'high' );
|
||||
endif;
|
||||
}
|
||||
@@ -37,165 +38,32 @@ function sportspress_team_edit_columns() {
|
||||
'cb' => '<input type="checkbox" />',
|
||||
'sp_logo' => ' ',
|
||||
'title' => __( 'Team', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' )
|
||||
'sp_league' => __( 'Leagues', 'sportspress' ),
|
||||
'sp_season' => __( 'Seasons', 'sportspress' ),
|
||||
);
|
||||
return $columns;
|
||||
}
|
||||
add_filter( 'manage_edit-sp_team_columns', 'sportspress_team_edit_columns' );
|
||||
|
||||
function sportspress_team_columns_meta( $post ) {
|
||||
$leagues = (array)get_the_terms( $post->ID, 'sp_season' );
|
||||
$columns = (array)get_post_meta( $post->ID, 'sp_columns', true );
|
||||
$leagues = (array)get_the_terms( $post->ID, 'sp_league' );
|
||||
|
||||
// Equation Operating System
|
||||
$eos = new eqEOS();
|
||||
$league_num = sizeof( $leagues );
|
||||
|
||||
// Get labels from result variables
|
||||
$result_labels = (array)sportspress_get_var_labels( 'sp_result' );
|
||||
|
||||
// Get labels from outcome variables
|
||||
$outcome_labels = (array)sportspress_get_var_labels( 'sp_outcome' );
|
||||
|
||||
// Generate array of all league ids
|
||||
$div_ids = array();
|
||||
foreach ( $leagues as $key => $value ):
|
||||
if ( is_object( $value ) && property_exists( $value, 'term_id' ) )
|
||||
$div_ids[] = $value->term_id;
|
||||
endforeach;
|
||||
|
||||
// Get all leagues populated with columns where available
|
||||
$data = sportspress_array_combine( $div_ids, $columns );
|
||||
|
||||
// Get equations from column variables
|
||||
$equations = sportspress_get_var_equations( 'sp_column' );
|
||||
|
||||
// Initialize placeholders array
|
||||
$placeholders = array();
|
||||
|
||||
foreach ( $div_ids as $div_id ):
|
||||
|
||||
$totals = array( 'eventsplayed' => 0, 'streak' => 0, 'last10' => null );
|
||||
|
||||
foreach ( $result_labels as $key => $value ):
|
||||
$totals[ $key . 'for' ] = 0;
|
||||
$totals[ $key . 'against' ] = 0;
|
||||
endforeach;
|
||||
|
||||
foreach ( $outcome_labels as $key => $value ):
|
||||
$totals[ $key ] = 0;
|
||||
endforeach;
|
||||
|
||||
// Initialize streaks counter
|
||||
$streak = array( 'name' => '', 'count' => 0, 'fire' => 1 );
|
||||
|
||||
// Initialize last 10 counter
|
||||
$last10 = array();
|
||||
|
||||
// Add outcome types to last 10 counter
|
||||
foreach( $outcome_labels as $key => $value ):
|
||||
$last10[ $key ] = 0;
|
||||
endforeach;
|
||||
|
||||
// Get all events involving the team in current season
|
||||
$args = array(
|
||||
'post_type' => 'sp_event',
|
||||
'numberposts' => -1,
|
||||
'posts_per_page' => -1,
|
||||
'order' => 'ASC',
|
||||
'meta_query' => array(
|
||||
array(
|
||||
'key' => 'sp_team',
|
||||
'value' => $post->ID
|
||||
)
|
||||
),
|
||||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => 'sp_season',
|
||||
'field' => 'id',
|
||||
'terms' => $div_id
|
||||
)
|
||||
)
|
||||
);
|
||||
$events = get_posts( $args );
|
||||
|
||||
foreach( $events as $event ):
|
||||
$results = (array)get_post_meta( $event->ID, 'sp_results', true );
|
||||
foreach ( $results as $team_id => $team_result ):
|
||||
foreach ( $team_result as $key => $value ):
|
||||
if ( $team_id == $post->ID ):
|
||||
if ( $key == 'outcome' ):
|
||||
|
||||
// Increment events played and outcome count
|
||||
if ( array_key_exists( $value, $totals ) ):
|
||||
$totals['eventsplayed']++;
|
||||
$totals[ $value ]++;
|
||||
endif;
|
||||
|
||||
if ( $value && $value != '-1' ):
|
||||
|
||||
// Add to streak counter
|
||||
if ( $streak['fire'] && ( $streak['name'] == '' || $streak['name'] == $value ) ):
|
||||
$streak['name'] = $value;
|
||||
$streak['count'] ++;
|
||||
else:
|
||||
$streak['fire'] = 0;
|
||||
endif;
|
||||
|
||||
// Add to last 10 counter if sum is less than 10
|
||||
if ( array_key_exists( $value, $last10 ) && array_sum( $last10 ) < 10 ):
|
||||
$last10[ $value ] ++;
|
||||
endif;
|
||||
|
||||
endif;
|
||||
|
||||
else:
|
||||
if ( array_key_exists( $key . 'for', $totals ) ):
|
||||
$totals[ $key . 'for' ] += $value;
|
||||
endif;
|
||||
endif;
|
||||
else:
|
||||
if ( $key != 'outcome' ):
|
||||
if ( array_key_exists( $key . 'against', $totals ) ):
|
||||
$totals[ $key . 'against' ] += $value;
|
||||
endif;
|
||||
endif;
|
||||
endif;
|
||||
endforeach;
|
||||
endforeach;
|
||||
endforeach;
|
||||
|
||||
// Compile streaks counter and add to totals
|
||||
$args=array(
|
||||
'name' => $streak['name'],
|
||||
'post_type' => 'sp_outcome',
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => 1
|
||||
);
|
||||
$outcomes = get_posts( $args );
|
||||
|
||||
if ( $outcomes ):
|
||||
$outcome = $outcomes[0];
|
||||
$totals['streak'] = $outcome->post_title . $streak['count'];
|
||||
// Loop through statistics for each league
|
||||
foreach ( $leagues as $league ):
|
||||
|
||||
if ( $league_num > 1 ):
|
||||
?>
|
||||
<p><strong><?php echo $league->name; ?></strong></p>
|
||||
<?php
|
||||
endif;
|
||||
|
||||
// Add last 10 to totals
|
||||
$totals['last10'] = $last10;
|
||||
list( $columns, $data, $placeholders, $merged ) = sportspress_get_team_columns_data( $post->ID, $league->term_id, true );
|
||||
|
||||
// Generate array of placeholder values for each league
|
||||
$placeholders[ $div_id ] = array();
|
||||
foreach ( $equations as $key => $value ):
|
||||
if ( $totals['eventsplayed'] > 0 ):
|
||||
$placeholders[ $div_id ][ $key ] = sportspress_solve( $value, $totals );
|
||||
else:
|
||||
$placeholders[ $div_id ][ $key ] = 0;
|
||||
endif;
|
||||
endforeach;
|
||||
sportspress_edit_team_columns_table( $columns, $data, $placeholders );
|
||||
|
||||
endforeach;
|
||||
|
||||
// Get columns from statistics variables
|
||||
$columns = sportspress_get_var_labels( 'sp_column' );
|
||||
|
||||
sportspress_edit_team_columns_table( $columns, $data, $placeholders );
|
||||
sportspress_nonce();
|
||||
}
|
||||
|
||||
21
admin/terms/league.php
Normal file
21
admin/terms/league.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
function sportspress_league_term_init() {
|
||||
$name = __( 'Leagues', 'sportspress' );
|
||||
$singular_name = __( 'League', 'sportspress' );
|
||||
$lowercase_name = __( 'league', 'sportspress' );
|
||||
$object_type = array( 'sp_calendar', 'sp_team', 'sp_player', 'sp_staff' );
|
||||
$labels = sportspress_get_term_labels( $name, $singular_name, $lowercase_name );
|
||||
$args = array(
|
||||
'label' => $name,
|
||||
'labels' => $labels,
|
||||
'public' => true,
|
||||
'hierarchical' => true,
|
||||
'rewrite' => array( 'slug' => 'league' )
|
||||
);
|
||||
register_taxonomy( 'sp_league', $object_type, $args );
|
||||
register_taxonomy_for_object_type( 'sp_league', 'sp_calendar' );
|
||||
register_taxonomy_for_object_type( 'sp_league', 'sp_team' );
|
||||
register_taxonomy_for_object_type( 'sp_league', 'sp_player' );
|
||||
register_taxonomy_for_object_type( 'sp_league', 'sp_staff' );
|
||||
}
|
||||
add_action( 'init', 'sportspress_league_term_init' );
|
||||
228
functions.php
228
functions.php
@@ -1,4 +1,153 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_event_details' ) ) {
|
||||
function sportspress_event_details( $id ) {
|
||||
|
||||
$teams = (array)get_post_meta( $id, 'sp_team', false );
|
||||
$staff = (array)get_post_meta( $id, 'sp_staff', false );
|
||||
$stats = (array)get_post_meta( $id, 'sp_players', true );
|
||||
$results = sportspress_array_combine( $teams, (array)get_post_meta( $id, 'sp_results', true ) );
|
||||
$statistic_labels = sportspress_get_var_labels( 'sp_statistic' );
|
||||
$result_labels = sportspress_get_var_labels( 'sp_result' );
|
||||
|
||||
$output = '';
|
||||
|
||||
foreach( $teams as $key => $team_id ):
|
||||
if ( ! $team_id ) continue;
|
||||
|
||||
// Get results for players in the team
|
||||
$players = sportspress_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $key );
|
||||
$data = sportspress_array_combine( $players, sportspress_array_value( $stats, $team_id, array() ) );
|
||||
|
||||
$output .= '<h3>' . get_the_title( $team_id ) . '</h3>';
|
||||
|
||||
$output .= '<table class="sp-event-statistics sp-data-table">' . '<thead>' . '<tr>';
|
||||
|
||||
$output .= '<th class="column-number">' . __( '#', 'sportspress' ) . '</th>';
|
||||
$output .= '<th class="column-number">' . __( 'Player', 'sportspress' ) . '</th>';
|
||||
|
||||
foreach( $statistic_labels as $key => $label ):
|
||||
$output .= '<th class="column-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $data as $player_id => $row ):
|
||||
|
||||
if ( ! $player_id )
|
||||
continue;
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
|
||||
// Player number
|
||||
$output .= '<td class="column-number">' . $number . '</td>';
|
||||
|
||||
// Name as link
|
||||
$permalink = get_post_permalink( $player_id );
|
||||
$name = get_the_title( $player_id );
|
||||
$output .= '<td class="column-name">' . '<a href="' . $permalink . '">' . $name . '</a></td>';
|
||||
|
||||
foreach( $statistic_labels as $key => $label ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
|
||||
$value = $row[ $key ];
|
||||
else:
|
||||
$value = 0;
|
||||
endif;
|
||||
$output .= '<td class="column-' . $key . '">' . $value . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>';
|
||||
|
||||
if ( array_key_exists( 0, $data ) ):
|
||||
|
||||
$output .= '</tfoot><tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
|
||||
// Player number
|
||||
$output .= '<th class="column-number"> </th>';
|
||||
$output .= '<th class="column-name">' . __( 'Total', 'sportspress' ) . '</th>';
|
||||
|
||||
$row = $data[0];
|
||||
|
||||
foreach( $statistic_labels as $key => $label ):
|
||||
if ( $key == 'name' ):
|
||||
continue;
|
||||
endif;
|
||||
$output .= '<th class="column-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr></tfoot>';
|
||||
|
||||
endif;
|
||||
|
||||
$output .= '</table>';
|
||||
|
||||
endforeach;
|
||||
|
||||
// Initialize and check
|
||||
$table_rows = '';
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $results as $team_id => $result ):
|
||||
if ( sportspress_array_value( $result, 'outcome', '-1' ) != '-1' ):
|
||||
|
||||
unset( $result['outcome'] );
|
||||
|
||||
$table_rows .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
$table_rows .= '<td class="column_name">' . get_the_title( $team_id ) . '</td>';
|
||||
|
||||
foreach( $result_labels as $key => $label ):
|
||||
if ( $key == 'name' )
|
||||
continue;
|
||||
if ( array_key_exists( $key, $result ) && $result[ $key ] != '' ):
|
||||
$value = $result[ $key ];
|
||||
else:
|
||||
$value = '—';
|
||||
endif;
|
||||
$table_rows .= '<td class="column-' . $key . '">' . $value . '</td>';
|
||||
endforeach;
|
||||
|
||||
$table_rows .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endif;
|
||||
endforeach;
|
||||
|
||||
if ( ! empty( $table_rows ) ):
|
||||
|
||||
$output .= '<h3>' . __( 'Results', 'sportspress' ) . '</h3>';
|
||||
|
||||
$output .= '<table class="sp-event-results sp-data-table"><thead>';
|
||||
$output .= '<th class="column-name">' . __( 'Team', 'sportspress' ) . '</th>';
|
||||
foreach( $result_labels as $key => $label ):
|
||||
$output .= '<th class="column-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
$output .= $table_rows;
|
||||
$output .= '</tbody></table>';
|
||||
|
||||
endif;
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'sportspress_league_table' ) ) {
|
||||
function sportspress_league_table( $id ) {
|
||||
|
||||
@@ -23,7 +172,7 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
|
||||
|
||||
foreach( $data as $team_id => $row ):
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 1 ? 'odd' : 'even' ) . '">';
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
// Position as number
|
||||
$output .= '<td class="column-number">' . $i . '</td>';
|
||||
@@ -53,6 +202,62 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ( !function_exists( 'sportspress_team_columns' ) ) {
|
||||
function sportspress_team_columns( $id ) {
|
||||
|
||||
$leagues = get_the_terms( $id, 'sp_league' );
|
||||
|
||||
$output = '';
|
||||
|
||||
// Loop through data for each league
|
||||
foreach ( $leagues as $league ):
|
||||
|
||||
if ( sizeof( $leagues ) > 1 )
|
||||
$output .= '<h4 class="sp-team-league-name">' . $league->name . '</h4>';
|
||||
|
||||
$data = sportspress_get_team_columns_data( $id, $league->term_id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
|
||||
// Remove the first row to leave us with the actual data
|
||||
unset( $data[0] );
|
||||
|
||||
$output .= '<table class="sp-team-columns sp-data-table">' . '<thead>' . '<tr>';
|
||||
|
||||
foreach( $labels as $key => $label ):
|
||||
$output .= '<th class="column-' . $key . '">' . $label . '</th>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
$i = 0;
|
||||
|
||||
foreach( $data as $season_id => $row ):
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
$output .= '<td class="column-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
endforeach;
|
||||
|
||||
$output .= '</tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>';
|
||||
|
||||
|
||||
endforeach;
|
||||
|
||||
return $output;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( !function_exists( 'sportspress_player_list' ) ) {
|
||||
function sportspress_player_list( $id ) {
|
||||
|
||||
@@ -77,7 +282,7 @@ if ( !function_exists( 'sportspress_player_list' ) ) {
|
||||
|
||||
foreach( $data as $player_id => $row ):
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 1 ? 'odd' : 'even' ) . '">';
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
// Player number
|
||||
$number = get_post_meta( $player_id, 'sp_number', true );
|
||||
@@ -131,7 +336,7 @@ if ( !function_exists( 'sportspress_player_metrics' ) ) {
|
||||
|
||||
foreach( $data as $label => $value ):
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 1 ? 'odd' : 'even' ) . '"><th>' . $label . '</th><td>' . $value . '</td></tr>';
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '"><th>' . $label . '</th><td>' . $value . '</td></tr>';
|
||||
|
||||
$i++;
|
||||
|
||||
@@ -148,20 +353,17 @@ if ( !function_exists( 'sportspress_player_metrics' ) ) {
|
||||
if ( !function_exists( 'sportspress_player_statistics' ) ) {
|
||||
function sportspress_player_statistics( $id ) {
|
||||
|
||||
$team_ids = (array)get_post_meta( $id, 'sp_team', false );
|
||||
|
||||
// First one is empty
|
||||
unset( $team_ids[0] );
|
||||
$leagues = get_the_terms( $id, 'sp_league' );
|
||||
|
||||
$output = '';
|
||||
|
||||
// Loop through statistics for each team
|
||||
foreach ( $team_ids as $team_id ):
|
||||
// Loop through statistics for each league
|
||||
foreach ( $leagues as $league ):
|
||||
|
||||
if ( sizeof( $team_ids ) > 1 )
|
||||
$output .= '<h4 class="sp-player-team-name">' . get_the_title( $team_id ) . '</h4>';
|
||||
if ( sizeof( $leagues ) > 1 )
|
||||
$output .= '<h4 class="sp-player-league-name">' . $league->name . '</h4>';
|
||||
|
||||
$data = sportspress_get_player_statistics_data( $id, $team_id );
|
||||
$data = sportspress_get_player_statistics_data( $id, $league->term_id );
|
||||
|
||||
// The first row should be column labels
|
||||
$labels = $data[0];
|
||||
@@ -181,7 +383,7 @@ if ( !function_exists( 'sportspress_player_statistics' ) ) {
|
||||
|
||||
foreach( $data as $season_id => $row ):
|
||||
|
||||
$output .= '<tr class="' . ( $i % 2 == 1 ? 'odd' : 'even' ) . '">';
|
||||
$output .= '<tr class="' . ( $i % 2 == 0 ? 'odd' : 'even' ) . '">';
|
||||
|
||||
foreach( $labels as $key => $value ):
|
||||
$output .= '<td class="column-' . $key . '">' . sportspress_array_value( $row, $key, '—' ) . '</td>';
|
||||
|
||||
@@ -54,6 +54,7 @@ require_once dirname( __FILE__ ) . '/admin/post-types/list.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/post-types/staff.php';
|
||||
|
||||
// Terms
|
||||
require_once dirname( __FILE__ ) . '/admin/terms/league.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/terms/season.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/terms/venue.php';
|
||||
require_once dirname( __FILE__ ) . '/admin/terms/position.php';
|
||||
|
||||
Reference in New Issue
Block a user