Move mode setting to event options

This commit is contained in:
Brian Miyaji
2015-04-14 22:19:29 +10:00
parent 2a9d6212c5
commit 0a7078d352
3 changed files with 49 additions and 51 deletions

View File

@@ -166,9 +166,6 @@ class SP_Admin_Welcome {
</div>
<?php
endif;
if ( isset( $_POST['sportspress_load_individual_mode_module'] ) ):
update_option( 'sportspress_load_individual_mode_module', $_POST['sportspress_load_individual_mode_module'] );
endif;
if ( isset( $_POST['add_sample_data'] ) ):
SP_Admin_Sample_Data::delete_posts();
SP_Admin_Sample_Data::insert_posts();
@@ -193,10 +190,6 @@ class SP_Admin_Welcome {
?>
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress', 'tab' => 'general' ), 'admin.php' ) ) ); ?>"><i class="dashicons dashicons-edit"></i> <?php _e( 'Change', 'sportspress' ); ?></a>
<h4><?php _e( 'Mode', 'sportspress' ); ?></h4>
<?php echo ( 'yes' == get_option( 'sportspress_load_individual_mode_module', 'no' ) ? __( 'Player vs player', 'sportspress' ) : __( 'Team vs team', 'sportspress' ) ); ?>
<a href="<?php echo esc_url( admin_url( add_query_arg( array( 'page' => 'sportspress', 'tab' => 'general' ), 'admin.php' ) ) ); ?>"><i class="dashicons dashicons-edit"></i> <?php _e( 'Change', 'sportspress' ); ?></a>
<h4><?php _e( 'Next Steps', 'sportspress' ); ?></h4>
<p><?php _e( 'We&#8217;ve assembled some links to get you started:', 'sportspress' ); ?></p>
<?php
@@ -278,18 +271,6 @@ class SP_Admin_Welcome {
'class' => $class,
'options' => $sport_options,
),
array(
'title' => __( 'Mode', 'sportspress' ),
'id' => 'sportspress_load_individual_mode_module',
'default' => 'no',
'type' => 'radio',
'options' => array(
'no' => __( 'Team vs team', 'sportspress' ),
'yes' => __( 'Player vs player', 'sportspress' ),
),
'desc_tip' => _x( 'Who competes in events?', 'mode setting description', 'sportspress' ),
),
);
SP_Admin_Settings::output_fields( $settings );
?>

View File

@@ -26,6 +26,7 @@ class SP_Settings_Events extends SP_Settings_Page {
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_admin_field_current_mode', array( $this, 'current_mode_setting' ) );
add_action( 'sportspress_admin_field_delimiter', array( $this, 'delimiter_setting' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
@@ -86,13 +87,27 @@ class SP_Settings_Events extends SP_Settings_Page {
),
array(
'desc' => __( 'Player Performance', 'sportspress' ),
'desc' => __( 'Box Score', 'sportspress' ),
'id' => 'sportspress_event_show_performance',
'default' => 'yes',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Mode', 'sportspress' ),
'id' => 'sportspress_load_individual_mode_module',
'default' => 'no',
'type' => 'radio',
'options' => array(
'no' => __( 'Team vs team', 'sportspress' ),
'yes' => __( 'Player vs player', 'sportspress' ),
),
'desc_tip' => _x( 'Who competes in events?', 'mode setting description', 'sportspress' ),
),
array( 'type' => 'current_mode' ),
array(
'title' => __( 'Limit', 'sportspress' ),
'id' => 'sportspress_event_teams',
@@ -108,6 +123,23 @@ class SP_Settings_Events extends SP_Settings_Page {
array( 'type' => 'delimiter' ),
array(
'title' => __( 'Teams', 'sportspress' ),
'desc' => __( 'Filter by competition', 'sportspress' ),
'id' => 'sportspress_event_filter_teams_by_league',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'start',
),
array(
'desc' => __( 'Filter by season', 'sportspress' ),
'id' => 'sportspress_event_filter_teams_by_season',
'default' => 'no',
'type' => 'checkbox',
'checkboxgroup' => 'end',
),
array(
'title' => __( 'Venues', 'sportspress' ),
'desc' => __( 'Display maps', 'sportspress' ),
@@ -202,7 +234,7 @@ class SP_Settings_Events extends SP_Settings_Page {
),
array(
array( 'title' => __( 'Player Performance', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'performance_options' ),
array( 'title' => __( 'Box Score', 'sportspress' ), 'type' => 'title', 'desc' => '', 'id' => 'performance_options' ),
),
apply_filters( 'sportspress_performance_options', array(
@@ -364,6 +396,21 @@ class SP_Settings_Events extends SP_Settings_Page {
</tr>
<?php
}
/**
* Output script to refresh page when mode is changed.
*/
function current_mode_setting() {
?>
<input type="hidden" name="sportspress_individual_mode_module_loaded" value="<?php echo get_option( 'sportspress_load_individual_mode_module', 'no' ); ?>">
<?php if ( sp_array_value( $_POST, 'sportspress_load_individual_mode_module', 'no' ) !== sp_array_value( $_POST, 'sportspress_individual_mode_module_loaded', 'no' ) ) { ?>
<script type="text/javascript">
window.onload = function() {
window.location = window.location.href;
}
</script>
<?php }
}
}
endif;

View File

@@ -28,7 +28,6 @@ class SP_Settings_General extends SP_Settings_Page {
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );
add_action( 'sportspress_admin_field_timezone', array( $this, 'timezone_setting' ) );
add_action( 'sportspress_admin_field_frontend_styles', array( $this, 'frontend_styles_setting' ) );
add_action( 'sportspress_admin_field_current_mode', array( $this, 'current_mode_setting' ) );
add_action( 'sportspress_settings_save_' . $this->id, array( $this, 'save' ) );
}
@@ -57,20 +56,6 @@ class SP_Settings_General extends SP_Settings_Page {
'type' => 'sport',
'options' => $presets,
),
array(
'title' => __( 'Mode', 'sportspress' ),
'id' => 'sportspress_load_individual_mode_module',
'default' => 'no',
'type' => 'radio',
'options' => array(
'no' => __( 'Team vs team', 'sportspress' ),
'yes' => __( 'Player vs player', 'sportspress' ),
),
'desc_tip' => _x( 'Who competes in events?', 'mode setting description', 'sportspress' ),
),
array( 'type' => 'current_mode' ),
)),
array(
@@ -363,21 +348,6 @@ class SP_Settings_General extends SP_Settings_Page {
<input name="' . esc_attr( $id ). '" id="' . esc_attr( $id ) . '" type="text" value="' . esc_attr( $value ) . '" class="colorpick" /> <div id="colorPickerDiv_' . esc_attr( $id ) . '" class="colorpickdiv"></div>
</div>';
}
/**
* Output script to refresh page when mode is changed.
*/
function current_mode_setting() {
?>
<input type="hidden" name="sportspress_individual_mode_module_loaded" value="<?php echo get_option( 'sportspress_load_individual_mode_module', 'no' ); ?>">
<?php if ( sp_array_value( $_POST, 'sportspress_load_individual_mode_module', 'no' ) !== sp_array_value( $_POST, 'sportspress_individual_mode_module_loaded', 'no' ) ) { ?>
<script type="text/javascript">
window.onload = function() {
window.location = window.location.href;
}
</script>
<?php }
}
}
endif;