Add completed football preset and display statistics per player position

This commit is contained in:
Brian Miyaji
2014-02-07 06:42:11 +11:00
parent 700ef3bf2d
commit b6b8e30e7e
5 changed files with 882 additions and 92 deletions

View File

@@ -83,7 +83,7 @@ function sportspress_settings_init() {
register_setting(
'sportspress_general',
'sportspress',
'sportspress_validate'
'sportspress_sport_validate'
);
add_settings_section(
@@ -125,7 +125,7 @@ function sportspress_settings_init() {
}
add_action( 'admin_init', 'sportspress_settings_init', 1 );
function sportspress_validate( $input ) {
function sportspress_sport_validate( $input ) {
$options = get_option( 'sportspress' );
@@ -137,6 +137,24 @@ function sportspress_validate( $input ) {
// Get sports presets
global $sportspress_sports;
// Get array of taxonomies to insert
$term_groups = sportspress_array_value( sportspress_array_value( $sportspress_sports, sportspress_array_value( $input, 'sport', null ), array() ), 'terms', array() );
foreach( $term_groups as $taxonomy => $terms ):
// Find empty terms and destroy
$allterms = get_terms( $taxonomy, 'hide_empty=0' );
foreach( $allterms as $term ):
if ( $term->count == 0 )
wp_delete_term( $term->term_id, $taxonomy );
endforeach;
// Insert terms
foreach( $terms as $term ):
wp_insert_term( $term['name'], $taxonomy, array( 'slug' => $term['slug'] ) );
endforeach;
endforeach;
// Get array of post types to insert
$post_groups = sportspress_array_value( sportspress_array_value( $sportspress_sports, sportspress_array_value( $input, 'sport', null ), array() ), 'posts', array() );
@@ -193,6 +211,17 @@ function sportspress_validate( $input ) {
endif;
// Update terms
if ( array_key_exists( 'tax_input', $post ) ):
foreach ( $post['tax_input'] as $taxonomy => $terms ):
wp_set_object_terms( $id, $terms, $taxonomy, false );
endforeach;
endif;
endif;
endforeach;