diff --git a/admin/post-types/column.php b/admin/post-types/column.php index 17f2fa59..6b7a7fc6 100644 --- a/admin/post-types/column.php +++ b/admin/post-types/column.php @@ -39,7 +39,11 @@ function sp_column_details_meta( $post ) { $equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) ); $order = get_post_meta( $post->ID, 'sp_order', true ); $priority = get_post_meta( $post->ID, 'sp_priority', true ); + $precision = get_post_meta( $post->ID, 'sp_precision', true ); $abbreviation = get_post_meta( $post->ID, 'sp_abbreviation', true ); + + // Defaults + if ( $precision == '' ) $precision = 1; ?>

@@ -68,6 +72,10 @@ function sp_column_details_meta( $post ) { ?>

+

+

+ +

diff --git a/admin/post-types/event.php b/admin/post-types/event.php index 5edd1687..63095d56 100644 --- a/admin/post-types/event.php +++ b/admin/post-types/event.php @@ -141,7 +141,7 @@ function sp_event_edit_columns() { 'cb' => '', 'title' => __( 'Event', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ), - 'sp_league' => __( 'Leagues', 'sportspress' ), + 'sp_season' => __( 'Seasons', 'sportspress' ), 'sp_kickoff' => __( 'Kick-off', 'sportspress' ) ); return $columns; diff --git a/admin/post-types/list.php b/admin/post-types/list.php index 78cbb41c..4654a955 100644 --- a/admin/post-types/list.php +++ b/admin/post-types/list.php @@ -25,7 +25,7 @@ function sp_list_edit_columns() { 'title' => __( 'Title' ), 'sp_player' => __( 'Players', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ), - 'sp_league' => __( 'Leagues', 'sportspress' ) + 'sp_season' => __( 'Seasons', 'sportspress' ) ); return $columns; } @@ -42,16 +42,16 @@ function sp_list_meta_init( $post ) { } function sp_list_player_meta( $post ) { - $league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 ); + $season_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 ); $team_id = get_post_meta( $post->ID, 'sp_team', true ); ?>

'sp_league', - 'name' => 'sp_league', - 'selected' => $league_id, + 'taxonomy' => 'sp_season', + 'name' => 'sp_season', + 'selected' => $season_id, 'value' => 'term_id' ); sp_dropdown_taxonomies( $args ); diff --git a/admin/post-types/player.php b/admin/post-types/player.php index ceee3972..9bd20137 100644 --- a/admin/post-types/player.php +++ b/admin/post-types/player.php @@ -21,7 +21,7 @@ add_action( 'init', 'sp_player_cpt_init' ); function sp_player_meta_init( $post ) { $teams = (array)get_post_meta( $post->ID, 'sp_team', false ); - $leagues = (array)get_the_terms( $post->ID, 'sp_league' ); + $leagues = (array)get_the_terms( $post->ID, 'sp_season' ); remove_meta_box( 'submitdiv', 'sp_player', 'side' ); add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'sp_player', 'side', 'high' ); @@ -44,7 +44,7 @@ function sp_player_team_meta( $post ) { function sp_player_stats_meta( $post ) { $team_ids = (array)get_post_meta( $post->ID, 'sp_team', false ); - $leagues = (array)get_the_terms( $post->ID, 'sp_league' ); + $leagues = (array)get_the_terms( $post->ID, 'sp_season' ); $stats = (array)get_post_meta( $post->ID, 'sp_statistics', true ); // Equation Operating System @@ -110,7 +110,7 @@ function sp_player_stats_meta( $post ) { ), 'tax_query' => array( array( - 'taxonomy' => 'sp_league', + 'taxonomy' => 'sp_season', 'field' => 'id', 'terms' => $div_id ) @@ -182,7 +182,7 @@ function sp_player_edit_columns() { 'title' => __( 'Name', 'sportspress' ), 'sp_position' => __( 'Positions', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ), - 'sp_league' => __( 'Leagues', 'sportspress' ) + 'sp_season' => __( 'Seasons', 'sportspress' ) ); return $columns; } diff --git a/admin/post-types/staff.php b/admin/post-types/staff.php index d62ff038..c277c92f 100644 --- a/admin/post-types/staff.php +++ b/admin/post-types/staff.php @@ -43,7 +43,7 @@ function sp_staff_edit_columns() { 'title' => __( 'Name', 'sportspress' ), 'sp_position' => __( 'Positions', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ), - 'sp_league' => __( 'Leagues', 'sportspress' ), + 'sp_season' => __( 'Seasons', 'sportspress' ), ); return $columns; } diff --git a/admin/post-types/statistic.php b/admin/post-types/statistic.php index c9c77625..fa9c300f 100644 --- a/admin/post-types/statistic.php +++ b/admin/post-types/statistic.php @@ -37,7 +37,13 @@ function sp_statistic_meta_init() { function sp_statistic_equation_meta( $post ) { $equation = explode( ' ', get_post_meta( $post->ID, 'sp_equation', true ) ); + $order = get_post_meta( $post->ID, 'sp_order', true ); + $priority = get_post_meta( $post->ID, 'sp_priority', true ); + $precision = get_post_meta( $post->ID, 'sp_precision', true ); $abbreviation = get_post_meta( $post->ID, 'sp_abbreviation', true ); + + // Defaults + if ( $precision == '' ) $precision = 1; ?>

+

+

+ + +

+

+ +

diff --git a/admin/post-types/table.php b/admin/post-types/table.php index ae35dede..e464d775 100644 --- a/admin/post-types/table.php +++ b/admin/post-types/table.php @@ -24,7 +24,7 @@ function sp_table_edit_columns() { 'cb' => '', 'title' => __( 'Title' ), 'sp_team' => __( 'Teams', 'sportspress' ), - 'sp_league' => __( 'Leagues', 'sportspress' ), + 'sp_season' => __( 'Seasons', 'sportspress' ), ); return $columns; } @@ -41,14 +41,14 @@ function sp_table_meta_init( $post ) { } function sp_table_team_meta( $post, $test ) { - $league_id = sp_get_the_term_id( $post->ID, 'sp_league', 0 ); + $league_id = sp_get_the_term_id( $post->ID, 'sp_season', 0 ); ?>

'sp_league', - 'name' => 'sp_league', + 'taxonomy' => 'sp_season', + 'name' => 'sp_season', 'selected' => $league_id, 'value' => 'term_id' ); @@ -56,7 +56,7 @@ function sp_table_team_meta( $post, $test ) { ?>

ID, 'sp_team', 'block', 'sp_league' ); + sp_post_checklist( $post->ID, 'sp_team', 'block', 'sp_season' ); sp_post_adder( 'sp_team' ); ?>
diff --git a/admin/post-types/team.php b/admin/post-types/team.php index 013484b9..7dbd2fa4 100644 --- a/admin/post-types/team.php +++ b/admin/post-types/team.php @@ -20,7 +20,7 @@ function sp_team_cpt_init() { add_action( 'init', 'sp_team_cpt_init' ); function sp_team_meta_init( $post ) { - $leagues = (array)get_the_terms( $post->ID, 'sp_league' ); + $leagues = (array)get_the_terms( $post->ID, 'sp_season' ); remove_meta_box( 'submitdiv', 'sp_team', 'side' ); add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'sp_team', 'side', 'high' ); @@ -37,14 +37,14 @@ function sp_team_edit_columns() { 'cb' => '', 'sp_logo' => ' ', 'title' => __( 'Team', 'sportspress' ), - 'sp_league' => __( 'Leagues', 'sportspress' ) + 'sp_season' => __( 'Seasons', 'sportspress' ) ); return $columns; } add_filter( 'manage_edit-sp_team_columns', 'sp_team_edit_columns' ); function sp_team_columns_meta( $post ) { - $leagues = (array)get_the_terms( $post->ID, 'sp_league' ); + $leagues = (array)get_the_terms( $post->ID, 'sp_season' ); $columns = (array)get_post_meta( $post->ID, 'sp_columns', true ); // Equation Operating System @@ -98,7 +98,7 @@ function sp_team_columns_meta( $post ) { ), 'tax_query' => array( array( - 'taxonomy' => 'sp_league', + 'taxonomy' => 'sp_season', 'field' => 'id', 'terms' => $div_id ) diff --git a/admin/terms/league.php b/admin/terms/season.php similarity index 52% rename from admin/terms/league.php rename to admin/terms/season.php index 50ae1908..24e39871 100644 --- a/admin/terms/league.php +++ b/admin/terms/season.php @@ -1,8 +1,8 @@ true, 'rewrite' => array( 'slug' => 'league' ) ); - register_taxonomy( 'sp_league', $object_type, $args ); + register_taxonomy( 'sp_season', $object_type, $args ); } -add_action( 'init', 'sp_league_term_init' ); +add_action( 'init', 'sp_season_term_init' ); ?> \ No newline at end of file diff --git a/sportspress-actions.php b/sportspress-actions.php index e308f0d7..d4c9fc94 100644 --- a/sportspress-actions.php +++ b/sportspress-actions.php @@ -30,13 +30,13 @@ function sp_admin_menu( $position ) { // Remove "Add Configuration" link under SportsPress unset( $submenu['edit.php?post_type=sp_config'][10] ); - // Remove "Leagues" link under Events + // Remove "Seasons" link under Events unset( $submenu['edit.php?post_type=sp_event'][15] ); - // Remove "Leagues" link under Players + // Remove "Seasons" link under Players unset( $submenu['edit.php?post_type=sp_player'][15] ); - // Remove "Leagues" link under Staff + // Remove "Seasons" link under Staff unset( $submenu['edit.php?post_type=sp_staff'][15] ); } add_action( 'admin_menu', 'sp_admin_menu' ); @@ -108,8 +108,8 @@ function sp_manage_posts_custom_column( $column, $post_id ) { case 'sp_event': echo get_post_meta ( $post_id, 'sp_event' ) ? sizeof( get_post_meta ( $post_id, 'sp_event' ) ) : '—'; break; - case 'sp_league': - echo get_the_terms ( $post_id, 'sp_league' ) ? the_terms( $post_id, 'sp_league' ) : '—'; + case 'sp_season': + echo get_the_terms ( $post_id, 'sp_season' ) ? the_terms( $post_id, 'sp_season' ) : '—'; break; case 'sp_sponsor': echo get_the_terms ( $post_id, 'sp_sponsor' ) ? the_terms( $post_id, 'sp_sponsor' ) : '—'; @@ -154,11 +154,11 @@ function sp_restrict_manage_posts() { sp_dropdown_taxonomies( $args ); endif; if ( in_array( $typenow, array( 'sp_team', 'sp_event', 'sp_player', 'sp_staff', 'sp_table', 'sp_list' ) ) ): - $selected = isset( $_REQUEST['sp_league'] ) ? $_REQUEST['sp_league'] : null; + $selected = isset( $_REQUEST['sp_season'] ) ? $_REQUEST['sp_season'] : null; $args = array( - 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Leagues', 'sportspress' ) ), - 'taxonomy' => 'sp_league', - 'name' => 'sp_league', + 'show_option_all' => sprintf( __( 'All %s', 'sportspress' ), __( 'Seasons', 'sportspress' ) ), + 'taxonomy' => 'sp_season', + 'name' => 'sp_season', 'selected' => $selected ); sp_dropdown_taxonomies( $args ); @@ -219,6 +219,13 @@ function sp_save_post( $post_id ) { break; + case ( 'sp_result' ): + + // Update abbreviation as string + update_post_meta( $post_id, 'sp_abbreviation', sp_array_value( $_POST, 'sp_abbreviation', '' ) ); + + break; + case ( 'sp_column' ): // Update equation as string @@ -233,6 +240,9 @@ function sp_save_post( $post_id ) { // Update abbreviation as string update_post_meta( $post_id, 'sp_abbreviation', sp_array_value( $_POST, 'sp_abbreviation', '' ) ); + // Update precision as integer + update_post_meta( $post_id, 'sp_precision', (int) sp_array_value( $_POST, 'sp_precision', 1 ) ); + break; case ( 'sp_statistic' ): @@ -243,6 +253,9 @@ function sp_save_post( $post_id ) { // Update abbreviation as string update_post_meta( $post_id, 'sp_abbreviation', sp_array_value( $_POST, 'sp_abbreviation', '' ) ); + // Update precision as integer + update_post_meta( $post_id, 'sp_precision', (int) sp_array_value( $_POST, 'sp_precision', 1 ) ); + break; case ( 'sp_player' ): @@ -256,19 +269,41 @@ function sp_save_post( $post_id ) { break; case ( 'sp_staff' ): + + // Update team array sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); + break; + case ( 'sp_table' ): + + // Update teams array update_post_meta( $post_id, 'sp_teams', sp_array_value( $_POST, 'sp_teams', array() ) ); - wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' ); + + // Update season taxonomy + wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' ); + + // Update team array sp_update_post_meta_recursive( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); + break; + case ( 'sp_list' ): + + // Update players array update_post_meta( $post_id, 'sp_players', sp_array_value( $_POST, 'sp_players', array() ) ); + + // Update team array update_post_meta( $post_id, 'sp_team', sp_array_value( $_POST, 'sp_team', array() ) ); - wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_league', 0 ), 'sp_league' ); + + // Update season taxonomy + wp_set_post_terms( $post_id, sp_array_value( $_POST, 'sp_season', 0 ), 'sp_season' ); + + //Update player array sp_update_post_meta_recursive( $post_id, 'sp_player', sp_array_value( $_POST, 'sp_player', array() ) ); + break; + endswitch; } add_action( 'save_post', 'sp_save_post' ); diff --git a/sportspress-functions.php b/sportspress-functions.php index cb0fdc7c..0d5fc033 100644 --- a/sportspress-functions.php +++ b/sportspress-functions.php @@ -232,7 +232,7 @@ if ( !function_exists( 'sp_post_checklist' ) ) { $parents = get_post_ancestors( $post ); if ( $filter ): $filter_values = (array)get_post_meta( $post->ID, $filter, false ); - $terms = (array)get_the_terms( $post->ID, 'sp_league' ); + $terms = (array)get_the_terms( $post->ID, 'sp_season' ); foreach ( $terms as $term ): if ( is_object( $term ) && property_exists( $term, 'term_id' ) ) $filter_values[] = $term->term_id; @@ -447,7 +447,7 @@ if ( !function_exists( 'sp_league_table' ) ) { $i = 0; foreach ( $data as $team_id => $team_stats ): if ( !$team_id ) continue; - $div = get_term( $team_id, 'sp_league' ); + $div = get_term( $team_id, 'sp_season' ); ?> @@ -487,7 +487,7 @@ if ( !function_exists( 'sp_player_table' ) ) { $i = 0; foreach ( $data as $player_id => $player_stats ): if ( !$player_id ) continue; - $div = get_term( $player_id, 'sp_league' ); + $div = get_term( $player_id, 'sp_season' ); ?> @@ -516,7 +516,7 @@ if ( !function_exists( 'sp_team_columns_table' ) ) { - + @@ -528,13 +528,13 @@ if ( !function_exists( 'sp_team_columns_table' ) ) { if ( empty( $data ) ): ?> - + $div_stats ): if ( !$div_id ) continue; - $div = get_term( $div_id, 'sp_league' ); + $div = get_term( $div_id, 'sp_season' ); ?>
@@ -564,7 +564,7 @@ if ( !function_exists( 'sp_player_statistics_table' ) ) { - + @@ -582,7 +582,7 @@ if ( !function_exists( 'sp_player_statistics_table' ) ) { endif; foreach ( $team_stats as $div_id => $div_stats ): if ( !$div_id ) continue; - $div = get_term( $div_id, 'sp_league' ); + $div = get_term( $div_id, 'sp_season' ); ?>
@@ -800,7 +800,7 @@ if ( !function_exists( 'sp_solve' ) ) { if ( !function_exists( 'sp_get_table' ) ) { function sp_get_table( $post_id, $breakdown = false ) { - $div_id = sp_get_the_term_id( $post_id, 'sp_league', 0 ); + $div_id = sp_get_the_term_id( $post_id, 'sp_season', 0 ); $team_ids = (array)get_post_meta( $post_id, 'sp_team', false ); $table_stats = (array)get_post_meta( $post_id, 'sp_teams', true ); @@ -857,7 +857,7 @@ if ( !function_exists( 'sp_get_table' ) ) { 'order' => 'ASC', 'tax_query' => array( array( - 'taxonomy' => 'sp_league', + 'taxonomy' => 'sp_season', 'field' => 'id', 'terms' => $div_id ) @@ -1031,7 +1031,7 @@ if ( !function_exists( 'sp_get_table' ) ) { if ( !function_exists( 'sp_get_list' ) ) { function sp_get_list( $post_id, $breakdown = false ) { - $div_id = sp_get_the_term_id( $post_id, 'sp_league', 0 ); + $div_id = sp_get_the_term_id( $post_id, 'sp_season', 0 ); $team_id = get_post_meta( $post_id, 'sp_team', true ); $player_ids = (array)get_post_meta( $post_id, 'sp_player', false ); $stats = (array)get_post_meta( $post_id, 'sp_players', true ); @@ -1080,7 +1080,7 @@ if ( !function_exists( 'sp_get_list' ) ) { 'posts_per_page' => -1, 'tax_query' => array( array( - 'taxonomy' => 'sp_league', + 'taxonomy' => 'sp_season', 'field' => 'id', 'terms' => $div_id ) diff --git a/sportspress-globals.php b/sportspress-globals.php index baceb88d..83b7d1be 100644 --- a/sportspress-globals.php +++ b/sportspress-globals.php @@ -32,7 +32,8 @@ $sportspress_texts = array( 'Publish immediately' => __( 'Joined', 'sportspress' ) . ': %1$s' ), 'sp_table' => array( - 'Enter title here' => '' + 'Enter title here' => '', + 'Post updated. View post' => 'test' ) ); diff --git a/sportspress.php b/sportspress.php index f8505672..c22aeb21 100644 --- a/sportspress.php +++ b/sportspress.php @@ -47,7 +47,7 @@ require_once dirname( __FILE__ ) . '/admin/post-types/list.php'; require_once dirname( __FILE__ ) . '/admin/post-types/staff.php'; // Terms -require_once dirname( __FILE__ ) . '/admin/terms/league.php'; +require_once dirname( __FILE__ ) . '/admin/terms/season.php'; require_once dirname( __FILE__ ) . '/admin/terms/position.php'; // Presets