Merge globals into single file, load options, and add text settings page

This commit is contained in:
Brian Miyaji
2014-03-18 16:39:53 +11:00
parent ee33f7b630
commit 37ebe39620
25 changed files with 748 additions and 497 deletions

View File

@@ -1,134 +1,136 @@
<?php
function sportspress_results_callback() {
$options = get_option( 'sportspress' );
class SportsPressEventSettingsPage {
private $options;
$main_result = sportspress_array_value( $options, 'main_result', 0 );
public function __construct() {
global $sportspress_options;
$this->options =& $sportspress_options;
add_action( 'admin_init', array( $this, 'page_init' ), 1 );
}
$args = array(
'post_type' => 'sp_result',
'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( '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
if ( sizeof( $data ) > 0 ):
$default = end( $data );
reset( $data );
printf( __( 'Default (%s)', 'sportspress' ), $default->post_title );
else:
_e( 'Default', 'sportspress' );
endif;
?>
</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>
function page_init() {
register_setting(
'sportspress_events',
'sportspress',
'sportspress_options_validate'
);
add_settings_section(
'event',
__( 'Event Options', 'sportspress' ),
'',
'sportspress_events'
);
add_settings_field(
'results',
__( 'Results', 'sportspress' ),
array( $this, 'results_callback' ),
'sportspress_events',
'event'
);
add_settings_field(
'outcomes',
__( 'Outcomes', 'sportspress' ),
array( $this, 'outcomes_callback' ),
'sportspress_events',
'event'
);
}
function results_callback() {
$main_result = sportspress_array_value( $this->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 );
?>
<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
if ( sizeof( $data ) > 0 ):
$default = end( $data );
reset( $data );
printf( __( 'Default (%s)', 'sportspress' ), $default->post_title );
else:
_e( 'Default', 'sportspress' );
endif;
?>
</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>
<br class="clear">
</div>
</fieldset>
<?php
}
</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>
function outcomes_callback() {
$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>
<?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>
<br class="clear">
</div>
</fieldset>
<?php
</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 );
if ( is_admin() )
$sportspress_event_settings_page = new SportsPressEventSettingsPage();

View File

@@ -1,44 +1,55 @@
<?php
function sportspress_sport_callback() {
global $sportspress_sports;
$options = get_option( 'sportspress' );
class SportsPressGeneralSettingsPage {
private $options;
$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
public function __construct() {
global $sportspress_options;
$this->options =& $sportspress_options;
add_action( 'admin_init', array( $this, 'page_init' ), 1 );
}
function page_init() {
register_setting(
'sportspress_general',
'sportspress',
'sportspress_options_validate'
);
add_settings_section(
'general',
__( 'General Options', 'sportspress' ),
'',
'sportspress_general'
);
add_settings_field(
'sport',
__( 'Sport', 'sportspress' ),
array( $this, 'sport_callback' ),
'sportspress_general',
'general'
);
}
function sport_callback() {
global $sportspress_options, $sportspress_sports;
$selected = sportspress_array_value( $sportspress_options, 'sport', null );
$custom_sport_name = sportspress_array_value( $sportspress_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 );
if ( is_admin() )
$sportspress_event_settings_page = new SportsPressGeneralSettingsPage();

View File

@@ -1,145 +1,190 @@
<?php
function sportspress_player_settings_details_callback() {
$options = get_option( 'sportspress' );
class SportsPressPlayerSettingsPage {
private $options;
$show_nationality_flag = sportspress_array_value( $options, 'player_show_nationality_flag', true );
?>
<fieldset>
<label for="sportspress_player_show_nationality_flag">
<input id="sportspress_player_show_nationality_flag_default" name="sportspress[player_show_nationality_flag]" type="hidden" value="0">
<input id="sportspress_player_show_nationality_flag" name="sportspress[player_show_nationality_flag]" type="checkbox" value="1" <?php checked( $show_nationality_flag ); ?>>
<?php _e( 'Display national flags', 'sportspress' ); ?>
</label>
</fieldset>
<?php
}
public function __construct() {
global $sportspress_options;
$this->options =& $sportspress_options;
add_action( 'admin_init', array( $this, 'page_init' ), 1 );
}
function sportspress_player_settings_metrics_callback() {
$args = array(
'post_type' => 'sp_metric',
'numberposts' => -1,
'posts_per_page' => -1,
function page_init() {
register_setting(
'sportspress_players',
'sportspress',
'sportspress_options_validate'
);
add_settings_section(
'player',
__( 'Player Options', 'sportspress' ),
'',
'sportspress_players'
);
add_settings_section(
'list',
__( 'Player List Options', 'sportspress' ),
'',
'sportspress_players'
);
add_settings_field(
'nationality',
__( 'Nationality', 'sportspress' ),
array( $this, 'nationality_callback' ),
'sportspress_players',
'player'
);
add_settings_field(
'list',
__( 'List', 'sportspress' ),
array( $this, 'list_callback' ),
'sportspress_players',
'list'
);
add_settings_field(
'gallery',
__( 'Gallery', 'sportspress' ),
array( $this, 'gallery_callback' ),
'sportspress_players',
'list'
);
add_settings_field(
'metrics',
__( 'Metrics', 'sportspress' ),
array( $this, 'metrics_callback' ),
'sportspress_players',
'list'
);
add_settings_field(
'statistics',
__( 'Statistics', 'sportspress' ),
array( $this, 'statistics_callback' ),
'sportspress_players',
'list'
);
}
function nationality_callback() {
$show_nationality_flag = sportspress_array_value( $this->options, 'player_show_nationality_flag', true );
?>
<fieldset>
<label for="sportspress_player_show_nationality_flag">
<input id="sportspress_player_show_nationality_flag_default" name="sportspress[player_show_nationality_flag]" type="hidden" value="0">
<input id="sportspress_player_show_nationality_flag" name="sportspress[player_show_nationality_flag]" type="checkbox" value="1" <?php checked( $show_nationality_flag ); ?>>
<?php _e( 'Display national flags', 'sportspress' ); ?>
</label>
</fieldset>
<?php
}
function list_callback() {
$link_posts = sportspress_array_value( $this->options, 'player_list_link_posts', true );
?>
<fieldset>
<label for="sportspress_player_list_link_posts">
<input id="sportspress_player_list_link_posts_default" name="sportspress[player_list_link_posts]" type="hidden" value="0">
<input id="sportspress_player_list_link_posts" name="sportspress[player_list_link_posts]" type="checkbox" value="1" <?php checked( $link_posts ); ?>>
<?php _e( 'Display players as links', 'sportspress' ); ?>
</label>
</fieldset>
<?php
}
function gallery_callback() {
$show_names_on_hover = sportspress_array_value( $this->options, 'player_gallery_show_names_on_hover', true );
?>
<fieldset>
<label for="sportspress_player_gallery_show_names_on_hover">
<input id="sportspress_player_gallery_show_names_on_hover_default" name="sportspress[player_gallery_show_names_on_hover]" type="hidden" value="0">
<input id="sportspress_player_gallery_show_names_on_hover" name="sportspress[player_gallery_show_names_on_hover]" type="checkbox" value="1" <?php checked( $show_names_on_hover ); ?>>
<?php _e( 'Display player names on hover', 'sportspress' ); ?>
</label>
</fieldset>
<?php
}
function 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>
<?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 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">&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>
);
$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>
<?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>
<br class="clear">
</div>
</fieldset>
<?
</fieldset>
<?php
}
}
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(
'details',
__( 'Details', 'sportspress' ),
'sportspress_player_settings_details_callback',
'sportspress_players',
'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 );
if ( is_admin() )
$sportspress_event_settings_page = new SportsPressPlayerSettingsPage();

View File

@@ -1,98 +0,0 @@
<?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

@@ -0,0 +1,114 @@
<?php
class SportsPressTeamSettingsPage {
private $options;
public function __construct() {
global $sportspress_options;
$this->options =& $sportspress_options;
add_action( 'admin_init', array( $this, 'page_init' ), 1 );
}
function page_init() {
register_setting(
'sportspress_teams',
'sportspress',
'sportspress_options_validate'
);
add_settings_section(
'team',
__( 'Team Options', 'sportspress' ),
'',
'sportspress_teams'
);
add_settings_section(
'table',
__( 'League Table Options', 'sportspress' ),
'',
'sportspress_teams'
);
add_settings_field(
'table',
__( 'Teams', 'sportspress' ),
array( $this, 'tables_callback' ),
'sportspress_teams',
'table'
);
add_settings_field(
'columns',
__( 'Columns', 'sportspress' ),
array( $this, 'columns_callback' ),
'sportspress_teams',
'table'
);
}
function tables_callback() {
$show_team_logo = sportspress_array_value( $this->options, 'league_table_show_team_logo', false );
$link_posts = sportspress_array_value( $this->options, 'league_table_link_posts', 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>
<fieldset>
<label for="sportspress_league_table_link_posts">
<input id="sportspress_league_table_link_posts_default" name="sportspress[league_table_link_posts]" type="hidden" value="0">
<input id="sportspress_league_table_link_posts" name="sportspress[league_table_link_posts]" type="checkbox" value="1" <?php checked( $link_posts ); ?>>
<?php _e( 'Display teams as links', 'sportspress' ); ?>
</label>
</fieldset>
<?php
}
function 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>
<?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
}
}
if ( is_admin() )
$sportspress_event_settings_page = new SportsPressTeamSettingsPage();

View File

@@ -0,0 +1,55 @@
<?php
class SportsPressTextSettingsPage {
public function __construct() {
global $sportspress_options;
$this->options =& $sportspress_options;
$this->strings = array(
array( 'league', __( 'League', 'sportspress' ) ),
array( 'season', __( 'Season', 'sportspress' ) ),
array( 'venue', __( 'Venue', 'sportspress' ) ),
array( 'rank', __( 'Rank', 'sportspress' ) ),
array( 'hash', '#' ),
array( 'player', __( 'Player', 'sportspress' ) ),
array( 'team', __( 'Team', 'sportspress' ) ),
array( 'pos', __( 'Pos', 'sportspress' ) ),
array( 'current_team', __( 'Current Team', 'sportspress' ) ),
);
add_action( 'admin_init', array( $this, 'page_init' ), 1 );
}
function page_init() {
register_setting(
'sportspress_text',
'sportspress',
'sportspress_options_validate'
);
add_settings_section(
'string',
__( 'Strings', 'sportspress' ),
'',
'sportspress_text'
);
foreach ( $this->strings as $string ):
add_settings_field(
$string[0],
$string[1],
array( $this, 'string_callback' ),
'sportspress_text',
'string'
);
endforeach;
}
public function string_callback( $test ) {
$string = array_shift( $this->strings );
$key = $string[0];
$placeholder = $string[1];
$text = sportspress_array_value( $this->options, $key . '_string', null );
?><fieldset><input id="sportspress_<?php echo $key; ?>_string" name="sportspress[<?php echo $key; ?>_string]" type="text" value="<?php echo $text; ?>" placeholder="<?php echo $placeholder; ?>"></fieldset><?php
}
}
if ( is_admin() )
$sportspress_text_settings_page = new SportsPressTextSettingsPage();

View File

@@ -7,35 +7,37 @@ function sportspress_options() {
<div class="wrap">
<h2 class="nav-tab-wrapper">
<a href="<?php echo remove_query_arg( 'tab' ); ?>" class="nav-tab<?php echo $active_tab == 'general' ? ' nav-tab-active' : ''; ?>"><?php _e( 'General', 'sportspress' ); ?></a>
<a href="<?php echo add_query_arg( 'tab', 'events' ); ?>" class="nav-tab<?php echo $active_tab == 'events' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Events', 'sportspress' ); ?></a>
<a href="<?php echo add_query_arg( 'tab', 'tables' ); ?>" class="nav-tab<?php echo $active_tab == 'tables' ? ' nav-tab-active' : ''; ?>"><?php _e( 'League Tables', 'sportspress' ); ?></a>
<a href="<?php echo add_query_arg( 'tab', 'players' ); ?>" class="nav-tab<?php echo $active_tab == 'players' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Players', 'sportspress' ); ?></a>
<a href="<?php echo remove_query_arg( 'tab' ); ?>" class="nav-tab<?php echo $active_tab == 'general' ? ' nav-tab-active' : ''; ?>"><?php _e( 'SportsPress', 'sportspress' ); ?></a>
<a href="<?php echo add_query_arg( 'tab', 'events' ); ?>" class="nav-tab<?php echo $active_tab == 'events' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Schedule', 'sportspress' ); ?></a>
<a href="<?php echo add_query_arg( 'tab', 'teams' ); ?>" class="nav-tab<?php echo $active_tab == 'teams' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Teams', 'sportspress' ); ?></a>
<a href="<?php echo add_query_arg( 'tab', 'players' ); ?>" class="nav-tab<?php echo $active_tab == 'players' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Roster', 'sportspress' ); ?></a>
<a href="<?php echo add_query_arg( 'tab', 'text' ); ?>" class="nav-tab<?php echo $active_tab == 'text' ? ' nav-tab-active' : ''; ?>"><?php _e( 'Text', 'sportspress' ); ?></a>
</h2>
<form method="post" action="options.php">
<?php
switch ( $active_tab ):
case 'events':
?><h3 class="title"><?php _e( 'Event Options', 'sportspress' ); ?></h3><?php
settings_fields( 'sportspress_events' );
do_settings_sections( 'sportspress_events' );
submit_button();
break;
case 'tables':
?><h3 class="title"><?php _e( 'League Table Options', 'sportspress' ); ?></h3><?php
settings_fields( 'sportspress_tables' );
do_settings_sections( 'sportspress_tables' );
case 'teams':
settings_fields( 'sportspress_teams' );
do_settings_sections( 'sportspress_teams' );
submit_button();
break;
case 'players':
?><h3 class="title"><?php _e( 'Player Options', 'sportspress' ); ?></h3><?php
settings_fields( 'sportspress_players' );
do_settings_sections( 'sportspress_players' );
submit_button();
break;
case 'text':
settings_fields( 'sportspress_text' );
do_settings_sections( 'sportspress_text' );
submit_button();
break;
default:
?><h3 class="title"><?php _e( 'General Options', 'sportspress' ); ?></h3><?php
settings_fields( 'sportspress_general' );
do_settings_sections( 'sportspress_general' );
submit_button();