Add settings page and use EOS to calculate team and player stats
This commit is contained in:
291
globals.php
291
globals.php
@@ -1,289 +1,4 @@
|
|||||||
<?php
|
<?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" .
|
|
||||||
' ' . ': $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(
|
$sportspress_texts = array(
|
||||||
'sp_team' => array(
|
'sp_team' => array(
|
||||||
'Enter title here' => __( 'Team', 'sportspress' ),
|
'Enter title here' => __( 'Team', 'sportspress' ),
|
||||||
@@ -339,9 +54,9 @@ $sportspress_thumbnail_texts = array(
|
|||||||
$sportspress_options = array(
|
$sportspress_options = array(
|
||||||
'settings' => array(
|
'settings' => array(
|
||||||
'sp_event_team_count' => 2,
|
'sp_event_team_count' => 2,
|
||||||
'sp_team_stats_columns' => $sportspress_sports['soccer']['team'],
|
'sp_team_stats_columns' => '',
|
||||||
'sp_event_stats_columns' => $sportspress_sports['soccer']['event'],
|
'sp_event_stats_columns' => '',
|
||||||
'sp_player_stats_columns' => $sportspress_sports['soccer']['player']
|
'sp_player_stats_columns' => ''
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
45
helpers.php
45
helpers.php
@@ -254,6 +254,18 @@ if ( !function_exists( 'sp_get_eos_array' ) ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !function_exists( 'sp_get_eos_keys' ) ) {
|
||||||
|
function sp_get_eos_keys( $raw ) {
|
||||||
|
$raw = str_replace( array( "\r\n", ' :' ), array( "\n", ':' ), $raw );
|
||||||
|
$arr = explode( "\n", $raw );
|
||||||
|
$output = array();
|
||||||
|
foreach ( $arr as $value ):
|
||||||
|
$output[] = substr( $value, 0, strpos( $value, ':') );
|
||||||
|
endforeach;
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( !function_exists( 'sp_get_stats_row' ) ) {
|
if ( !function_exists( 'sp_get_stats_row' ) ) {
|
||||||
function sp_get_stats_row( $post_type = 'post', $args = array(), $static = false ) {
|
function sp_get_stats_row( $post_type = 'post', $args = array(), $static = false ) {
|
||||||
$args = array_merge(
|
$args = array_merge(
|
||||||
@@ -269,6 +281,8 @@ if ( !function_exists( 'sp_get_stats_row' ) ) {
|
|||||||
|
|
||||||
$vars = array();
|
$vars = array();
|
||||||
|
|
||||||
|
$stats_settings = get_option( 'sportspress_stats' );
|
||||||
|
|
||||||
// Get dynamic stats
|
// Get dynamic stats
|
||||||
switch ($post_type):
|
switch ($post_type):
|
||||||
case 'sp_team':
|
case 'sp_team':
|
||||||
@@ -289,7 +303,7 @@ if ( !function_exists( 'sp_get_stats_row' ) ) {
|
|||||||
$vars['against'] = 0; foreach( $posts as $post ): $result = $post->sp_result; unset( $result[ $post->sp_team_index ] ); $vars['against'] += array_sum( $result ); endforeach;
|
$vars['against'] = 0; foreach( $posts as $post ): $result = $post->sp_result; unset( $result[ $post->sp_team_index ] ); $vars['against'] += array_sum( $result ); endforeach;
|
||||||
|
|
||||||
// Get EOS array
|
// Get EOS array
|
||||||
$rows = sp_get_eos_array( get_option( 'sp_team_stats_columns' ) );
|
$rows = sp_get_eos_array( $stats_settings['team'] );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'sp_player':
|
case 'sp_player':
|
||||||
@@ -335,7 +349,7 @@ if ( !function_exists( 'sp_get_stats_row' ) ) {
|
|||||||
$dynamic = array();
|
$dynamic = array();
|
||||||
foreach ( $rows as $key => $value ):
|
foreach ( $rows as $key => $value ):
|
||||||
$row = explode( ':', $value );
|
$row = explode( ':', $value );
|
||||||
$dynamic[] = $eos->solveIF( sp_array_value( $row, 1, '$played'), $vars );
|
$dynamic[ $key ] = $eos->solveIF( sp_array_value( $row, 1, '$played'), $vars );
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
if ( $static ):
|
if ( $static ):
|
||||||
@@ -364,10 +378,10 @@ if ( !function_exists( 'sp_get_stats_row' ) ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( !function_exists( 'sp_stats_table' ) ) {
|
if ( !function_exists( 'sp_stats_table' ) ) {
|
||||||
function sp_stats_table( $stats = array(), $placeholders = array(), $index = 0, $columns = array( 'Name' ), $total = true, $rowtype = 'post', $slug = 'sp_stats' ) {
|
function sp_stats_table( $stats = array(), $placeholders = array(), $index = 0, $columns = array(), $total = true, $rowtype = 'post', $slug = 'sp_stats' ) {
|
||||||
global $pagenow;
|
global $pagenow;
|
||||||
if ( !is_array( $stats ) )
|
if ( !is_array( $stats ) )
|
||||||
$stats = array();
|
$stats = array( __( 'Name', 'sportspress' ) );
|
||||||
?>
|
?>
|
||||||
<table class="widefat sp-stats-table">
|
<table class="widefat sp-stats-table">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -428,6 +442,7 @@ if ( !function_exists( 'sp_stats_table' ) ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if ( !function_exists( 'sp_team_stats_sport_choice' ) ) {
|
if ( !function_exists( 'sp_team_stats_sport_choice' ) ) {
|
||||||
function sp_team_stats_sport_choice( $selected = null ) {
|
function sp_team_stats_sport_choice( $selected = null ) {
|
||||||
global $sportspress_sports;
|
global $sportspress_sports;
|
||||||
@@ -440,6 +455,7 @@ if ( !function_exists( 'sp_team_stats_sport_choice' ) ) {
|
|||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
if ( !function_exists( 'sp_post_adder' ) ) {
|
if ( !function_exists( 'sp_post_adder' ) ) {
|
||||||
function sp_post_adder( $meta = 'post' ) {
|
function sp_post_adder( $meta = 'post' ) {
|
||||||
@@ -473,4 +489,25 @@ if ( !function_exists( 'sp_update_post_meta_recursive' ) ) {
|
|||||||
endforeach;
|
endforeach;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !function_exists( 'sportspress_render_option_field' ) ) {
|
||||||
|
function sportspress_render_option_field( $group, $name, $type = 'text' ) {
|
||||||
|
|
||||||
|
$options = get_option( $group );
|
||||||
|
$value = '';
|
||||||
|
if ( is_array( $options ) && array_key_exists( $name, $options ) ):
|
||||||
|
$value = $options[ $name ];
|
||||||
|
endif;
|
||||||
|
|
||||||
|
switch ( $type ):
|
||||||
|
case 'textarea':
|
||||||
|
echo '<textarea id="' . $group . '" name="' . $group . '[' . $name . ']" rows="10" cols="50">' . $value . '</textarea>';
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
echo '<input type="text" id="' . $name . '" name="' . $group . '[' . $name . ']" value="' . $value . '" />';
|
||||||
|
break;
|
||||||
|
endswitch;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
16
player.php
16
player.php
@@ -38,6 +38,13 @@ function sp_player_stats_meta( $post ) {
|
|||||||
$leagues = (array)get_the_terms( $post->ID, 'sp_league' );
|
$leagues = (array)get_the_terms( $post->ID, 'sp_league' );
|
||||||
$stats = (array)get_post_meta( $post->ID, 'sp_stats', true );
|
$stats = (array)get_post_meta( $post->ID, 'sp_stats', true );
|
||||||
|
|
||||||
|
// Get column names from settings
|
||||||
|
$stats_settings = get_option( 'sportspress_stats' );
|
||||||
|
$columns = sp_get_eos_keys( $stats_settings['player'] );
|
||||||
|
|
||||||
|
// Add first column label
|
||||||
|
array_unshift( $columns, __( 'League', 'sportspress' ) );
|
||||||
|
|
||||||
// Generate array of all league ids
|
// Generate array of all league ids
|
||||||
$league_ids = array( 0 );
|
$league_ids = array( 0 );
|
||||||
foreach ( $leagues as $key => $value ):
|
foreach ( $leagues as $key => $value ):
|
||||||
@@ -73,9 +80,10 @@ function sp_player_stats_meta( $post ) {
|
|||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
<p><strong><?php _e( 'Overall', 'sportspress' ); ?></strong></p>
|
<p><strong><?php _e( 'Overall', 'sportspress' ); ?></strong></p>
|
||||||
<?php sp_stats_table( $data, $placeholders, 0, array( 'League', 'Played', 'Goals', 'Assists', 'Yellow Cards', 'Red Cards' ), true, 'sp_league' ); ?>
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
sp_stats_table( $data, $placeholders, 0, $columns, true, 'sp_league' );
|
||||||
|
|
||||||
// Leagues
|
// Leagues
|
||||||
foreach ( $teams as $team ):
|
foreach ( $teams as $team ):
|
||||||
if ( !$team ) continue;
|
if ( !$team ) continue;
|
||||||
@@ -110,7 +118,11 @@ function sp_player_stats_meta( $post ) {
|
|||||||
endforeach;
|
endforeach;
|
||||||
?>
|
?>
|
||||||
<p><strong><?php echo get_the_title( $team ); ?></strong></p>
|
<p><strong><?php echo get_the_title( $team ); ?></strong></p>
|
||||||
<?php sp_stats_table( $data, $placeholders, $team, array( 'League', 'Played', 'Goals', 'Assists', 'Yellow Cards', 'Red Cards' ), true, 'sp_league' ); ?>
|
<?php
|
||||||
|
|
||||||
|
sp_stats_table( $data, $placeholders, $team, $columns, true, 'sp_league' );
|
||||||
|
|
||||||
|
?>
|
||||||
<?php
|
<?php
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
|
|||||||
286
presets.php
Normal file
286
presets.php
Normal file
@@ -0,0 +1,286 @@
|
|||||||
|
<?php
|
||||||
|
$sportspress_presets = 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" .
|
||||||
|
' ' . ': $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'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
?>
|
||||||
594
settings.php
594
settings.php
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
function sp_settings_menu() {
|
/*
|
||||||
add_submenu_page(
|
function sportspress_admin_menu() {
|
||||||
'options-general.php',
|
add_options_page(
|
||||||
__( 'SportsPress', 'sportspress' ),
|
__( 'SportsPress', 'sportspress' ),
|
||||||
__( 'SportsPress', 'sportspress' ),
|
__( 'SportsPress', 'sportspress' ),
|
||||||
'manage_options',
|
'manage_options',
|
||||||
@@ -9,71 +9,565 @@ function sp_settings_menu() {
|
|||||||
'sportspress_settings_page'
|
'sportspress_settings_page'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
add_action('admin_menu', 'sp_settings_menu');
|
add_action('admin_menu', 'sportspress_admin_menu');
|
||||||
|
|
||||||
|
function sportspress_register_settings() {
|
||||||
|
register_setting( 'sportspress_stats', 'sportspress_team_stats' );
|
||||||
|
}
|
||||||
|
add_action( 'admin_init', 'sportspress_register_settings' );
|
||||||
|
|
||||||
function sportspress_settings_add_js() {
|
function sportspress_settings_add_js() {
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
//<![CDATA[
|
|
||||||
jQuery(document).ready(function($){
|
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>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
add_action('admin_head', 'sportspress_settings_add_js');
|
add_action('admin_head', 'sportspress_settings_add_js');
|
||||||
|
|
||||||
function sportspress_settings_page() {
|
function sportspress_settings_page() {
|
||||||
?>
|
?><?php settings_fields( 'sportspress_stats' ) ?>test
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<div id="icon-options-general" class="icon32"><br></div>
|
<div id="icon-options-general" class="icon32"><br></div>
|
||||||
<h2 class="nav-tab-wrapper">
|
<h2 class="nav-tab-wrapper">
|
||||||
<?php _e( 'SportsPress Settings', 'sportspress' ); ?>
|
<?php _e( 'SportsPress', 'sportspress' ); ?>
|
||||||
<a href="#" class="nav-tab nav-tab-active">Tab 1</a>
|
<a href="#" class="nav-tab"><?php _e( 'General', 'sportspress' ); ?></a>
|
||||||
<a href="#" class="nav-tab">Tab 2</a>
|
<a href="#" class="nav-tab nav-tab-active"><?php _e( 'Statistics', 'sportspress' ); ?></a>
|
||||||
</h2>
|
</h2>
|
||||||
<?php
|
<?php
|
||||||
if ( ! current_user_can( 'manage_options' ) ) wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
if ( ! current_user_can( 'manage_options' ) ) wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
|
||||||
|
?>
|
||||||
|
<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"><?php _e( 'Team', 'sportspress' ); ?></label>
|
||||||
|
</th>
|
||||||
|
<td>
|
||||||
|
<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
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function introduces the theme options into the 'Appearance' menu and into a top-level
|
||||||
|
* __( 'SportsPress', 'sportspress' ) menu.
|
||||||
|
*/
|
||||||
|
function sportspress_admin_menu() {
|
||||||
|
|
||||||
|
add_options_page(
|
||||||
|
__( 'SportsPress', 'sportspress' ),
|
||||||
|
__( 'SportsPress', 'sportspress' ),
|
||||||
|
'manage_options',
|
||||||
|
'sportspress',
|
||||||
|
'sportspress_settings'
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
add_action( 'admin_menu', 'sportspress_admin_menu' );
|
||||||
|
|
||||||
|
function sportspress_settings( $tab = '' ) {
|
||||||
?>
|
?>
|
||||||
|
<div class="wrap">
|
||||||
|
|
||||||
<form method="post" action="options.php">
|
<div id="icon-themes" class="icon32"></div>
|
||||||
<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">
|
<h2><?php _e( 'SportsPress', 'sportspress' ); ?></h2>
|
||||||
<table class="form-table">
|
<?php settings_errors(); ?>
|
||||||
<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' ); ?>
|
<?php
|
||||||
</form>
|
if( isset( $_GET[ 'tab' ] ) ) {
|
||||||
</div>
|
$tab = $_GET[ 'tab' ];
|
||||||
<?php } ?>
|
} else if( $tab == 'stats' ) {
|
||||||
|
$tab = 'stats';
|
||||||
|
} else if( $tab == 'input_examples' ) {
|
||||||
|
$tab = 'input_examples';
|
||||||
|
} else {
|
||||||
|
$tab = 'display_options';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<h2 class="nav-tab-wrapper">
|
||||||
|
<a href="?page=sportspress&tab=display_options" class="nav-tab <?php echo $tab == 'display_options' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Display Options', 'sportspress' ); ?></a>
|
||||||
|
<a href="?page=sportspress&tab=stats" class="nav-tab <?php echo $tab == 'stats' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Statistics', 'sportspress' ); ?></a>
|
||||||
|
<a href="?page=sportspress&tab=input_examples" class="nav-tab <?php echo $tab == 'input_examples' ? 'nav-tab-active' : ''; ?>"><?php _e( 'Input Examples', 'sportspress' ); ?></a>
|
||||||
|
</h2>
|
||||||
|
|
||||||
|
<form method="post" action="options.php">
|
||||||
|
<?php
|
||||||
|
|
||||||
|
if( $tab == 'display_options' ) {
|
||||||
|
|
||||||
|
settings_fields( 'sportspress_settings_options' );
|
||||||
|
do_settings_sections( 'sportspress_settings_options' );
|
||||||
|
|
||||||
|
} elseif( $tab == 'stats' ) {
|
||||||
|
|
||||||
|
settings_fields( 'sportspress_stats' );
|
||||||
|
do_settings_sections( 'sportspress_stats' );
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
settings_fields( 'sportspress_input_examples' );
|
||||||
|
do_settings_sections( 'sportspress_input_examples' );
|
||||||
|
|
||||||
|
} // end if/else
|
||||||
|
|
||||||
|
submit_button();
|
||||||
|
|
||||||
|
?>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</div><!-- /.wrap -->
|
||||||
|
<?php
|
||||||
|
} // end sportspress_settings
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------ *
|
||||||
|
* Setting Registration
|
||||||
|
* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides default values for the Statistics.
|
||||||
|
*/
|
||||||
|
function sportspress_default_stats() {
|
||||||
|
|
||||||
|
$defaults = array(
|
||||||
|
'team' => '',
|
||||||
|
'event' => '',
|
||||||
|
'player' => '',
|
||||||
|
'staff' => 'Staff settings',
|
||||||
|
);
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_default_stats', $defaults );
|
||||||
|
|
||||||
|
} // end sportspress_default_stats
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides default values for the Display Options.
|
||||||
|
*/
|
||||||
|
function sportspress_default_display_options() {
|
||||||
|
|
||||||
|
$defaults = array(
|
||||||
|
'show_header' => '',
|
||||||
|
'show_content' => '',
|
||||||
|
'show_footer' => '',
|
||||||
|
);
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_default_display_options', $defaults );
|
||||||
|
|
||||||
|
} // end sportspress_default_display_options
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides default values for the Input Options.
|
||||||
|
*/
|
||||||
|
function sportspress_default_input_options() {
|
||||||
|
|
||||||
|
$defaults = array(
|
||||||
|
'input_example' => '',
|
||||||
|
'textarea_example' => '',
|
||||||
|
'checkbox_example' => '',
|
||||||
|
'radio_example' => '',
|
||||||
|
'time_options' => 'default'
|
||||||
|
);
|
||||||
|
|
||||||
|
return apply_filters( 'sportspress_default_input_options', $defaults );
|
||||||
|
|
||||||
|
} // end sportspress_default_input_options
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the theme's display options page by registering the Sections,
|
||||||
|
* Fields, and Settings.
|
||||||
|
*
|
||||||
|
* This function is registered with the 'admin_init' hook.
|
||||||
|
*/
|
||||||
|
function sportspress_initialize_theme_options() {
|
||||||
|
|
||||||
|
// If the theme options don't exist, create them.
|
||||||
|
if ( false == get_option( 'sportspress_settings_options' ) ) {
|
||||||
|
add_option( 'sportspress_settings_options', apply_filters( 'sportspress_default_display_options', sportspress_default_display_options() ) );
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
// First, we register a section. This is necessary since all future options must belong to a
|
||||||
|
add_settings_section(
|
||||||
|
'general_settings_section', // ID used to identify this section and with which to register options
|
||||||
|
__( 'Display Options', 'sportspress' ), // Title to be displayed on the administration page
|
||||||
|
'', // Callback used to render the description of the section
|
||||||
|
'sportspress_settings_options' // Page on which to add this section of options
|
||||||
|
);
|
||||||
|
|
||||||
|
// Next, we'll introduce the fields for toggling the visibility of content elements.
|
||||||
|
add_settings_field(
|
||||||
|
'show_header', // ID used to identify the field throughout the theme
|
||||||
|
__( 'Header', 'sportspress' ), // The label to the left of the option interface element
|
||||||
|
'sportspress_toggle_header_callback', // The name of the function responsible for rendering the option interface
|
||||||
|
'sportspress_settings_options', // The page on which this option will be displayed
|
||||||
|
'general_settings_section', // The name of the section to which this field belongs
|
||||||
|
array( // The array of arguments to pass to the callback. In this case, just a description.
|
||||||
|
__( 'Activate this setting to display the header.', 'sportspress' ),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'show_content',
|
||||||
|
__( 'Content', 'sportspress' ),
|
||||||
|
'sportspress_toggle_content_callback',
|
||||||
|
'sportspress_settings_options',
|
||||||
|
'general_settings_section',
|
||||||
|
array(
|
||||||
|
__( 'Activate this setting to display the content.', 'sportspress' ),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'show_footer',
|
||||||
|
__( 'Footer', 'sportspress' ),
|
||||||
|
'sportspress_toggle_footer_callback',
|
||||||
|
'sportspress_settings_options',
|
||||||
|
'general_settings_section',
|
||||||
|
array(
|
||||||
|
__( 'Activate this setting to display the footer.', 'sportspress' ),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Finally, we register the fields with WordPress
|
||||||
|
register_setting(
|
||||||
|
'sportspress_settings_options',
|
||||||
|
'sportspress_settings_options'
|
||||||
|
);
|
||||||
|
|
||||||
|
} // end sportspress_initialize_theme_options
|
||||||
|
add_action( 'admin_init', 'sportspress_initialize_theme_options' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the theme's social options by registering the Sections,
|
||||||
|
* Fields, and Settings.
|
||||||
|
*
|
||||||
|
* This function is registered with the 'admin_init' hook.
|
||||||
|
*/
|
||||||
|
function sportspress_intialize_stats() {
|
||||||
|
|
||||||
|
if( false == get_option( 'sportspress_stats' ) ) {
|
||||||
|
add_option( 'sportspress_stats', apply_filters( 'sportspress_default_stats', sportspress_default_stats() ) );
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
add_settings_section(
|
||||||
|
'sportspress_team_stats', // ID used to identify this section and with which to register options
|
||||||
|
__( 'Teams', 'sportspress' ), // Title to be displayed on the administration page
|
||||||
|
'', // Callback used to render the description of the section
|
||||||
|
'sportspress_stats' // Page on which to add this section of options
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_section(
|
||||||
|
'sportspress_event_stats', // ID used to identify this section and with which to register options
|
||||||
|
__( 'Events', 'sportspress' ), // Title to be displayed on the administration page
|
||||||
|
'', // Callback used to render the description of the section
|
||||||
|
'sportspress_stats' // Page on which to add this section of options
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_section(
|
||||||
|
'sportspress_player_stats', // ID used to identify this section and with which to register options
|
||||||
|
__( 'Players', 'sportspress' ), // Title to be displayed on the administration page
|
||||||
|
'', // Callback used to render the description of the section
|
||||||
|
'sportspress_stats' // Page on which to add this section of options
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'team',
|
||||||
|
__( 'Statistics', 'sportspress' ),
|
||||||
|
'sportspress_team_stats_callback',
|
||||||
|
'sportspress_stats',
|
||||||
|
'sportspress_team_stats'
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'event_team',
|
||||||
|
__( 'Teams', 'sportspress' ),
|
||||||
|
'sportspress_event_team_stats_callback',
|
||||||
|
'sportspress_stats',
|
||||||
|
'sportspress_event_stats'
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'event_player',
|
||||||
|
__( 'Players', 'sportspress' ),
|
||||||
|
'sportspress_event_player_stats_callback',
|
||||||
|
'sportspress_stats',
|
||||||
|
'sportspress_event_stats'
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'player',
|
||||||
|
__( 'Statistics', 'sportspress' ),
|
||||||
|
'sportspress_player_stats_callback',
|
||||||
|
'sportspress_stats',
|
||||||
|
'sportspress_player_stats'
|
||||||
|
);
|
||||||
|
|
||||||
|
register_setting(
|
||||||
|
'sportspress_stats',
|
||||||
|
'sportspress_stats'
|
||||||
|
);
|
||||||
|
|
||||||
|
} // end sportspress_intialize_stats
|
||||||
|
add_action( 'admin_init', 'sportspress_intialize_stats' );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the theme's input example by registering the Sections,
|
||||||
|
* Fields, and Settings. This particular group of options is used to demonstration
|
||||||
|
* validation and sanitization.
|
||||||
|
*
|
||||||
|
* This function is registered with the 'admin_init' hook.
|
||||||
|
*/
|
||||||
|
function sportspress_initialize_input_examples() {
|
||||||
|
|
||||||
|
if( false == get_option( 'sportspress_input_examples' ) ) {
|
||||||
|
add_option( 'sportspress_input_examples', apply_filters( 'sportspress_default_input_options', sportspress_default_input_options() ) );
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
add_settings_section(
|
||||||
|
'input_examples_section',
|
||||||
|
__( 'Input Examples', 'sportspress' ),
|
||||||
|
'',
|
||||||
|
'sportspress_input_examples'
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'Input Element',
|
||||||
|
__( 'Input Element', 'sportspress' ),
|
||||||
|
'sportspress_input_element_callback',
|
||||||
|
'sportspress_input_examples',
|
||||||
|
'input_examples_section'
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'Textarea Element',
|
||||||
|
__( 'Textarea Element', 'sportspress' ),
|
||||||
|
'sportspress_textarea_element_callback',
|
||||||
|
'sportspress_input_examples',
|
||||||
|
'input_examples_section'
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'Checkbox Element',
|
||||||
|
__( 'Checkbox Element', 'sportspress' ),
|
||||||
|
'sportspress_checkbox_element_callback',
|
||||||
|
'sportspress_input_examples',
|
||||||
|
'input_examples_section'
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'Radio Button Elements',
|
||||||
|
__( 'Radio Button Elements', 'sportspress' ),
|
||||||
|
'sportspress_radio_element_callback',
|
||||||
|
'sportspress_input_examples',
|
||||||
|
'input_examples_section'
|
||||||
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'Select Element',
|
||||||
|
__( 'Select Element', 'sportspress' ),
|
||||||
|
'sportspress_select_element_callback',
|
||||||
|
'sportspress_input_examples',
|
||||||
|
'input_examples_section'
|
||||||
|
);
|
||||||
|
|
||||||
|
register_setting(
|
||||||
|
'sportspress_input_examples',
|
||||||
|
'sportspress_input_examples',
|
||||||
|
'sportspress_validate_input_examples'
|
||||||
|
);
|
||||||
|
|
||||||
|
} // end sportspress_initialize_input_examples
|
||||||
|
add_action( 'admin_init', 'sportspress_initialize_input_examples' );
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------ *
|
||||||
|
* Field Callbacks
|
||||||
|
* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function renders the interface elements for toggling the visibility of the header element.
|
||||||
|
*
|
||||||
|
* It accepts an array or arguments and expects the first element in the array to be the description
|
||||||
|
* to be displayed next to the checkbox.
|
||||||
|
*/
|
||||||
|
function sportspress_toggle_header_callback($args) {
|
||||||
|
|
||||||
|
// First, we read the options collection
|
||||||
|
$options = get_option('sportspress_settings_options');
|
||||||
|
|
||||||
|
// Next, we update the name attribute to access this element's ID in the context of the display options array
|
||||||
|
// We also access the show_header element of the options collection in the call to the checked() helper function
|
||||||
|
$html = '<input type="checkbox" id="show_header" name="sportspress_settings_options[show_header]" value="1" ' . checked( 1, isset( $options['show_header'] ) ? $options['show_header'] : 0, false ) . '/>';
|
||||||
|
|
||||||
|
// Here, we'll take the first argument of the array and add it to a label next to the checkbox
|
||||||
|
$html .= '<label for="show_header"> ' . $args[0] . '</label>';
|
||||||
|
|
||||||
|
echo $html;
|
||||||
|
|
||||||
|
} // end sportspress_toggle_header_callback
|
||||||
|
|
||||||
|
function sportspress_toggle_content_callback($args) {
|
||||||
|
|
||||||
|
$options = get_option('sportspress_settings_options');
|
||||||
|
|
||||||
|
$html = '<input type="checkbox" id="show_content" name="sportspress_settings_options[show_content]" value="1" ' . checked( 1, isset( $options['show_content'] ) ? $options['show_content'] : 0, false ) . '/>';
|
||||||
|
$html .= '<label for="show_content"> ' . $args[0] . '</label>';
|
||||||
|
|
||||||
|
echo $html;
|
||||||
|
|
||||||
|
} // end sportspress_toggle_content_callback
|
||||||
|
|
||||||
|
function sportspress_toggle_footer_callback($args) {
|
||||||
|
|
||||||
|
$options = get_option('sportspress_settings_options');
|
||||||
|
|
||||||
|
$html = '<input type="checkbox" id="show_footer" name="sportspress_settings_options[show_footer]" value="1" ' . checked( 1, isset( $options['show_footer'] ) ? $options['show_footer'] : 0, false ) . '/>';
|
||||||
|
$html .= '<label for="show_footer"> ' . $args[0] . '</label>';
|
||||||
|
|
||||||
|
echo $html;
|
||||||
|
|
||||||
|
} // end sportspress_toggle_footer_callback
|
||||||
|
|
||||||
|
function sportspress_team_stats_callback() {
|
||||||
|
sportspress_render_option_field( 'sportspress_stats', 'team', 'textarea' );
|
||||||
|
}
|
||||||
|
|
||||||
|
function sportspress_event_team_stats_callback() {
|
||||||
|
sportspress_render_option_field( 'sportspress_stats', 'event_team', 'textarea' );
|
||||||
|
}
|
||||||
|
|
||||||
|
function sportspress_event_player_stats_callback() {
|
||||||
|
sportspress_render_option_field( 'sportspress_stats', 'event_player', 'textarea' );
|
||||||
|
}
|
||||||
|
|
||||||
|
function sportspress_player_stats_callback() {
|
||||||
|
sportspress_render_option_field( 'sportspress_stats', 'player', 'textarea' );
|
||||||
|
}
|
||||||
|
|
||||||
|
function sportspress_input_element_callback() {
|
||||||
|
|
||||||
|
$options = get_option( 'sportspress_input_examples' );
|
||||||
|
|
||||||
|
// Render the output
|
||||||
|
echo '<input type="text" id="input_example" name="sportspress_input_examples[input_example]" value="' . $options['input_example'] . '" />';
|
||||||
|
|
||||||
|
} // end sportspress_input_element_callback
|
||||||
|
|
||||||
|
function sportspress_textarea_element_callback() {
|
||||||
|
|
||||||
|
$options = get_option( 'sportspress_input_examples' );
|
||||||
|
|
||||||
|
// Render the output
|
||||||
|
echo '<textarea id="textarea_example" name="sportspress_input_examples[textarea_example]" rows="5" cols="50">' . $options['textarea_example'] . '</textarea>';
|
||||||
|
|
||||||
|
} // end sportspress_textarea_element_callback
|
||||||
|
|
||||||
|
function sportspress_checkbox_element_callback() {
|
||||||
|
|
||||||
|
$options = get_option( 'sportspress_input_examples' );
|
||||||
|
|
||||||
|
$html = '<input type="checkbox" id="checkbox_example" name="sportspress_input_examples[checkbox_example]" value="1"' . checked( 1, $options['checkbox_example'], false ) . '/>';
|
||||||
|
$html .= ' ';
|
||||||
|
$html .= '<label for="checkbox_example">This is an example of a checkbox</label>';
|
||||||
|
|
||||||
|
echo $html;
|
||||||
|
|
||||||
|
} // end sportspress_checkbox_element_callback
|
||||||
|
|
||||||
|
function sportspress_radio_element_callback() {
|
||||||
|
|
||||||
|
$options = get_option( 'sportspress_input_examples' );
|
||||||
|
|
||||||
|
$html = '<input type="radio" id="radio_example_one" name="sportspress_input_examples[radio_example]" value="1"' . checked( 1, $options['radio_example'], false ) . '/>';
|
||||||
|
$html .= ' ';
|
||||||
|
$html .= '<label for="radio_example_one">Option One</label>';
|
||||||
|
$html .= ' ';
|
||||||
|
$html .= '<input type="radio" id="radio_example_two" name="sportspress_input_examples[radio_example]" value="2"' . checked( 2, $options['radio_example'], false ) . '/>';
|
||||||
|
$html .= ' ';
|
||||||
|
$html .= '<label for="radio_example_two">Option Two</label>';
|
||||||
|
|
||||||
|
echo $html;
|
||||||
|
|
||||||
|
} // end sportspress_radio_element_callback
|
||||||
|
|
||||||
|
function sportspress_select_element_callback() {
|
||||||
|
|
||||||
|
$options = get_option( 'sportspress_input_examples' );
|
||||||
|
|
||||||
|
$html = '<select id="time_options" name="sportspress_input_examples[time_options]">';
|
||||||
|
$html .= '<option value="default">' . __( 'Select a time option...', 'sportspress' ) . '</option>';
|
||||||
|
$html .= '<option value="never"' . selected( $options['time_options'], 'never', false) . '>' . __( 'Never', 'sportspress' ) . '</option>';
|
||||||
|
$html .= '<option value="sometimes"' . selected( $options['time_options'], 'sometimes', false) . '>' . __( 'Sometimes', 'sportspress' ) . '</option>';
|
||||||
|
$html .= '<option value="always"' . selected( $options['time_options'], 'always', false) . '>' . __( 'Always', 'sportspress' ) . '</option>'; $html .= '</select>';
|
||||||
|
|
||||||
|
echo $html;
|
||||||
|
|
||||||
|
} // end sportspress_radio_element_callback
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------ *
|
||||||
|
* Setting Callbacks
|
||||||
|
* ------------------------------------------------------------------------ */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanitization callback for the social options. Since each of the social options are text inputs,
|
||||||
|
* this function loops through the incoming option and strips all tags and slashes from the value
|
||||||
|
* before serializing it.
|
||||||
|
*
|
||||||
|
* @params $input The unsanitized collection of options.
|
||||||
|
*
|
||||||
|
* @returns The collection of sanitized values.
|
||||||
|
*/
|
||||||
|
function sportspress_sanitize_stats( $input ) {
|
||||||
|
|
||||||
|
// Define the array for the updated options
|
||||||
|
$output = array();
|
||||||
|
|
||||||
|
// Loop through each of the options sanitizing the data
|
||||||
|
foreach( $input as $key => $val ) {
|
||||||
|
|
||||||
|
if( isset ( $input[$key] ) ) {
|
||||||
|
$output[$key] = esc_url_raw( strip_tags( stripslashes( $input[$key] ) ) );
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
} // end foreach
|
||||||
|
|
||||||
|
// Return the new collection
|
||||||
|
return apply_filters( 'sportspress_sanitize_stats', $output, $input );
|
||||||
|
|
||||||
|
} // end sportspress_sanitize_stats
|
||||||
|
|
||||||
|
function sportspress_validate_input_examples( $input ) {
|
||||||
|
|
||||||
|
// Create our array for storing the validated options
|
||||||
|
$output = array();
|
||||||
|
|
||||||
|
// Loop through each of the incoming options
|
||||||
|
foreach( $input as $key => $value ) {
|
||||||
|
|
||||||
|
// Check to see if the current option has a value. If so, process it.
|
||||||
|
if( isset( $input[$key] ) ) {
|
||||||
|
|
||||||
|
// Strip all HTML and PHP tags and properly handle quoted strings
|
||||||
|
$output[$key] = strip_tags( stripslashes( $input[ $key ] ) );
|
||||||
|
|
||||||
|
} // end if
|
||||||
|
|
||||||
|
} // end foreach
|
||||||
|
|
||||||
|
// Return the array processing any additional functions filtered by this action
|
||||||
|
return apply_filters( 'sportspress_validate_input_examples', $output, $input );
|
||||||
|
|
||||||
|
} // end sportspress_validate_input_examples
|
||||||
|
|
||||||
|
?>
|
||||||
@@ -7,12 +7,11 @@ function sp_enqueue_styles() {
|
|||||||
}
|
}
|
||||||
//add_action( 'wp_print_styles', 'sp_enqueue_styles' );
|
//add_action( 'wp_print_styles', 'sp_enqueue_styles' );
|
||||||
|
|
||||||
function sp_admin_styles_init() {
|
function sp_admin_styles() {
|
||||||
// wp_enqueue_style( 'thickbox' );
|
|
||||||
wp_register_style( 'sportspress-admin.css', SPORTSPRESS_PLUGIN_URL . 'sportspress-admin.css', array(), '1.0' );
|
wp_register_style( 'sportspress-admin.css', SPORTSPRESS_PLUGIN_URL . 'sportspress-admin.css', array(), '1.0' );
|
||||||
wp_enqueue_style( 'sportspress-admin.css');
|
wp_enqueue_style( 'sportspress-admin.css');
|
||||||
}
|
}
|
||||||
add_action( 'admin_init', 'sp_admin_styles_init' );
|
add_action( 'admin_init', 'sp_admin_styles' );
|
||||||
|
|
||||||
function sp_adminbar_enqueue_styles() {
|
function sp_adminbar_enqueue_styles() {
|
||||||
wp_register_style( 'adminbar-stylesheet', get_template_directory_uri() . '/css/adminbar.css' );
|
wp_register_style( 'adminbar-stylesheet', get_template_directory_uri() . '/css/adminbar.css' );
|
||||||
|
|||||||
9
team.php
9
team.php
@@ -73,7 +73,14 @@ function sp_team_stats_meta( $post ) {
|
|||||||
$placeholders[ $league_id ] = sp_get_stats_row( 'sp_team', $args );
|
$placeholders[ $league_id ] = sp_get_stats_row( 'sp_team', $args );
|
||||||
endforeach;
|
endforeach;
|
||||||
|
|
||||||
sp_stats_table( $data, $placeholders, 0, array( 'League', 'P', 'W', 'D', 'L', 'F', 'A', 'GD', 'Pts' ), false, 'sp_league' );
|
// Get column names from settings
|
||||||
|
$stats_settings = get_option( 'sportspress_stats' );
|
||||||
|
$columns = sp_get_eos_keys( $stats_settings['team'] );
|
||||||
|
|
||||||
|
// Add first column label
|
||||||
|
array_unshift( $columns, __( 'League', 'sportspress' ) );
|
||||||
|
|
||||||
|
sp_stats_table( $data, $placeholders, 0, $columns, false, 'sp_league' );
|
||||||
sp_nonce();
|
sp_nonce();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user