Organize settings tabs

This commit is contained in:
Brian Miyaji
2014-03-08 01:22:47 +11:00
parent 45e45c2211
commit 3cb3737597
11 changed files with 429 additions and 395 deletions

View File

@@ -1,82 +0,0 @@
<h3 class="title"><?php _e( 'Event Settings', 'sportspress' ); ?></h3>
<?php
settings_fields( 'sportspress_events' );
do_settings_sections( 'sportspress_events' );
submit_button();
$args = array(
'post_type' => 'sp_result',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$data = get_posts( $args );
?>
<h3 class="title"><?php _e( 'Results', 'sportspress' ); ?></h3>
<table class="widefat sp-admin-config-table">
<thead>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
</tr>
</tfoot>
<?php $i = 0; foreach ( $data as $row ): ?>
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="row-title"><?php echo $row->post_title; ?></td>
<td><?php echo $row->post_name; ?>for / <?php echo $row->post_name; ?>against</td>
</tr>
<?php $i++; endforeach; ?>
</table>
<div class="tablenav bottom">
<div class="alignleft actions">
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_result' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_result' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
</div>
<br class="clear">
</div>
<?php
$args = array(
'post_type' => 'sp_outcome',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$data = get_posts( $args );
?>
<h3 class="title"><?php _e( 'Outcomes', 'sportspress' ); ?></h3>
<table class="widefat sp-admin-config-table">
<thead>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
</tr>
</tfoot>
<?php $i = 0; foreach ( $data as $row ): ?>
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="row-title"><?php echo $row->post_title; ?></td>
<td><?php echo $row->post_name; ?></td>
</tr>
<?php $i++; endforeach; ?>
</table>
<div class="tablenav bottom">
<div class="alignleft actions">
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_outcome' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_outcome' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
</div>
<br class="clear">
</div>

View File

@@ -1,5 +0,0 @@
<h3 class="title"><?php _e( 'General Settings', 'sportspress' ); ?></h3>
<?php
settings_fields( 'sportspress_general' );
do_settings_sections( 'sportspress_general' );
submit_button();

View File

@@ -0,0 +1,127 @@
<?php
function sportspress_results_callback() {
$options = get_option( 'sportspress' );
$main_result = sportspress_array_value( $options, 'main_result', 0 );
$args = array(
'post_type' => 'sp_result',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$data = get_posts( $args );
$default = end( $data );
reset( $data );
?>
<fieldset>
<table class="widefat sp-admin-config-table">
<thead>
<tr>
<th scope="col"><?php _e( 'Primary', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th class="radio"><input type="radio" id="sportspress_main_result_0" name="sportspress[main_result]" value="0" <?php checked( $main_result, 0 ); ?>></th>
<th colspan="2"><label for="sportspress_main_result_0"><?php printf( __( 'Default (%s)', 'sportspress' ), $default->post_title ); ?></label></th>
</tr>
</tfoot>
<?php $i = 0; foreach ( $data as $row ): ?>
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="radio"><input type="radio" id="sportspress_main_result_<?php echo $row->post_name; ?>" name="sportspress[main_result]" value="<?php echo $row->post_name; ?>" <?php checked( $main_result, $row->post_name ); ?>></td>
<td class="row-title"><label for="sportspress_main_result_<?php echo $row->post_name; ?>"><?php echo $row->post_title; ?></label></td>
<td><?php echo $row->post_name; ?>for / <?php echo $row->post_name; ?>against</td>
</tr>
<?php $i++; endforeach; ?>
</table>
<div class="tablenav bottom">
<div class="alignleft actions">
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_result' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_result' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
</div>
<br class="clear">
</div>
</fieldset>
<?php
}
function sportspress_outcomes_callback() {
$options = get_option( 'sportspress' );
$args = array(
'post_type' => 'sp_outcome',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$data = get_posts( $args );
?>
<fieldset>
<table class="widefat sp-admin-config-table">
<thead>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
</tr>
</tfoot>
<?php $i = 0; foreach ( $data as $row ): ?>
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="row-title"><?php echo $row->post_title; ?></td>
<td><?php echo $row->post_name; ?></td>
</tr>
<?php $i++; endforeach; ?>
</table>
<div class="tablenav bottom">
<div class="alignleft actions">
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_outcome' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_outcome' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
</div>
<br class="clear">
</div>
</fieldset>
<?php
}
function sportspress_event_settings_init() {
register_setting(
'sportspress_events',
'sportspress',
'sportspress_options_validate'
);
add_settings_section(
'events',
'',
'',
'sportspress_events'
);
add_settings_field(
'results',
__( 'Results', 'sportspress' ),
'sportspress_results_callback',
'sportspress_events',
'events'
);
add_settings_field(
'outcomes',
__( 'Outcomes', 'sportspress' ),
'sportspress_outcomes_callback',
'sportspress_events',
'events'
);
}
add_action( 'admin_init', 'sportspress_event_settings_init', 1 );

View File

@@ -0,0 +1,44 @@
<?php
function sportspress_sport_callback() {
global $sportspress_sports;
$options = get_option( 'sportspress' );
$selected = sportspress_array_value( $options, 'sport', null );
$custom_sport_name = sportspress_array_value( $options, 'custom_sport_name', null );
?>
<fieldset>
<select id="sportspress_sport" name="sportspress[sport]">
<option value><?php _e( '&mdash; Select &mdash;', 'sportspress' ); ?></option>
<?php foreach( $sportspress_sports as $slug => $sport ): ?>
<option value="<?php echo $slug; ?>" <?php selected( $selected, $slug ); ?>><?php echo $sport['name']; ?></option>
<?php endforeach; ?>
<option value="custom" <?php selected( $selected, 'custom' ); ?>><?php _e( 'Custom', 'sportspress' ); ?></option>
</select>
<input id="sportspress_custom_sport_name" name="sportspress[custom_sport_name]" type="text" placeholder="<?php _e( 'Sport', 'sportspress' ); ?>" value="<?php echo $custom_sport_name; ?>"<?php if ( $selected != 'custom' ): ?> class="hidden"<?php endif; ?>>
</fieldset>
<?php
}
function sportspress_general_settings_init() {
register_setting(
'sportspress_general',
'sportspress',
'sportspress_options_validate'
);
add_settings_section(
'general',
'',
'',
'sportspress_general'
);
add_settings_field(
'sport',
__( 'Sport', 'sportspress' ),
'sportspress_sport_callback',
'sportspress_general',
'general'
);
}
add_action( 'admin_init', 'sportspress_general_settings_init', 1 );

View File

@@ -0,0 +1,122 @@
<?php
function sportspress_player_settings_metrics_callback() {
$args = array(
'post_type' => 'sp_metric',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$data = get_posts( $args );
?>
<fieldset>
<table class="widefat sp-admin-config-table">
<thead>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Positions', 'sportspress' ); ?></th>
<th scope="col">&nbsp;</th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Positions', 'sportspress' ); ?></th>
<th scope="col">&nbsp;</th>
</tr>
</tfoot>
<?php $i = 0; foreach ( $data as $row ): ?>
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="row-title"><?php echo $row->post_title; ?></td>
<td><?php echo get_the_terms ( $row->ID, 'sp_position' ) ? the_terms( $row->ID, 'sp_position' ) : '&mdash;'; ?></td>
<td>&nbsp;</td>
</tr>
<?php $i++; endforeach; ?>
</table>
<div class="tablenav bottom">
<div class="alignleft actions">
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_metric' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_metric' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
</div>
<br class="clear">
</div>
</fieldset>
<?
}
function sportspress_player_settings_statistics_callback() {
$args = array(
'post_type' => 'sp_statistic',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$data = get_posts( $args );
?>
<fieldset>
<table class="widefat sp-admin-config-table">
<thead>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Positions', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Calculate', 'sportspress' ); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Positions', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Calculate', 'sportspress' ); ?></th>
</tr>
</tfoot>
<?php $i = 0; foreach ( $data as $row ): ?>
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="row-title"><?php echo $row->post_title; ?></td>
<td><?php echo get_the_terms ( $row->ID, 'sp_position' ) ? the_terms( $row->ID, 'sp_position' ) : '&mdash;'; ?></td>
<td><?php echo sportspress_get_post_calculate( $row->ID ); ?></td>
</tr>
<?php $i++; endforeach; ?>
</table>
<div class="tablenav bottom">
<div class="alignleft actions">
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_statistic' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_statistic' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
</div>
<br class="clear">
</div>
</fieldset>
<?php
}
function sportspress_player_settings_init() {
register_setting(
'sportspress_players',
'sportspress',
'sportspress_options_validate'
);
add_settings_section(
'players',
'',
'',
'sportspress_players'
);
add_settings_field(
'metrics',
__( 'Metrics', 'sportspress' ),
'sportspress_player_settings_metrics_callback',
'sportspress_players',
'players'
);
add_settings_field(
'statistics',
__( 'Statistics', 'sportspress' ),
'sportspress_player_settings_statistics_callback',
'sportspress_players',
'players'
);
}
add_action( 'admin_init', 'sportspress_player_settings_init', 1 );

View File

@@ -0,0 +1,98 @@
<?php
function sportspress_table_settings_teams_callback() {
$options = get_option( 'sportspress' );
$show_team_logo = sportspress_array_value( $options, 'league_table_show_team_logo', false );
?>
<fieldset>
<label for="sportspress_league_table_show_team_logo">
<input id="sportspress_league_table_show_team_logo_default" name="sportspress[league_table_show_team_logo]" type="hidden" value="0">
<input id="sportspress_league_table_show_team_logo" name="sportspress[league_table_show_team_logo]" type="checkbox" value="1" <?php checked( $show_team_logo ); ?>>
<?php _e( 'Display logos', 'sportspress' ); ?>
</label>
</fieldset>
<?php
}
function sportspress_table_settings_columns_callback() {
$args = array(
'post_type' => 'sp_column',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$data = get_posts( $args );
?>
<fieldset>
<table class="widefat sp-admin-config-table">
<thead>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Equation', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Rounding', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Sort Order', 'sportspress' ); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Equation', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Rounding', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Sort Order', 'sportspress' ); ?></th>
</tr>
</tfoot>
<?php $i = 0; foreach ( $data as $row ): ?>
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="row-title"><?php echo $row->post_title; ?></td>
<td><?php echo $row->post_name; ?></td>
<td><?php echo sportspress_get_post_equation( $row->ID, $row->post_name ); ?></td>
<td><?php echo sportspress_get_post_precision( $row->ID ); ?></td>
<td><?php echo sportspress_get_post_order( $row->ID ); ?></td>
</tr>
<?php $i++; endforeach; ?>
</table>
<div class="tablenav bottom">
<div class="alignleft actions">
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_column' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_column' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
</div>
<br class="clear">
</div>
</fieldset>
<?php
}
function sportspress_table_settings_init() {
register_setting(
'sportspress_tables',
'sportspress',
'sportspress_options_validate'
);
add_settings_section(
'tables',
'',
'',
'sportspress_tables'
);
add_settings_field(
'teams',
__( 'Teams', 'sportspress' ),
'sportspress_table_settings_teams_callback',
'sportspress_tables',
'tables'
);
add_settings_field(
'columns',
__( 'Columns', 'sportspress' ),
'sportspress_table_settings_columns_callback',
'sportspress_tables',
'tables'
);
}
add_action( 'admin_init', 'sportspress_table_settings_init', 1 );

View File

@@ -1,87 +0,0 @@
<h3 class="title"><?php _e( 'Player Settings', 'sportspress' ); ?></h3>
<?php
settings_fields( 'sportspress_players' );
do_settings_sections( 'sportspress_players' );
submit_button();
$args = array(
'post_type' => 'sp_metric',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$data = get_posts( $args );
?>
<h3 class="title"><?php _e( 'Metrics', 'sportspress' ); ?></h3>
<table class="widefat sp-admin-config-table">
<thead>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Positions', 'sportspress' ); ?></th>
<th scope="col">&nbsp;</th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Positions', 'sportspress' ); ?></th>
<th scope="col">&nbsp;</th>
</tr>
</tfoot>
<?php $i = 0; foreach ( $data as $row ): ?>
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="row-title"><?php echo $row->post_title; ?></td>
<td><?php echo get_the_terms ( $row->ID, 'sp_position' ) ? the_terms( $row->ID, 'sp_position' ) : '&mdash;'; ?></td>
<td>&nbsp;</td>
</tr>
<?php $i++; endforeach; ?>
</table>
<div class="tablenav bottom">
<div class="alignleft actions">
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_metric' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_metric' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
</div>
<br class="clear">
</div>
<?php
$args = array(
'post_type' => 'sp_statistic',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$data = get_posts( $args );
?>
<h3 class="title"><?php _e( 'Statistics', 'sportspress' ); ?></h3>
<table class="widefat sp-admin-config-table">
<thead>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Positions', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Calculate', 'sportspress' ); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Positions', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Calculate', 'sportspress' ); ?></th>
</tr>
</tfoot>
<?php $i = 0; foreach ( $data as $row ): ?>
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="row-title"><?php echo $row->post_title; ?></td>
<td><?php echo get_the_terms ( $row->ID, 'sp_position' ) ? the_terms( $row->ID, 'sp_position' ) : '&mdash;'; ?></td>
<td><?php echo sportspress_get_post_calculate( $row->ID ); ?></td>
</tr>
<?php $i++; endforeach; ?>
</table>
<div class="tablenav bottom">
<div class="alignleft actions">
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_statistic' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_statistic' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
</div>
<br class="clear">
</div>

View File

@@ -1,5 +1,5 @@
<?php
function sportspress_settings() {
function sportspress_options() {
$active_tab = isset( $_GET[ 'tab' ] ) ? $_GET[ 'tab' ] : 'general';
@@ -17,16 +17,29 @@ function sportspress_settings() {
<?php
switch ( $active_tab ):
case 'events':
include 'events.php';
?><h3 class="title"><?php _e( 'Event Options', 'sportspress' ); ?></h3><?php
settings_fields( 'sportspress_events' );
do_settings_sections( 'sportspress_events' );
submit_button();
break;
case 'tables':
include 'tables.php';
?><h3 class="title"><?php _e( 'League Table Options', 'sportspress' ); ?></h3><?php
settings_fields( 'sportspress_tables' );
do_settings_sections( 'sportspress_tables' );
submit_button();
break;
case 'players':
include 'players.php';
?><h3 class="title"><?php _e( 'Player Options', 'sportspress' ); ?></h3><?php
settings_fields( 'sportspress_players' );
do_settings_sections( 'sportspress_players' );
submit_button();
break;
default:
include 'general.php';
?><h3 class="title"><?php _e( 'General Options', 'sportspress' ); ?></h3><?php
settings_fields( 'sportspress_general' );
do_settings_sections( 'sportspress_general' );
submit_button();
break;
endswitch;
?>
</form>
@@ -35,166 +48,6 @@ function sportspress_settings() {
<?php
}
function sportspress_sport_callback() {
global $sportspress_sports;
$options = get_option( 'sportspress' );
$selected = sportspress_array_value( $options, 'sport', null );
$custom_sport_name = sportspress_array_value( $options, 'custom_sport_name', null );
?>
<fieldset>
<select id="sportspress_sport" name="sportspress[sport]">
<option value><?php _e( '&mdash; Select &mdash;', 'sportspress' ); ?></option>
<?php foreach( $sportspress_sports as $slug => $sport ): ?>
<option value="<?php echo $slug; ?>" <?php selected( $selected, $slug ); ?>><?php echo $sport['name']; ?></option>
<?php endforeach; ?>
<option value="custom" <?php selected( $selected, 'custom' ); ?>><?php _e( 'Custom', 'sportspress' ); ?></option>
</select>
<input id="sportspress_custom_sport_name" name="sportspress[custom_sport_name]" type="text" placeholder="<?php _e( 'Sport', 'sportspress' ); ?>" value="<?php echo $custom_sport_name; ?>"<?php if ( $selected != 'custom' ): ?> class="hidden"<?php endif; ?>>
</fieldset>
<?php
}
function sportspress_result_callback() {
$options = get_option( 'sportspress' );
$selected = sportspress_array_value( $options, 'main_result', null );
$args = array(
'post_type' => 'sp_result',
'name' => 'sportspress[main_result]',
'show_option_all' => __( '(Auto)', 'sportspress' ),
'selected' => $selected,
'values' => 'slug',
);
?>
<fieldset>
<? sportspress_dropdown_pages( $args ); ?>
</fieldset>
<?php
}
function sportspress_team_logos_callback() {
$options = get_option( 'sportspress' );
$show_team_logo = sportspress_array_value( $options, 'league_table_show_team_logo', false );
?>
<fieldset>
<label for="sportspress_league_table_show_team_logo">
<input id="sportspress_league_table_show_team_logo_default" name="sportspress[league_table_show_team_logo]" type="hidden" value="0">
<input id="sportspress_league_table_show_team_logo" name="sportspress[league_table_show_team_logo]" type="checkbox" value="1" <?php checked( $show_team_logo ); ?>>
<?php _e( 'Display logos', 'sportspress' ); ?>
</label>
</fieldset>
<?php
}
function sportspress_team_stats_callback() {
sportspress_render_option_field( 'sportspress_stats', 'team', 'textarea' );
}
function sportspress_event_stats_callback() {
sportspress_render_option_field( 'sportspress_stats', 'event', 'textarea' );
}
function sportspress_player_stats_callback() {
sportspress_render_option_field( 'sportspress_stats', 'player', 'textarea' );
}
function sportspress_settings_init() {
$installed = get_option( 'sportspress_installed', false );
// General settings
register_setting(
'sportspress_general',
'sportspress',
'sportspress_options_validate'
);
add_settings_section(
'general',
'',
'',
'sportspress_general'
);
add_settings_field(
'sport',
__( 'Sport', 'sportspress' ),
'sportspress_sport_callback',
'sportspress_general',
'general'
);
// Event Settings
register_setting(
'sportspress_events',
'sportspress',
'sportspress_options_validate'
);
add_settings_section(
'events',
'',
'',
'sportspress_events'
);
add_settings_field(
'result',
__( 'Main Result', 'sportspress' ),
'sportspress_result_callback',
'sportspress_events',
'events'
);
// League Table Settings
register_setting(
'sportspress_tables',
'sportspress',
'sportspress_options_validate'
);
add_settings_section(
'tables',
'',
'',
'sportspress_tables'
);
add_settings_field(
'result',
__( 'Teams', 'sportspress' ),
'sportspress_team_logos_callback',
'sportspress_tables',
'tables'
);
// Player Settings
register_setting(
'sportspress_players',
'sportspress',
'sportspress_options_validate'
);
add_settings_section(
'players',
'',
'',
'sportspress_players'
);
add_settings_field(
'result',
__( 'Main Result', 'sportspress' ),
'sportspress_result_callback',
'sportspress_players',
'players'
);
}
add_action( 'admin_init', 'sportspress_settings_init', 1 );
function sportspress_options_validate( $input ) {
$options = (array)get_option( 'sportspress' );
@@ -310,7 +163,7 @@ function sportspress_add_menu_page() {
__( 'SportsPress', 'sportspress' ),
'manage_options',
'sportspress',
'sportspress_settings'
'sportspress_options'
);
}
add_action( 'admin_menu', 'sportspress_add_menu_page' );

View File

@@ -1,52 +0,0 @@
<h3 class="title"><?php _e( 'League Table Settings', 'sportspress' ); ?></h3>
<?php
settings_fields( 'sportspress_tables' );
do_settings_sections( 'sportspress_tables' );
submit_button();
$args = array(
'post_type' => 'sp_column',
'numberposts' => -1,
'posts_per_page' => -1,
'orderby' => 'menu_order',
'order' => 'ASC'
);
$data = get_posts( $args );
?>
<h3 class="title"><?php _e( 'Columns', 'sportspress' ); ?></h3>
<table class="widefat sp-admin-config-table">
<thead>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Equation', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Rounding', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Sort Order', 'sportspress' ); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Equation', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Rounding', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Sort Order', 'sportspress' ); ?></th>
</tr>
</tfoot>
<?php $i = 0; foreach ( $data as $row ): ?>
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="row-title"><?php echo $row->post_title; ?></td>
<td><?php echo $row->post_name; ?></td>
<td><?php echo sportspress_get_post_equation( $row->ID, $row->post_name ); ?></td>
<td><?php echo sportspress_get_post_precision( $row->ID ); ?></td>
<td><?php echo sportspress_get_post_order( $row->ID ); ?></td>
</tr>
<?php $i++; endforeach; ?>
</table>
<div class="tablenav bottom">
<div class="alignleft actions">
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_column' ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></a>
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_column' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
</div>
<br class="clear">
</div>

View File

@@ -258,7 +258,19 @@ table.widefat.sp-league-table th input[type=checkbox] {
.sp-admin-config-table th,
.sp-admin-config-table td {
width: 20%;
padding: 8px 10px;
}
.sp-admin-config-table th.radio,
.sp-admin-config-table td.radio {
width: 1%;
text-align: center;
}
.sp-admin-config-table th.radio input[type=radio],
.sp-admin-config-table td.radio input[type=radio] {
margin: 0;
vertical-align: middle;
}
table.widefat th.column-sp_icon,

View File

@@ -50,8 +50,12 @@ require_once dirname( __FILE__ ) . '/admin/templates/player-metrics.php';
require_once dirname( __FILE__ ) . '/admin/templates/player-statistics.php';
require_once dirname( __FILE__ ) . '/admin/templates/team-columns.php';
// Settings
require_once dirname( __FILE__ ) . '/admin/settings/settings.php' ;
// Options
require_once dirname( __FILE__ ) . '/admin/settings/settings.php';
require_once dirname( __FILE__ ) . '/admin/settings/options-general.php';
require_once dirname( __FILE__ ) . '/admin/settings/options-event.php';
require_once dirname( __FILE__ ) . '/admin/settings/options-table.php';
require_once dirname( __FILE__ ) . '/admin/settings/options-player.php';
// Custom post types
require_once dirname( __FILE__ ) . '/admin/post-types/separator.php';