Enable multiselect outcomes close #8
This commit is contained in:
@@ -22,6 +22,6 @@ function sportspress_admin_enqueue_scripts( $hook ) {
|
|||||||
wp_enqueue_script( 'sportspress-admin', SPORTSPRESS_PLUGIN_URL .'assets/js/admin.js', array( 'jquery' ), time(), true );
|
wp_enqueue_script( 'sportspress-admin', SPORTSPRESS_PLUGIN_URL .'assets/js/admin.js', array( 'jquery' ), time(), true );
|
||||||
|
|
||||||
// Localize scripts.
|
// Localize scripts.
|
||||||
wp_localize_script( 'sportspress-admin', 'localized_strings', array( 'remove_text' => __( '— Remove —', 'sportspress' ), 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ) ) );
|
wp_localize_script( 'sportspress-admin', 'localized_strings', array( 'none' => __( 'None', 'sportspress' ), 'remove_text' => __( '— Remove —', 'sportspress' ), 'days' => __( 'days', 'sportspress' ), 'hrs' => __( 'hrs', 'sportspress' ), 'mins' => __( 'mins', 'sportspress' ), 'secs' => __( 'secs', 'sportspress' ) ) );
|
||||||
}
|
}
|
||||||
add_action( 'admin_enqueue_scripts', 'sportspress_admin_enqueue_scripts' );
|
add_action( 'admin_enqueue_scripts', 'sportspress_admin_enqueue_scripts' );
|
||||||
|
|||||||
@@ -54,23 +54,7 @@ function sportspress_manage_posts_custom_column( $column, $post_id ) {
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( $team_result != null ):
|
if ( $team_result != null ):
|
||||||
echo ' — ' . $team_result;
|
echo ' <strong>' . $team_result . '</strong>';
|
||||||
endif;
|
|
||||||
|
|
||||||
$outcome_slug = sportspress_array_value( $team_results, 'outcome', null );
|
|
||||||
if ( $outcome_slug && $outcome_slug != '-1' ):
|
|
||||||
$args=array(
|
|
||||||
'name' => $outcome_slug,
|
|
||||||
'post_type' => 'sp_outcome',
|
|
||||||
'post_status' => 'publish',
|
|
||||||
'posts_per_page' => 1
|
|
||||||
);
|
|
||||||
$outcomes = get_posts( $args );
|
|
||||||
|
|
||||||
if ( sizeof( $outcomes ) ):
|
|
||||||
$outcome = reset( $outcomes );
|
|
||||||
echo ' (' . $outcome->post_title . ')';
|
|
||||||
endif;
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
echo '<br>';
|
echo '<br>';
|
||||||
|
|||||||
@@ -181,10 +181,6 @@
|
|||||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
|
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
|
||||||
}
|
}
|
||||||
|
|
||||||
.postbox .inside .sp-data-table-container {
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wp-media-buttons .button.sp-insert {
|
.wp-media-buttons .button.sp-insert {
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ jQuery(document).ready(function($){
|
|||||||
// Chosen select
|
// Chosen select
|
||||||
$(".chosen-select").chosen({
|
$(".chosen-select").chosen({
|
||||||
allow_single_deselect: true,
|
allow_single_deselect: true,
|
||||||
single_backstroke_delete: false
|
single_backstroke_delete: false,
|
||||||
|
placeholder_text_multiple: localized_strings.none
|
||||||
});
|
});
|
||||||
|
|
||||||
// Auto key placeholder
|
// Auto key placeholder
|
||||||
|
|||||||
@@ -1046,15 +1046,20 @@ if ( !function_exists( 'sportspress_edit_event_results_table' ) ) {
|
|||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
$value = sportspress_array_value( $team_results, 'outcome', '' );
|
$values = sportspress_array_value( $team_results, 'outcome', '' );
|
||||||
|
if ( ! is_array( $values ) )
|
||||||
|
$values = array( $values );
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
'post_type' => 'sp_outcome',
|
'post_type' => 'sp_outcome',
|
||||||
'name' => 'sp_results[' . $team_id . '][outcome]',
|
'name' => 'sp_results[' . $team_id . '][outcome][]',
|
||||||
'show_option_none' => __( '-- Not set --', 'sportspress' ),
|
|
||||||
'option_none_value' => '',
|
'option_none_value' => '',
|
||||||
'sort_order' => 'ASC',
|
'sort_order' => 'ASC',
|
||||||
'sort_column' => 'menu_order',
|
'sort_column' => 'menu_order',
|
||||||
'selected' => $value
|
'selected' => $values,
|
||||||
|
'class' => 'sp-outcome',
|
||||||
|
'property' => 'multiple',
|
||||||
|
'chosen' => true,
|
||||||
);
|
);
|
||||||
sportspress_dropdown_pages( $args );
|
sportspress_dropdown_pages( $args );
|
||||||
?>
|
?>
|
||||||
@@ -1534,34 +1539,43 @@ if ( !function_exists( 'sportspress_get_team_columns_data' ) ) {
|
|||||||
if ( $team_id == $post_id ):
|
if ( $team_id == $post_id ):
|
||||||
if ( $key == 'outcome' ):
|
if ( $key == 'outcome' ):
|
||||||
|
|
||||||
// Increment events played and outcome count
|
// Convert to array
|
||||||
if ( array_key_exists( $value, $totals ) ):
|
if ( ! is_array( $value ) ):
|
||||||
$totals['eventsplayed']++;
|
$value = array( $value );
|
||||||
$totals[ $value ]++;
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( $value && $value != '-1' ):
|
foreach( $value as $outcome ):
|
||||||
|
|
||||||
|
// Increment events played and outcome count
|
||||||
|
if ( array_key_exists( $outcome, $totals ) ):
|
||||||
|
$totals['eventsplayed']++;
|
||||||
|
$totals[ $outcome ]++;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if ( $outcome && $outcome != '-1' ):
|
||||||
|
|
||||||
// Add to streak counter
|
// Add to streak counter
|
||||||
if ( $streak['fire'] && ( $streak['name'] == '' || $streak['name'] == $value ) ):
|
if ( $streak['fire'] && ( $streak['name'] == '' || $streak['name'] == $outcome ) ):
|
||||||
$streak['name'] = $value;
|
$streak['name'] = $outcome;
|
||||||
$streak['count'] ++;
|
$streak['count'] ++;
|
||||||
else:
|
else:
|
||||||
$streak['fire'] = 0;
|
$streak['fire'] = 0;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Add to last 5 counter if sum is less than 5
|
// Add to last 5 counter if sum is less than 5
|
||||||
if ( array_key_exists( $value, $last5 ) && array_sum( $last5 ) < 5 ):
|
if ( array_key_exists( $outcome, $last5 ) && array_sum( $last5 ) < 5 ):
|
||||||
$last5[ $value ] ++;
|
$last5[ $outcome ] ++;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Add to last 10 counter if sum is less than 10
|
// Add to last 10 counter if sum is less than 10
|
||||||
if ( array_key_exists( $value, $last10 ) && array_sum( $last10 ) < 10 ):
|
if ( array_key_exists( $outcome, $last10 ) && array_sum( $last10 ) < 10 ):
|
||||||
$last10[ $value ] ++;
|
$last10[ $outcome ] ++;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if ( array_key_exists( $key . 'for', $totals ) ):
|
if ( array_key_exists( $key . 'for', $totals ) ):
|
||||||
$totals[ $key . 'for' ] += $value;
|
$totals[ $key . 'for' ] += $value;
|
||||||
@@ -1747,34 +1761,42 @@ if ( !function_exists( 'sportspress_get_league_table_data' ) ) {
|
|||||||
|
|
||||||
if ( $key == 'outcome' ):
|
if ( $key == 'outcome' ):
|
||||||
|
|
||||||
// Increment events played and outcome count
|
if ( ! is_array( $value ) ):
|
||||||
if ( array_key_exists( $team_id, $totals ) && is_array( $totals[ $team_id ] ) && array_key_exists( $value, $totals[ $team_id ] ) ):
|
$value = array( $value );
|
||||||
$totals[ $team_id ]['eventsplayed']++;
|
|
||||||
$totals[ $team_id ][ $value ]++;
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( $value && $value != '-1' ):
|
foreach ( $value as $outcome ):
|
||||||
|
|
||||||
|
// Increment events played and outcome count
|
||||||
|
if ( array_key_exists( $team_id, $totals ) && is_array( $totals[ $team_id ] ) && array_key_exists( $outcome, $totals[ $team_id ] ) ):
|
||||||
|
$totals[ $team_id ]['eventsplayed']++;
|
||||||
|
$totals[ $team_id ][ $outcome ]++;
|
||||||
|
endif;
|
||||||
|
|
||||||
|
if ( $outcome && $outcome != '-1' ):
|
||||||
|
|
||||||
// Add to streak counter
|
// Add to streak counter
|
||||||
if ( $streaks[ $team_id ]['fire'] && ( $streaks[ $team_id ]['name'] == '' || $streaks[ $team_id ]['name'] == $value ) ):
|
if ( $streaks[ $team_id ]['fire'] && ( $streaks[ $team_id ]['name'] == '' || $streaks[ $team_id ]['name'] == $outcome ) ):
|
||||||
$streaks[ $team_id ]['name'] = $value;
|
$streaks[ $team_id ]['name'] = $outcome;
|
||||||
$streaks[ $team_id ]['count'] ++;
|
$streaks[ $team_id ]['count'] ++;
|
||||||
else:
|
else:
|
||||||
$streaks[ $team_id ]['fire'] = 0;
|
$streaks[ $team_id ]['fire'] = 0;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Add to last 5 counter if sum is less than 5
|
// Add to last 5 counter if sum is less than 5
|
||||||
if ( array_key_exists( $team_id, $last5s ) && array_key_exists( $value, $last5s[ $team_id ] ) && array_sum( $last5s[ $team_id ] ) < 5 ):
|
if ( array_key_exists( $team_id, $last5s ) && array_key_exists( $outcome, $last5s[ $team_id ] ) && array_sum( $last5s[ $team_id ] ) < 5 ):
|
||||||
$last5s[ $team_id ][ $value ] ++;
|
$last5s[ $team_id ][ $outcome ] ++;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
// Add to last 10 counter if sum is less than 10
|
// Add to last 10 counter if sum is less than 10
|
||||||
if ( array_key_exists( $team_id, $last10s ) && array_key_exists( $value, $last10s[ $team_id ] ) && array_sum( $last10s[ $team_id ] ) < 10 ):
|
if ( array_key_exists( $team_id, $last10s ) && array_key_exists( $outcome, $last10s[ $team_id ] ) && array_sum( $last10s[ $team_id ] ) < 10 ):
|
||||||
$last10s[ $team_id ][ $value ] ++;
|
$last10s[ $team_id ][ $outcome ] ++;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
endforeach;
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if ( array_key_exists( $team_id, $totals ) && is_array( $totals[ $team_id ] ) && array_key_exists( $key . 'for', $totals[ $team_id ] ) ):
|
if ( array_key_exists( $team_id, $totals ) && is_array( $totals[ $team_id ] ) && array_key_exists( $key . 'for', $totals[ $team_id ] ) ):
|
||||||
$totals[ $team_id ][ $key . 'for' ] += $value;
|
$totals[ $team_id ][ $key . 'for' ] += $value;
|
||||||
|
|||||||
Reference in New Issue
Block a user