Added sports placeholders and setting selection

This commit is contained in:
Takumi
2013-08-07 21:01:16 +10:00
parent 753a35f16c
commit 4a0b0c42f9
4 changed files with 359 additions and 117 deletions

View File

@@ -1,4 +1,289 @@
<?php
$sportspress_sports = array(
'Baseball' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'1' . ': $first' . "\r\n" .
'2' . ': $second' . "\r\n" .
'3' . ': $third' . "\r\n" .
'4' . ': $fourth' . "\r\n" .
'5' . ': $fifth' . "\r\n" .
'6' . ': $sixth' . "\r\n" .
'7' . ': $seventh' . "\r\n" .
'8' . ': $eigth' . "\r\n" .
'9' . ': $ninth' . "\r\n" .
'&nbsp;' . ': $extra' . "\r\n" .
'R' . ': $runs' . "\r\n" .
'H' . ': $hits' . "\r\n" .
'E' . ': $errors:' . "\r\n" .
'LOB' . ': $lob',
'player' =>
array(
'G' . ': $played' . "\r\n" .
'AB' . ': $ab' . "\r\n" .
'R' . ': $runs' . "\r\n" .
'H' . ': $hits' . "\r\n" .
'2B' . ': $double' . "\r\n" .
'3B' . ': $triple' . "\r\n" .
'HR' . ': $hr' . "\r\n" .
'RBI' . ': $rbi' . "\r\n" .
'BB' . ': $bb' . "\r\n" .
'SO' . ': $so' . "\r\n" .
'SB' . ': $sb' . "\r\n" .
'CS' . ': $cs' . "\r\n" .
'AVG' . ': $hits / $ab' . "\r\n" .
'OBP' . ': ( $hits + $bb + $hbp ) / ( $ab + $bb + $hbp + $sf )' . "\r\n" .
'SLG' . ': $tb / $ab' . "\r\n" .
'OPS' . ': ( $hits + $bb + $hbp ) / ( $ab + $bb + $hbp + $sf ) + ( $tb / $ab )'
),
array(
'W' . ': $wins' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'ERA' . ': ( $er * 9 ) / $ip' . "\r\n" .
'G' . ': $played' . "\r\n" .
'GS' . ': $gs' . "\r\n" .
'SV' . ': $sv' . "\r\n" .
'SVO' . ': $svo' . "\r\n" .
'IP' . ': $ip' . "\r\n" .
'H' . ': $hits' . "\r\n" .
'R' . ': $runs' . "\r\n" .
'ER' . ': $er' . "\r\n" .
'HR' . ': $hr' . "\r\n" .
'BB' . ': $bb' . "\r\n" .
'SO' . ': $so' . "\r\n" .
'AVG' . ': $hits / $ab' . "\r\n" .
'WHIP' . ': ( $hits + $walks ) / $ip'
),
array(
'W' . ': $wins' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'ERA' . ': ( $er * 9 ) / $ip' . "\r\n" .
'G' . ': $played' . "\r\n" .
'AB' . ': $ab' . "\r\n" .
'R' . ': $runs' . "\r\n" .
'H' . ': $hits' . "\r\n" .
'2B' . ': $double' . "\r\n" .
'3B' . ': $triple' . "\r\n" .
'HR' . ': $hr' . "\r\n" .
'RBI' . ': $rbi' . "\r\n" .
'BB' . ': $bb' . "\r\n" .
'SO' . ': $so' . "\r\n" .
'SB' . ': $sb' . "\r\n" .
'CS' . ': $cs' . "\r\n" .
'AVG' . ': $hits / $ab' . "\r\n" .
'OBP' . ': ( $hits + $bb + $hbp ) / ( $ab + $bb + $hbp + $sf )' . "\r\n" .
'SLG' . ': $tb / $ab' . "\r\n" .
'OPS' . ': ( $hits + $bb + $hbp ) / ( $ab + $bb + $hbp + $sf ) + ( $tb / $ab )'
)
),
'Basketball' => array(
'team' =>
'W' . ': $wins' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'Pct' . ': $wins / $played' . "\r\n" .
'GB' . ': ( $leadwins - $leadlosses + $wins - $losses ) / 2' . "\r\n" .
'Home' . ': $homewins $homelosses' . "\r\n" .
'Road' . ': $awaywins $awaylosses' . "\r\n" .
'L10' . ': $lastten' . "\r\n" .
'Streak' . ': $streak',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards'
),
'Cricket' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards'
),
'Football (USA)' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards'
),
'Footy (Australia)' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards'
),
'Hockey' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards'
),
'Rugby' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow' . ' Cards: $yellowcards' . "\r\n" .
'Red' . ' Cards: $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow' . ' Cards: $yellowcards' . "\r\n" .
'Red' . ' Cards: $redcards'
),
'soccer' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow Cards' . ': $yellowcards' . "\r\n" .
'Red Cards' . ': $redcards'
),
'Tennis' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow' . ' Cards: $yellowcards' . "\r\n" .
'Red' . ' Cards: $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow' . ' Cards: $yellowcards' . "\r\n" .
'Red' . ' Cards: $redcards'
),
'Volleyball' => array(
'team' =>
'P' . ': $played' . "\r\n" .
'W' . ': $wins' . "\r\n" .
'D' . ': $ties' . "\r\n" .
'L' . ': $losses' . "\r\n" .
'F' . ': $for' . "\r\n" .
'A' . ': $against' . "\r\n" .
'GD' . ': $for - $against' . "\r\n" .
'PTS' . ': 3 * $wins + $ties',
'event' =>
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow' . ' Cards: $yellowcards' . "\r\n" .
'Red' . ' Cards: $redcards',
'player' =>
'Attendances' . ': $played' . "\r\n" .
'Goals' . ': $goals' . "\r\n" .
'Assists' . ': $assists' . "\r\n" .
'Yellow' . ' Cards: $yellowcards' . "\r\n" .
'Red' . ' Cards: $redcards'
)
);
$sportspress_texts = array(
'sp_team' => array(
'Enter title here' => __( 'Team', 'sportspress' ),
@@ -54,23 +339,9 @@ $sportspress_thumbnail_texts = array(
$sportspress_options = array(
'settings' => array(
'sp_event_team_count' => 2,
'sp_team_stats_columns' => 'P: $played
W: $wins
D: $ties
L: $losses
F: $for
A: $against
GD: $for-$against
PTS: 3$wins+$ties',
'sp_event_stats_columns' => 'Goals: $goals
Assists: $assists
Yellow Cards: $yellowcards
Red Cards: $redcards',
'sp_player_stats_columns' => 'Attendances: $played
Goals: $goals
Assists: $assists
Yellow Cards: $yellowcards
Red Cards: $redcards'
'sp_team_stats_columns' => $sportspress_sports['soccer']['team'],
'sp_event_stats_columns' => $sportspress_sports['soccer']['event'],
'sp_player_stats_columns' => $sportspress_sports['soccer']['player']
)
);

View File

@@ -307,6 +307,7 @@ if ( !function_exists( 'sp_get_stats_row' ) ) {
$player_id = sp_array_value( $args['meta_query'][0], 'value', 0 );
if ( !array_key_exists( $player_id, $stat ) ) continue;
foreach ( $stat[ $player_id ] as $key => $value ):
if ( !array_key_exists( $key, $stats_keys ) || !array_key_exists( $stats_keys[ $key ], $vars ) ) continue;
$vars[ $stats_keys[ $key ] ] += $value;
endforeach;
endforeach;
@@ -478,6 +479,19 @@ if ( !function_exists( 'sp_stats_table' ) ) {
}
}
if ( !function_exists( 'sp_team_stats_sport_choice' ) ) {
function sp_team_stats_sport_choice( $selected = null ) {
global $sportspress_sports;
?>
<select id="sp_team_stats_sport" name="sp_team_stats_sport">
<?php foreach ( $sportspress_sports as $key => $value ): ?>
<option value="<?php echo $key; ?>" data-sp-preset="<?php echo sp_array_value( $value, 'team' ); ?>"<?php if ( $selected == $key ) echo ' selected="selected"'; ?>><?php echo sp_array_value( $value, 'name' ); ?></option>
<?php endforeach; ?>
</select>
<?php
}
}
if ( !function_exists( 'sp_post_adder' ) ) {
function sp_post_adder( $meta = 'post' ) {
$obj = get_post_type_object( $meta );

View File

@@ -5,119 +5,75 @@ function sp_settings_menu() {
__( 'SportsPress', 'sportspress' ),
__( 'SportsPress', 'sportspress' ),
'manage_options',
'sp_settings',
'sp_settings_page'
'sportspress',
'sportspress_settings_page'
);
}
add_action('admin_menu', 'sp_settings_menu');
function sp_settings_page() {
function sportspress_settings_add_js() {
?>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function($){
$("input[name='date_format']").click(function(){
if ( "date_format_custom_radio" != $(this).attr("id") )
$("input[name='date_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
});
$("input[name='date_format_custom']").focus(function(){
$("#date_format_custom_radio").attr("checked", "checked");
});
$("input[name='time_format']").click(function(){
if ( "time_format_custom_radio" != $(this).attr("id") )
$("input[name='time_format_custom']").val( $(this).val() ).siblings('.example').text( $(this).siblings('span').text() );
});
$("input[name='time_format_custom']").focus(function(){
$("#time_format_custom_radio").attr("checked", "checked");
});
$("input[name='date_format_custom'], input[name='time_format_custom']").change( function() {
var format = $(this);
format.siblings('.spinner').css('display', 'inline-block'); // show(); can't be used here
$.post(ajaxurl, {
action: 'date_format_custom' == format.attr('name') ? 'date_format' : 'time_format',
date : format.val()
}, function(d) { format.siblings('.spinner').hide(); format.siblings('.example').text(d); } );
});
});
//]]>
</script>
<?php
}
add_action('admin_head', 'sportspress_settings_add_js');
function sportspress_settings_page() {
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"><br></div>
<h2 class="nav-tab-wrapper">
<?php _e( 'SportsPress Settings', 'sportspress' ); ?>
<a href="#" class="nav-tab nav-tab-active">Tab 1</a>
<a href="#" class="nav-tab">Tab 2</a>
</h2>
</div>
<?php
/*
if ( true | ! current_user_can( 'manage_options' ) ) wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
$hidden_field_name = 'tb_submit_hidden';
if ( ! current_user_can( 'manage_options' ) ) wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"><br></div>
<h2><?php _e('General Settings', 'sportspress'); ?></h2>
<?php
if( isset( $_POST[ $hidden_field_name ] ) && $_POST[ $hidden_field_name ] == 'Y' ) {
global $tb_option_fields;
foreach( $tb_option_fields['settings'] as $option_field => $value ) {
$new_value = isset( $_POST[$option_field] ) ? $_POST[$option_field] : null;
update_option( $option_field, stripslashes( $new_value ) );
}
?>
<div id="message" class="updated"><p><strong><?php _e( 'Settings saved.' ); ?></strong></p></div>
<?php
}
?>
<form name="sportspress_form" method="post" action="">
<table class="form-table">
<tbody>
<tr valign="top">
<th scope="row"><?php _e( 'Home Team', 'sportspress' ); ?></th>
<td>
<?php $option_slug = 'tb_default_club'; ?>
<?php
tb_dropdown_posts( array(
'post_type' => 'tb_club',
'limit' => -1,
'show_option_none' => __( 'None' ),
'selected' => get_option( $option_slug ),
'name' => $option_slug,
'id' => $option_slug
) );
?>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="tb_region_code"><?php _e( 'Country', 'sportspress' ); ?></label></th>
<td>
<?php
global $tb_countries_of_the_world;
asort( $tb_countries_of_the_world );
echo form_dropdown( 'tb_region_code', $tb_countries_of_the_world, get_option( 'tb_region_code' ) );
?>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Header' ); ?></th>
<td>
<?php $option_slug = 'tb_header_sponsor'; ?>
<label for="<?php echo $option_slug; ?>"><?php _e( 'Sponsor', 'sportspress' ); ?> 1:</label>
<?php
tb_dropdown_posts( array(
'post_type' => 'tb_sponsor',
'limit' => -1,
'show_option_none' => __( 'None' ),
'selected' => get_option( $option_slug ),
'name' => $option_slug,
'id' => $option_slug
) );
?><br />
<?php $option_slug = 'tb_header_sponsor_2'; ?>
<label for="<?php echo $option_slug; ?>"><?php _e( 'Sponsor', 'sportspress' ); ?> 2:</label>
<?php
tb_dropdown_posts( array(
'post_type' => 'tb_sponsor',
'limit' => -1,
'show_option_none' => __( 'None' ),
'selected' => get_option( $option_slug ),
'name' => $option_slug,
'id' => $option_slug
) );
?>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Footer' ); ?></th>
<td>
<?php $option_slug = 'tb_footer_show_sponsors'; ?>
<input name="<?php echo $option_slug; ?>" type="checkbox" id="<?php echo $option_slug; ?>" value="1"<?php if( get_option( $option_slug ) ) echo ' checked' ?> />
<label for="<?php echo $option_slug; ?>"><?php _e( 'Sponsors', 'sportspress' ); ?></label>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php _e( 'Layout' ); ?></th>
<td>
<?php $option_slug = 'tb_responsive'; ?>
<input name="<?php echo $option_slug; ?>" type="checkbox" id="<?php echo $option_slug; ?>" value="1"<?php if( get_option( $option_slug ) ) echo ' checked' ?> />
<label for="<?php echo $option_slug; ?>"><?php _e( 'Responsive', 'sportspress' ); ?></label>
</td>
</tr>
</tbody>
</table>
<input type="hidden" name="<?php echo $hidden_field_name; ?>" value="Y">
<form method="post" action="options.php">
<input type="hidden" name="option_page" value="general"><input type="hidden" name="action" value="update"><input type="hidden" id="_wpnonce" name="_wpnonce" value="e1cad3625d"><input type="hidden" name="_wp_http_referer" value="/sportspress/wp-admin/options-general.php">
<table class="form-table">
<tbody><tr valign="top">
<th scope="row"><label for="sp_team_stats_columns">Team Statistics</label></th>
<td>
<p><?php sp_team_stats_sport_choice(); ?></p>
<p>
<textarea name="sp_team_stats_columns" rows="10" cols="50" id="sp_team_stats_columns" class="large-text code"><?php form_option('sp_team_stats_columns'); ?></textarea>
</p>
</td>
</tr>
</tbody></table>
<?php submit_button( null, 'primary', 'save-sportspress-options' ); ?>
</form>
</div>
<?php */ } ?>
<?php } ?>

View File

@@ -98,6 +98,7 @@
}
#sp_statsdiv .widefat input[type="text"],
#sp_statsdiv .widefat input[type="number"] {
min-width: 14px;
width: 100%;
}
.widefat th.column-sp_icon,