diff --git a/admin-functions.php b/admin-functions.php
index 69aa86ff..3ab0f16d 100644
--- a/admin-functions.php
+++ b/admin-functions.php
@@ -526,10 +526,10 @@ if ( !function_exists( 'sportspress_edit_calendar_table' ) ) {
post_title; ?>
- post_date ); ?>
+ ID ); ?>
|
- post_date ); ?>
+ ID ); ?>
|
+ | # |
|
|
@@ -856,9 +857,8 @@ if ( !function_exists( 'sportspress_event_players_table' ) ) {
$number = get_post_meta( $player_id, 'sp_number', true );
?>
- |
-
- |
+ |
+ |
$label ):
$value = sportspress_array_value( $player_statistics, $column, '' );
?>
diff --git a/admin/hooks/the-content.php b/admin/hooks/the-content.php
index b12e45f0..5153868a 100644
--- a/admin/hooks/the-content.php
+++ b/admin/hooks/the-content.php
@@ -5,44 +5,59 @@ function sportspress_the_content( $content ) {
global $post;
- // Display event details
- $content = sportspress_event_details( $post->ID ) . $content;
+ $details = sportspress_event_details( $post->ID );
+ $results = sportspress_event_results( $post->ID );
+ $players = sportspress_event_players( $post->ID );
+ $staff = sportspress_event_staff( $post->ID );
+
+ if ( ! empty( $results ) ):
+ $content = $results . $details . $players . $staff . $content;
+ else:
+ $venue = sportspress_event_venue( $post->ID );
+ $content = $details . $venue . $players . $staff . $content;
+ endif;
elseif ( is_singular( 'sp_calendar' ) && in_the_loop() ):
global $post;
- // Display events calendar
- $content = sportspress_events_calendar( $post->ID ) . $content;
+ $calendar = sportspress_events_calendar( $post->ID );
+
+ $content = $calendar . $content;
elseif ( is_singular( 'sp_team' ) && in_the_loop() ):
global $post;
- // Display team columns
- $content = sportspress_team_columns( $post->ID ) . $content;
+ $columns = sportspress_team_columns( $post->ID );
+
+ $content = $columns . $content;
elseif ( is_singular( 'sp_table' ) && in_the_loop() ):
global $post;
- // Display league table
- $content = sportspress_league_table( $post->ID ) . $content;
+ sportspress_league_table( $post->ID );
+
+ $content = $table . $content;
elseif ( is_singular( 'sp_list' ) && in_the_loop() ):
global $post;
- // Display player list
- $content = sportspress_player_list( $post->ID ) . $content;
+ $list = sportspress_player_list( $post->ID );
+
+ $content = $list . $content;
elseif ( is_singular( 'sp_player' ) && in_the_loop() ):
global $post;
- // Display player metrics and statistics
- $content = sportspress_player_metrics( $post->ID ) . sportspress_player_statistics( $post->ID ) . $content;
+ $metrics = sportspress_player_metrics( $post->ID );
+ $statistics = sportspress_player_statistics( $post->ID );
+
+ $content = $metrics . $statistics . $content;
endif;
diff --git a/admin/hooks/wp-enqueue-scripts.php b/admin/hooks/wp-enqueue-scripts.php
index 5f47d39b..d1931ad7 100644
--- a/admin/hooks/wp-enqueue-scripts.php
+++ b/admin/hooks/wp-enqueue-scripts.php
@@ -6,6 +6,7 @@ function sportspress_enqueue_scripts() {
// Scripts
wp_enqueue_script( 'jquery' );
+ wp_enqueue_script( 'google-maps', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false', array(), '3.exp', true );
wp_enqueue_script( 'jquery-datatables', SPORTSPRESS_PLUGIN_URL .'/assets/js/jquery.dataTables.min.js', array( 'jquery' ), '1.9.4', true );
wp_enqueue_script( 'sportspress', SPORTSPRESS_PLUGIN_URL .'/assets/js/sportspress.js', array( 'jquery' ), time(), true );
}
diff --git a/admin/post-types/event.php b/admin/post-types/event.php
index 58cd7397..94660f7f 100644
--- a/admin/post-types/event.php
+++ b/admin/post-types/event.php
@@ -38,8 +38,8 @@ function sportspress_event_meta_init( $post ) {
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'sportspress_event_details_meta', 'sp_event', 'side', 'high' );
add_meta_box( 'sp_teamdiv', __( 'Teams', 'sportspress' ), 'sportspress_event_team_meta', 'sp_event', 'side', 'high' );
if ( sizeof( $teams ) > 0 ):
- add_meta_box( 'sp_playersdiv', __( 'Players', 'sportspress' ), 'sportspress_event_players_meta', 'sp_event', 'normal', 'high' );
add_meta_box( 'sp_resultsdiv', __( 'Results', 'sportspress' ), 'sportspress_event_results_meta', 'sp_event', 'normal', 'high' );
+ add_meta_box( 'sp_playersdiv', __( 'Players', 'sportspress' ), 'sportspress_event_players_meta', 'sp_event', 'normal', 'high' );
endif;
add_meta_box( 'sp_articlediv', __( 'Article', 'sportspress' ), 'sportspress_event_article_meta', 'sp_event', 'normal', 'high' );
}
@@ -157,7 +157,7 @@ function sportspress_event_players_meta( $post ) {
?>
<' + '/script>');
+ }
+
+ var modules = google.maps.modules = {};
+ google.maps.__gjsload__ = function(name, text) {
+ modules[name] = text;
+ };
+
+ google.maps.Load = function(apiLoad) {
+ delete google.maps.Load;
+ apiLoad([0.009999999776482582,[[["https://mts0.googleapis.com/vt?lyrs=m@248000000\u0026src=api\u0026hl=en-US\u0026","https://mts1.googleapis.com/vt?lyrs=m@248000000\u0026src=api\u0026hl=en-US\u0026"],null,null,null,null,"m@248000000",["https://mts0.google.com/vt?lyrs=m@248000000\u0026src=api\u0026hl=en-US\u0026","https://mts1.google.com/vt?lyrs=m@248000000\u0026src=api\u0026hl=en-US\u0026"]],[["https://khms0.googleapis.com/kh?v=144\u0026hl=en-US\u0026","https://khms1.googleapis.com/kh?v=144\u0026hl=en-US\u0026"],null,null,null,1,"144",["https://khms0.google.com/kh?v=144\u0026hl=en-US\u0026","https://khms1.google.com/kh?v=144\u0026hl=en-US\u0026"]],[["https://mts0.googleapis.com/vt?lyrs=h@248000000\u0026src=api\u0026hl=en-US\u0026","https://mts1.googleapis.com/vt?lyrs=h@248000000\u0026src=api\u0026hl=en-US\u0026"],null,null,null,null,"h@248000000",["https://mts0.google.com/vt?lyrs=h@248000000\u0026src=api\u0026hl=en-US\u0026","https://mts1.google.com/vt?lyrs=h@248000000\u0026src=api\u0026hl=en-US\u0026"]],[["https://mts0.googleapis.com/vt?lyrs=t@132,r@248000000\u0026src=api\u0026hl=en-US\u0026","https://mts1.googleapis.com/vt?lyrs=t@132,r@248000000\u0026src=api\u0026hl=en-US\u0026"],null,null,null,null,"t@132,r@248000000",["https://mts0.google.com/vt?lyrs=t@132,r@248000000\u0026src=api\u0026hl=en-US\u0026","https://mts1.google.com/vt?lyrs=t@132,r@248000000\u0026src=api\u0026hl=en-US\u0026"]],null,null,[["https://cbks0.googleapis.com/cbk?","https://cbks1.googleapis.com/cbk?"]],[["https://khms0.googleapis.com/kh?v=83\u0026hl=en-US\u0026","https://khms1.googleapis.com/kh?v=83\u0026hl=en-US\u0026"],null,null,null,null,"83",["https://khms0.google.com/kh?v=83\u0026hl=en-US\u0026","https://khms1.google.com/kh?v=83\u0026hl=en-US\u0026"]],[["https://mts0.googleapis.com/mapslt?hl=en-US\u0026","https://mts1.googleapis.com/mapslt?hl=en-US\u0026"]],[["https://mts0.googleapis.com/mapslt/ft?hl=en-US\u0026","https://mts1.googleapis.com/mapslt/ft?hl=en-US\u0026"]],[["https://mts0.googleapis.com/vt?hl=en-US\u0026","https://mts1.googleapis.com/vt?hl=en-US\u0026"]],[["https://mts0.googleapis.com/mapslt/loom?hl=en-US\u0026","https://mts1.googleapis.com/mapslt/loom?hl=en-US\u0026"]],[["https://mts0.googleapis.com/mapslt?hl=en-US\u0026","https://mts1.googleapis.com/mapslt?hl=en-US\u0026"]],[["https://mts0.googleapis.com/mapslt/ft?hl=en-US\u0026","https://mts1.googleapis.com/mapslt/ft?hl=en-US\u0026"]]],["en-US","US",null,0,null,null,"https://maps.gstatic.com/mapfiles/","https://csi.gstatic.com","https://maps.googleapis.com","https://maps.googleapis.com"],["https://maps.gstatic.com/intl/en_us/mapfiles/api-3/15/6","3.15.6"],[2178329814],1,null,null,null,null,0,"",null,null,1,"https://khms.googleapis.com/mz?v=144\u0026",null,"https://earthbuilder.googleapis.com","https://earthbuilder.googleapis.com",null,"https://mts.googleapis.com/vt/icon",[["https://mts0.googleapis.com/vt","https://mts1.googleapis.com/vt"],["https://mts0.googleapis.com/vt","https://mts1.googleapis.com/vt"],[null,[[0,"m",248000000]],[null,"en-US","US",null,18,null,null,null,null,null,null,[[47],[37,[["smartmaps"]]]]],0],[null,[[0,"m",248000000]],[null,"en-US","US",null,18,null,null,null,null,null,null,[[47],[37,[["smartmaps"]]]]],3],[null,[[0,"m",248000000]],[null,"en-US","US",null,18,null,null,null,null,null,null,[[50],[37,[["smartmaps"]]]]],0],[null,[[0,"m",248000000]],[null,"en-US","US",null,18,null,null,null,null,null,null,[[50],[37,[["smartmaps"]]]]],3],[null,[[4,"t",132],[0,"r",132000000]],[null,"en-US","US",null,18,null,null,null,null,null,null,[[5],[37,[["smartmaps"]]]]],0],[null,[[4,"t",132],[0,"r",132000000]],[null,"en-US","US",null,18,null,null,null,null,null,null,[[5],[37,[["smartmaps"]]]]],3],[null,null,[null,"en-US","US",null,18],0],[null,null,[null,"en-US","US",null,18],3],[null,null,[null,"en-US","US",null,18],6],[null,null,[null,"en-US","US",null,18],0],["https://mts0.google.com/vt","https://mts1.google.com/vt"],"/maps/vt"],2,500], loadScriptTime);
+ };
+ var loadScriptTime = (new Date).getTime();
+ getScript("https://maps.gstatic.com/intl/en_us/mapfiles/api-3/15/6/main.js");
+})();
diff --git a/assets/js/sportspress.js b/assets/js/sportspress.js
index 6e0e08f3..a9758731 100644
--- a/assets/js/sportspress.js
+++ b/assets/js/sportspress.js
@@ -54,4 +54,29 @@
}
});
+ // Google Maps
+ function initialize_google_maps() {
+ $maps = $('.sp-google-map');
+ $maps.each(function() {
+ $self = $(this);
+ address = $self.attr('data-address');
+ latitude = $self.attr('data-latitude');
+ longitude = $self.attr('data-longitude');
+ var ll = new google.maps.LatLng(latitude,longitude);
+ var mapOptions = {
+ zoom: 16,
+ center: ll
+ };
+ var map = new google.maps.Map($self[0], mapOptions)
+ var marker = new google.maps.Marker({
+ position: ll,
+ map: map,
+ animation: google.maps.Animation.DROP,
+ flat: true,
+ title: address
+ });
+ });
+ }
+ google.maps.event.addDomListener(window, "load", initialize_google_maps);
+
})(jQuery);
\ No newline at end of file
diff --git a/functions.php b/functions.php
index 631f2d9c..424c3a4c 100644
--- a/functions.php
+++ b/functions.php
@@ -2,100 +2,53 @@
if ( !function_exists( 'sportspress_event_details' ) ) {
function sportspress_event_details( $id ) {
+ $date = get_the_time( get_option('date_format'), $id );
+ $time = get_the_time( get_option('time_format'), $id );
+ $leagues = get_the_terms( $id, 'sp_league' );
+ $seasons = get_the_terms( $id, 'sp_season' );
+
+ $data = array( __( 'Date', 'sportspress' ) => $date, __( 'Time', 'sportspress' ) => $time );
+
+ if ( $leagues )
+ $data[ __( 'League', 'sportspress' ) ] = sportspress_array_value( $leagues, 0, '—' )->name;
+
+ if ( $seasons )
+ $data[ __( 'Season', 'sportspress' ) ] = sportspress_array_value( $seasons, 0, '—' )->name;
+
+
+ $output = '' . __( 'Details', 'sportspress' ) . '
';
+
+ $output .= '';
+
+ $i = 0;
+
+ foreach( $data as $label => $value ):
+
+ $output .= '';
+ $output .= '| ' . $label . ' | ';
+ $output .= '' . $value . ' | ';
+ $output .= '
';
+
+ $i++;
+
+ endforeach;
+
+ $output .= '
';
+
+ return $output;
+
+ }
+}
+
+if ( !function_exists( 'sportspress_event_results' ) ) {
+ function sportspress_event_results( $id ) {
+
$teams = (array)get_post_meta( $id, 'sp_team', false );
- $staff = (array)get_post_meta( $id, 'sp_staff', false );
- $stats = (array)get_post_meta( $id, 'sp_players', true );
$results = sportspress_array_combine( $teams, (array)get_post_meta( $id, 'sp_results', true ) );
- $statistic_labels = sportspress_get_var_labels( 'sp_statistic' );
$result_labels = sportspress_get_var_labels( 'sp_result' );
$output = '';
- foreach( $teams as $key => $team_id ):
- if ( ! $team_id ) continue;
-
- // Get results for players in the team
- $players = sportspress_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $key );
- $data = sportspress_array_combine( $players, sportspress_array_value( $stats, $team_id, array() ) );
-
- $output .= '' . get_the_title( $team_id ) . '
';
-
- $output .= '' . '' . '';
-
- $output .= '| ' . __( '#', 'sportspress' ) . ' | ';
- $output .= '' . __( 'Player', 'sportspress' ) . ' | ';
-
- foreach( $statistic_labels as $key => $label ):
- $output .= '' . $label . ' | ';
- endforeach;
-
- $output .= '
' . '' . '';
-
- $i = 0;
-
- foreach( $data as $player_id => $row ):
-
- if ( ! $player_id )
- continue;
-
- $output .= '';
-
- $number = get_post_meta( $player_id, 'sp_number', true );
-
- // Player number
- $output .= '| ' . $number . ' | ';
-
- // Name as link
- $permalink = get_post_permalink( $player_id );
- $name = get_the_title( $player_id );
- $output .= '' . '' . $name . ' | ';
-
- foreach( $statistic_labels as $key => $label ):
- if ( $key == 'name' )
- continue;
- if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
- $value = $row[ $key ];
- else:
- $value = 0;
- endif;
- $output .= '' . $value . ' | ';
- endforeach;
-
- $output .= '
';
-
- $i++;
-
- endforeach;
-
- $output .= '';
-
- if ( array_key_exists( 0, $data ) ):
-
- $output .= '';
-
- $number = get_post_meta( $player_id, 'sp_number', true );
-
- // Player number
- $output .= '| | ';
- $output .= '' . __( 'Total', 'sportspress' ) . ' | ';
-
- $row = $data[0];
-
- foreach( $statistic_labels as $key => $label ):
- if ( $key == 'name' ):
- continue;
- endif;
- $output .= '' . sportspress_array_value( $row, $key, '—' ) . ' | ';
- endforeach;
-
- $output .= '
';
-
- endif;
-
- $output .= '
';
-
- endforeach;
-
// Initialize and check
$table_rows = '';
@@ -148,6 +101,149 @@ if ( !function_exists( 'sportspress_event_details' ) ) {
}
}
+if ( !function_exists( 'sportspress_event_players' ) ) {
+ function sportspress_event_players( $id ) {
+
+ $teams = (array)get_post_meta( $id, 'sp_team', false );
+ $staff = (array)get_post_meta( $id, 'sp_staff', false );
+ $stats = (array)get_post_meta( $id, 'sp_players', true );
+ $statistic_labels = sportspress_get_var_labels( 'sp_statistic' );
+
+ $output = '';
+
+ foreach( $teams as $key => $team_id ):
+ if ( ! $team_id ) continue;
+
+ // Get results for players in the team
+ $players = sportspress_array_between( (array)get_post_meta( $id, 'sp_player', false ), 0, $key );
+ $data = sportspress_array_combine( $players, sportspress_array_value( $stats, $team_id, array() ) );
+
+ $output .= '' . get_the_title( $team_id ) . '
';
+
+ $output .= '' . '' . '';
+
+ $output .= '| # | ';
+ $output .= '' . __( 'Player', 'sportspress' ) . ' | ';
+
+ foreach( $statistic_labels as $key => $label ):
+ $output .= '' . $label . ' | ';
+ endforeach;
+
+ $output .= '
' . '' . '';
+
+ $i = 0;
+
+ foreach( $data as $player_id => $row ):
+
+ if ( ! $player_id )
+ continue;
+
+ $output .= '';
+
+ $number = get_post_meta( $player_id, 'sp_number', true );
+
+ // Player number
+ $output .= '| ' . $number . ' | ';
+
+ // Name as link
+ $permalink = get_post_permalink( $player_id );
+ $name = get_the_title( $player_id );
+ $output .= '' . '' . $name . ' | ';
+
+ foreach( $statistic_labels as $key => $label ):
+ if ( $key == 'name' )
+ continue;
+ if ( array_key_exists( $key, $row ) && $row[ $key ] != '' ):
+ $value = $row[ $key ];
+ else:
+ $value = 0;
+ endif;
+ $output .= '' . $value . ' | ';
+ endforeach;
+
+ $output .= '
';
+
+ $i++;
+
+ endforeach;
+
+ $output .= '';
+
+ if ( array_key_exists( 0, $data ) ):
+
+ $output .= '';
+
+ $number = get_post_meta( $player_id, 'sp_number', true );
+
+ // Player number
+ $output .= '| | ';
+ $output .= '' . __( 'Total', 'sportspress' ) . ' | ';
+
+ $row = $data[0];
+
+ foreach( $statistic_labels as $key => $label ):
+ if ( $key == 'name' ):
+ continue;
+ endif;
+ $output .= '' . sportspress_array_value( $row, $key, '—' ) . ' | ';
+ endforeach;
+
+ $output .= '
';
+
+ endif;
+
+ $output .= '
';
+
+ endforeach;
+
+ return $output;
+
+ }
+}
+
+
+if ( !function_exists( 'sportspress_event_staff' ) ) {
+ function sportspress_event_staff( $id ) {
+
+ $staff = (array)get_post_meta( $id, 'sp_staff', false );
+
+ $output = '';
+
+ return $output;
+
+ }
+}
+
+
+if ( !function_exists( 'sportspress_event_venue' ) ) {
+ function sportspress_event_venue( $id ) {
+
+ $venues = get_the_terms( $id, 'sp_venue' );
+
+ $output = '';
+
+ if ( ! $venues )
+ return $output;
+
+ foreach( $venues as $venue ):
+
+ $t_id = $venue->term_id;
+ $term_meta = get_option( "taxonomy_$t_id" );
+
+ $address = sportspress_array_value( $term_meta, 'sp_address', '' );
+ $latitude = sportspress_array_value( $term_meta, 'sp_latitude', 0 );
+ $longitude = sportspress_array_value( $term_meta, 'sp_longitude', 0 );
+
+ $output .= '' . $venue->name . '
';
+ $output .= '';
+
+ endforeach;
+
+ return $output;
+
+ }
+}
+
if ( !function_exists( 'sportspress_league_table' ) ) {
function sportspress_league_table( $id ) {
@@ -161,7 +257,7 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
// Remove the first row to leave us with the actual data
unset( $data[0] );
- $output .= '' . __( '#', 'sportspress' ) . ' | ';
+ $output .= '# | ';
foreach( $labels as $key => $label ):
$output .= '' . $label . ' | ';
endforeach;
@@ -274,7 +370,7 @@ if ( !function_exists( 'sportspress_player_list' ) ) {
// Remove the first row to leave us with the actual data
unset( $data[0] );
- $output .= '' . __( '#', 'sportspress' ) . ' | ';
+ $output .= '# | ';
foreach( $labels as $key => $label ):
$output .= '' . $label . ' | ';
endforeach;