From c54bbade6db964b2293b59b375cab3ccf31bb15c Mon Sep 17 00:00:00 2001 From: Brian Miyaji Date: Sat, 8 Feb 2014 13:17:48 +1100 Subject: [PATCH] Display venue map, fix table and sports sorting, support player excerpts --- admin/globals/sports.php | 2 +- admin/hooks/gettext.php | 9 +++++++- admin/hooks/loop-start.php | 21 ++++++++++++++++++ admin/hooks/the-content.php | 18 ++++++++++++++- admin/hooks/the-posts.php | 9 -------- admin/post-types/player.php | 2 +- admin/templates/event-venue.php | 8 ++++--- assets/css/sportspress.css | 1 + assets/js/sportspress.js | 1 + functions.php | 39 ++++++++++++++++++++------------- readme.txt | 11 +++++++++- sportspress.php | 5 +++-- 12 files changed, 92 insertions(+), 34 deletions(-) create mode 100644 admin/hooks/loop-start.php diff --git a/admin/globals/sports.php b/admin/globals/sports.php index be0d1baa..e6de465d 100644 --- a/admin/globals/sports.php +++ b/admin/globals/sports.php @@ -18,6 +18,6 @@ function sportspress_define_sports_global() { include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/presets/tennis.php'; include_once dirname( SPORTSPRESS_PLUGIN_FILE ) . '/admin/presets/volleyball.php'; - asort( $sportspress_sports ); + uasort( $sportspress_sports, 'sportspress_sort_sports' ); } add_action( 'init', 'sportspress_define_sports_global' ); diff --git a/admin/hooks/gettext.php b/admin/hooks/gettext.php index dc946aa6..2263f5e5 100644 --- a/admin/hooks/gettext.php +++ b/admin/hooks/gettext.php @@ -3,7 +3,6 @@ function sportspress_gettext( $translated_text, $untranslated_text, $domain ) { global $typenow; if ( is_admin() ): - if ( 'sp_team' == $typenow ): switch ( $untranslated_text ): case 'Enter title here': @@ -44,6 +43,14 @@ function sportspress_gettext( $translated_text, $untranslated_text, $domain ) { break; endswitch; endif; + else: + if ( $untranslated_text == 'Archives' && is_tax( 'sp_venue' ) ): + $slug = get_query_var( 'sp_venue' ); + if ( $slug ): + $venue = get_term_by( 'slug', $slug, 'sp_venue' ); + $translated_text = $venue->name; + endif; + endif; endif; return $translated_text; diff --git a/admin/hooks/loop-start.php b/admin/hooks/loop-start.php new file mode 100644 index 00000000..86c3b131 --- /dev/null +++ b/admin/hooks/loop-start.php @@ -0,0 +1,21 @@ +query, 'sp_venue', null ); + + if ( ! $slug ) + return; + + $venue = get_term_by( 'slug', $slug, 'sp_venue' ); + $t_id = $venue->term_id; + $venue_meta = get_option( "taxonomy_$t_id" ); + $address = sportspress_array_value( $venue_meta, 'sp_address', null ); + $latitude = sportspress_array_value( $venue_meta, 'sp_latitude', null ); + $longitude = sportspress_array_value( $venue_meta, 'sp_longitude', null ); + + if ( $latitude != null && $longitude != null ) + echo '
'; +} +add_action( 'loop_start', 'sportspress_default_venue_content' ); diff --git a/admin/hooks/the-content.php b/admin/hooks/the-content.php index ee4adbcb..abc42dc0 100644 --- a/admin/hooks/the-content.php +++ b/admin/hooks/the-content.php @@ -13,7 +13,7 @@ function sportspress_default_event_content( $content ) { $results = sportspress_event_results(); $players = sportspress_event_players(); $staff = sportspress_event_staff(); - if ( ! empty( $results ) ) + if ( is_array( $results ) && array_filter( $results, 'array_filter' ) ) return $results . $details . $players . $staff . $content; $venue = sportspress_event_venue(); $content = $details . $venue . $players . $staff . $content; @@ -59,3 +59,19 @@ function sportspress_default_list_content( $content ) { return $content; } add_filter( 'the_content', 'sportspress_default_list_content' ); + + +/* + if ( ! $slug ) + return; + + $venue = get_term_by( 'slug', $slug, 'sp_venue' ); + $t_id = $venue->term_id; + $venue_meta = get_option( "taxonomy_$t_id" ); + $address = sportspress_array_value( $venue_meta, 'sp_address', null ); + $latitude = sportspress_array_value( $venue_meta, 'sp_latitude', null ); + $longitude = sportspress_array_value( $venue_meta, 'sp_longitude', null ); + + if ( $latitude != null && $longitude != null ) + echo '
'; + */ \ No newline at end of file diff --git a/admin/hooks/the-posts.php b/admin/hooks/the-posts.php index 46d21110..0924ebd1 100644 --- a/admin/hooks/the-posts.php +++ b/admin/hooks/the-posts.php @@ -1,13 +1,4 @@ post_count == 0 && isset( $wp_query->query_vars['sp_event'] ) ) { - $posts = $wpdb->get_results( $wp_query->request ); - } - return $posts; -} -//add_filter( 'the_posts', 'sportspress_the_posts' ); - function sportspress_posts_where( $where, $that ) { global $wpdb; if( 'sp_event' == $that->query_vars['post_type'] && is_archive() ) diff --git a/admin/post-types/player.php b/admin/post-types/player.php index 3c60bb53..1f22902a 100644 --- a/admin/post-types/player.php +++ b/admin/post-types/player.php @@ -10,7 +10,7 @@ function sportspress_player_post_init() { 'public' => true, 'has_archive' => false, 'hierarchical' => false, - 'supports' => array( 'title', 'author', 'thumbnail', 'page-attributes' ), + 'supports' => array( 'title', 'author', 'thumbnail', 'excerpt', 'page-attributes' ), 'register_meta_box_cb' => 'sportspress_player_meta_init', 'rewrite' => array( 'slug' => get_option( 'sp_player_slug', 'players' ) ), 'menu_icon' => 'dashicons-groups', diff --git a/admin/templates/event-venue.php b/admin/templates/event-venue.php index 9a132673..55adc85c 100644 --- a/admin/templates/event-venue.php +++ b/admin/templates/event-venue.php @@ -1,6 +1,6 @@ ' . $venue->name . ''; - $output .= '
'; + $output .= '

' . __( 'Venue', 'sportspress' ) . '

'; + $output .= '

' . $venue->name . '
' . $address . '

'; + if ( $latitude != null && $longitude != null ) + $output .= '
'; endforeach; diff --git a/assets/css/sportspress.css b/assets/css/sportspress.css index adc4f341..efc70ba5 100644 --- a/assets/css/sportspress.css +++ b/assets/css/sportspress.css @@ -35,6 +35,7 @@ /* Google Maps */ .sp-google-map { height: 320px; + margin-bottom: 32px; } @media only screen and (max-width: 40em) { diff --git a/assets/js/sportspress.js b/assets/js/sportspress.js index 80f0b546..1e6eba48 100644 --- a/assets/js/sportspress.js +++ b/assets/js/sportspress.js @@ -145,6 +145,7 @@ function viewport() { longitude = $self.attr('data-longitude'); var ll = new google.maps.LatLng(latitude,longitude); var mapOptions = { + scrollwheel: false, zoom: 16, center: ll }; diff --git a/functions.php b/functions.php index 6a34a4a4..dc332057 100644 --- a/functions.php +++ b/functions.php @@ -1766,30 +1766,39 @@ if ( !function_exists( 'sportspress_get_league_table_data' ) ) { } } -function sportspress_sort_table_teams ( $a, $b ) { +if ( !function_exists( 'sportspress_sort_sports' ) ) { + function sportspress_sort_sports ( $a, $b ) { - global $sportspress_column_priorities; + return strcmp( sportspress_array_value( $a, 'name', '' ), sportspress_array_value( $b, 'name', '' ) ); + } +} - // Loop through priorities - foreach( $sportspress_column_priorities as $priority ): +if ( !function_exists( 'sportspress_sort_table_teams' ) ) { + function sportspress_sort_table_teams ( $a, $b ) { - // Proceed if columns are not equal - if ( sportspress_array_value( $a, $priority['column'], 0 ) != sportspress_array_value( $b, $priority['column'], 0 ) ): + global $sportspress_column_priorities; - // Compare column values - $output = sportspress_array_value( $a, $priority['column'], 0 ) - sportspress_array_value( $b, $priority['column'], 0 ); + // Loop through priorities + foreach( $sportspress_column_priorities as $priority ): - // Flip value if descending order - if ( $priority['order'] == 'DESC' ) $output = 0 - $output; + // Proceed if columns are not equal + if ( sportspress_array_value( $a, $priority['column'], 0 ) != sportspress_array_value( $b, $priority['column'], 0 ) ): - return $output; + // Compare column values + $output = sportspress_array_value( $a, $priority['column'], 0 ) - sportspress_array_value( $b, $priority['column'], 0 ); - endif; + // Flip value if descending order + if ( $priority['order'] == 'DESC' ) $output = 0 - $output; - endforeach; + return $output; - // Default sort by alphabetical - return strcmp( sportspress_array_value( $a, 'name', '' ), sportspress_array_value( $b, 'name', '' ) ); + endif; + + endforeach; + + // Default sort by alphabetical + return strcmp( sportspress_array_value( $a, 'name', '' ), sportspress_array_value( $b, 'name', '' ) ); + } } if ( !function_exists( 'sportspress_get_player_list_data' ) ) { diff --git a/readme.txt b/readme.txt index 7f1458a4..d7d03713 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: sports, sports journalism, teams, team management, fixtures, results, stan Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=support@themeboy.com&item_name=Donation+for+SportsPress Requires at least: 3.5 Tested up to: 3.8 -Stable tag: 0.2.2 +Stable tag: 0.2.4 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -72,6 +72,15 @@ SportsPress is currently in beta and is undergoing testing. We are still activel == Changelog == += 0.2.4 = +* Feature - Display venue map on event page and venue archive. + += 0.2.3 = +* Feature - Enable selecting main event result. +* Feature - Add Last 5 counter to table columns. +* Localization - Update Japanese translations. +* Preset - Complete American Football preset. + = 0.2.2 = * Feature - League Table widget added. * Feature - Recent Events widget added. diff --git a/sportspress.php b/sportspress.php index 651f7f94..d03812ae 100644 --- a/sportspress.php +++ b/sportspress.php @@ -6,7 +6,7 @@ Plugin Name: SportsPress Plugin URI: http://themeboy.com/sportspress Description: Manage your club and its players, staff, events, league tables, and player lists. -Version: 0.2.2 +Version: 0.2.4 Author: ThemeBoy Author URI: http://themeboy.com/ License: GPLv3 @@ -18,7 +18,7 @@ if ( !function_exists( 'add_action' ) ) { exit; } -define( 'SPORTSPRESS_VERSION', '0.2.2' ); +define( 'SPORTSPRESS_VERSION', '0.2.4' ); define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) ); define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); define( 'SPORTSPRESS_PLUGIN_FILE', __FILE__ ); @@ -84,6 +84,7 @@ require_once dirname( __FILE__ ) . '/admin/widgets/league-table.php'; require_once dirname( __FILE__ ) . '/admin/hooks/plugins-loaded.php'; require_once dirname( __FILE__ ) . '/admin/hooks/after-setup-theme.php'; require_once dirname( __FILE__ ) . '/admin/hooks/wp-enqueue-scripts.php'; +require_once dirname( __FILE__ ) . '/admin/hooks/loop-start.php'; // Admin request actions require_once dirname( __FILE__ ) . '/admin/hooks/admin-init.php';