diff --git a/admin/hooks/admin-menu.php b/admin/hooks/admin-menu.php index b6d11426..2fb6b3a7 100644 --- a/admin/hooks/admin-menu.php +++ b/admin/hooks/admin-menu.php @@ -23,6 +23,9 @@ function sportspress_admin_menu( $position ) { if ( $position ): $menu[ $position ] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' ); endif; + + // Remove "Positions" link from Media submenu + unset( $submenu['upload.php'][17] ); // Remove "Leagues" link from Players submenu unset( $submenu['edit.php?post_type=sp_player'][15] ); diff --git a/admin/hooks/manage-posts-custom-column.php b/admin/hooks/manage-posts-custom-column.php index 129c8e84..6dda282e 100644 --- a/admin/hooks/manage-posts-custom-column.php +++ b/admin/hooks/manage-posts-custom-column.php @@ -2,7 +2,7 @@ function sportspress_manage_posts_custom_column( $column, $post_id ) { global $post; switch ( $column ): - case 'sp_logo': + case 'sp_icon': edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-icon' ), '', '', $post_id ); break; case 'sp_position': diff --git a/admin/hooks/sanitize-title.php b/admin/hooks/sanitize-title.php index 6a2e5e09..8802e6c4 100644 --- a/admin/hooks/sanitize-title.php +++ b/admin/hooks/sanitize-title.php @@ -5,7 +5,7 @@ function sportspress_sanitize_title( $title ) { return $title; - elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && in_array( $_POST['post_type'], array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic' ) ) ): + elseif ( isset( $_POST ) && array_key_exists( 'post_type', $_POST ) && in_array( $_POST['post_type'], array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_statistic', 'sp_metric' ) ) ): $key = $_POST['sp_key']; diff --git a/admin/hooks/save-post.php b/admin/hooks/save-post.php index 91947ceb..57a1ddff 100644 --- a/admin/hooks/save-post.php +++ b/admin/hooks/save-post.php @@ -82,6 +82,25 @@ function sportspress_save_post( $post_id ) { break; + case ( 'sp_metric' ): + + // Update format as string + update_post_meta( $post_id, 'sp_format', sportspress_array_value( $_POST, 'sp_format', 'integer' ) ); + + // Update precision as integer + update_post_meta( $post_id, 'sp_precision', (int) sportspress_array_value( $_POST, 'sp_precision', 1 ) ); + + // Update equation as string + update_post_meta( $post_id, 'sp_equation', implode( ' ', sportspress_array_value( $_POST, 'sp_equation', array() ) ) ); + + // Update sort order as string + update_post_meta( $post_id, 'sp_priority', sportspress_array_value( $_POST, 'sp_priority', '0' ) ); + + // Update sort order as string + update_post_meta( $post_id, 'sp_order', sportspress_array_value( $_POST, 'sp_order', 'DESC' ) ); + + break; + case ( 'sp_result' ): // Update format as string @@ -100,6 +119,9 @@ function sportspress_save_post( $post_id ) { // Update player number update_post_meta( $post_id, 'sp_number', sportspress_array_value( $_POST, 'sp_number', '' ) ); + // Update current team + update_post_meta( $post_id, 'sp_current_team', sportspress_array_value( $_POST, 'sp_current_team', '' ) ); + // Update nationality update_post_meta( $post_id, 'sp_nationality', sportspress_array_value( $_POST, 'sp_nationality', '' ) ); diff --git a/admin/post-types/player.php b/admin/post-types/player.php index 157ebc98..6d2c8079 100644 --- a/admin/post-types/player.php +++ b/admin/post-types/player.php @@ -22,6 +22,7 @@ add_action( 'init', 'sportspress_player_post_init' ); function sportspress_player_edit_columns() { $columns = array( 'cb' => '', + 'sp_icon' => ' ', 'title' => __( 'Name', 'sportspress' ), 'sp_position' => __( 'Positions', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ), @@ -39,7 +40,7 @@ function sportspress_player_meta_init( $post ) { remove_meta_box( 'submitdiv', 'sp_player', 'side' ); add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'sp_player', 'side', 'high' ); remove_meta_box( 'postimagediv', 'sp_player', 'side' ); - add_meta_box( 'postimagediv', __( 'Photo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_player', 'side', 'high' ); + add_meta_box( 'postimagediv', __( 'Photo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_player', 'side', 'low' ); add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'sportspress_player_details_meta', 'sp_player', 'side', 'high' ); add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sportspress_player_team_meta', 'sp_player', 'side', 'high' ); @@ -64,6 +65,8 @@ function sportspress_player_details_meta( $post ) { $number = get_post_meta( $post->ID, 'sp_number', true ); $nationality = get_post_meta( $post->ID, 'sp_nationality', true ); + $teams = array_filter( get_post_meta( $post->ID, 'sp_team', false ) ); + $current_team = get_post_meta( $post->ID, 'sp_current_team', true ); ?>
@@ -87,6 +90,20 @@ function sportspress_player_details_meta( $post ) {
+ ++ +
++ +
+ '', + 'sp_icon' => ' ', 'title' => __( 'Name', 'sportspress' ), 'sp_position' => __( 'Positions', 'sportspress' ), 'sp_team' => __( 'Teams', 'sportspress' ), diff --git a/admin/post-types/team.php b/admin/post-types/team.php index 89905423..f3a9823e 100644 --- a/admin/post-types/team.php +++ b/admin/post-types/team.php @@ -26,7 +26,7 @@ function sportspress_team_meta_init( $post ) { remove_meta_box( 'submitdiv', 'sp_team', 'side' ); add_meta_box( 'submitdiv', __( 'Publish' ), 'post_submit_meta_box', 'sp_team', 'side', 'high' ); remove_meta_box( 'postimagediv', 'sp_team', 'side' ); - add_meta_box( 'postimagediv', __( 'Logo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_team', 'side', 'high' ); + add_meta_box( 'postimagediv', __( 'Logo', 'sportspress' ), 'post_thumbnail_meta_box', 'sp_team', 'side', 'low' ); if ( $leagues && $seasons ): add_meta_box( 'sp_columnssdiv', __( 'Table Columns', 'sportspress' ), 'sportspress_team_columns_meta', 'sp_team', 'normal', 'high' ); @@ -36,7 +36,7 @@ function sportspress_team_meta_init( $post ) { function sportspress_team_edit_columns() { $columns = array( 'cb' => '', - 'sp_logo' => ' ', + 'sp_icon' => ' ', 'title' => __( 'Team', 'sportspress' ), 'sp_league' => __( 'Leagues', 'sportspress' ), 'sp_season' => __( 'Seasons', 'sportspress' ), diff --git a/admin/terms/position.php b/admin/terms/position.php index 95ed8cc4..30b45c77 100644 --- a/admin/terms/position.php +++ b/admin/terms/position.php @@ -3,7 +3,7 @@ function sportspress_position_term_init() { $name = __( 'Positions', 'sportspress' ); $singular_name = __( 'Position', 'sportspress' ); $lowercase_name = __( 'position', 'sportspress' ); - $object_type = array( 'sp_player' ); + $object_type = array( 'sp_player', 'attachment' ); $labels = sportspress_get_term_labels( $name, $singular_name, $lowercase_name ); $args = array( 'label' => $name, @@ -14,5 +14,6 @@ function sportspress_position_term_init() { ); register_taxonomy( 'sp_position', $object_type, $args ); register_taxonomy_for_object_type( 'sp_position', 'sp_player' ); + register_taxonomy_for_object_type( 'sp_position', 'attachment' ); } add_action( 'init', 'sportspress_position_term_init' ); diff --git a/assets/css/admin.css b/assets/css/admin.css index d715fd19..17541075 100644 --- a/assets/css/admin.css +++ b/assets/css/admin.css @@ -22,8 +22,8 @@ table.widefat.sp-data-table input.name { .sp-admin-config-table td { width: 20%; } -table.widefat th.column-sp_logo, -table.widefat td.column-sp_logo { +table.widefat th.column-sp_icon, +table.widefat td.column-sp_icon { width: 32px; text-align: center; } @@ -41,6 +41,25 @@ table.widefat td.column-sp_logo { height: 320px; } +#adminmenu #menu-posts-sp_event .wp-menu-name:after, +#adminmenu #menu-posts-sp_team .wp-menu-name:after, +#adminmenu #menu-posts-sp_staff .wp-menu-name:after { + content: ' \03b2'; + display: inline-block; + margin: 1px 0 0 6px; + vertical-align: top; + -webkit-border-radius: 10px; + border-radius: 10px; + z-index: 26; + background-color: #0074a2; + color: #fff; + width: 17px; + text-align: center; + font-size: 12px; + font-weight: normal; + line-height: 17px; +} + @media only screen and (max-width: 768px) { .form-field .sp-location-picker { diff --git a/assets/css/sportspress.css b/assets/css/sportspress.css index 7efdd4f4..dbd0988c 100644 --- a/assets/css/sportspress.css +++ b/assets/css/sportspress.css @@ -34,7 +34,7 @@ } .sp-data-table .data-name .logo { vertical-align: middle; - height: 2em; + height: 2.5em; width: auto; } diff --git a/functions.php b/functions.php index 6bde7963..9b87afa8 100644 --- a/functions.php +++ b/functions.php @@ -1,6 +1,11 @@ ID; + endif; $date = get_the_time( get_option('date_format'), $id ); $time = get_the_time( get_option('time_format'), $id ); @@ -41,7 +46,12 @@ if ( !function_exists( 'sportspress_event_details' ) ) { } if ( !function_exists( 'sportspress_event_results' ) ) { - function sportspress_event_results( $id ) { + function sportspress_event_results( $id = null ) { + + if ( ! $id ): + global $post; + $id = $post->ID; + endif; $teams = (array)get_post_meta( $id, 'sp_team', false ); $results = sportspress_array_combine( $teams, (array)get_post_meta( $id, 'sp_results', true ) ); @@ -102,7 +112,12 @@ if ( !function_exists( 'sportspress_event_results' ) ) { } if ( !function_exists( 'sportspress_event_players' ) ) { - function sportspress_event_players( $id ) { + function sportspress_event_players( $id = null ) { + + if ( ! $id ): + global $post; + $id = $post->ID; + endif; $teams = (array)get_post_meta( $id, 'sp_team', false ); $staff = (array)get_post_meta( $id, 'sp_staff', false ); @@ -203,7 +218,12 @@ if ( !function_exists( 'sportspress_event_players' ) ) { if ( !function_exists( 'sportspress_event_staff' ) ) { - function sportspress_event_staff( $id ) { + function sportspress_event_staff( $id = null ) { + + if ( ! $id ): + global $post; + $id = $post->ID; + endif; $staff = (array)get_post_meta( $id, 'sp_staff', false ); @@ -245,7 +265,20 @@ if ( !function_exists( 'sportspress_event_venue' ) ) { } if ( !function_exists( 'sportspress_league_table' ) ) { - function sportspress_league_table( $id ) { + function sportspress_league_table( $id = null, $args = '' ) { + + if ( ! $id ): + global $post; + $id = $post->ID; + endif; + + $defaults = array( + 'number_label' => __( 'Pos', 'sportspress' ), + 'thumbnails' => 1, + 'thumbnail_size' => 'thumbnail' + ); + + $r = wp_parse_args( $args, $defaults ); $data = sportspress_get_league_table_data( $id ); @@ -257,7 +290,7 @@ if ( !function_exists( 'sportspress_league_table' ) ) { // Remove the first row to leave us with the actual data unset( $data[0] ); - $output .= '| ' . $label . ' | '; + endforeach; + + $output .= '
|---|
| ' . sportspress_array_value( $row, $key, '—' ) . ' | '; + endforeach; + + $output .= '
| ' . $label . ' | '; - endforeach; - - $output .= '
|---|
| ' . sportspress_array_value( $row, $key, '—' ) . ' | '; - endforeach; - - $output .= '