Display venue map, fix table and sports sorting, support player excerpts
This commit is contained in:
@@ -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' );
|
||||
|
||||
@@ -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;
|
||||
|
||||
21
admin/hooks/loop-start.php
Normal file
21
admin/hooks/loop-start.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
function sportspress_default_venue_content( $query ) {
|
||||
if ( ! is_tax( 'sp_venue' ) )
|
||||
return;
|
||||
|
||||
$slug = sportspress_array_value( $query->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 '<div class="sp-google-map" data-address="' . $address . '" data-latitude="' . $latitude . '" data-longitude="' . $longitude . '"></div>';
|
||||
}
|
||||
add_action( 'loop_start', 'sportspress_default_venue_content' );
|
||||
@@ -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 '<div class="sp-google-map" data-address="' . $address . '" data-latitude="' . $latitude . '" data-longitude="' . $longitude . '"></div>';
|
||||
*/
|
||||
@@ -1,13 +1,4 @@
|
||||
<?php
|
||||
function sportspress_the_posts( $posts ) {
|
||||
global $wp_query, $wpdb;
|
||||
if( is_single() && $wp_query->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() )
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
if ( !function_exists( 'sportspress_event_venue' ) ) {
|
||||
function sportspress_event_venue( $id ) {
|
||||
function sportspress_event_venue( $id = null ) {
|
||||
|
||||
if ( ! $id )
|
||||
$id = get_the_ID();
|
||||
@@ -21,8 +21,10 @@ if ( !function_exists( 'sportspress_event_venue' ) ) {
|
||||
$latitude = sportspress_array_value( $term_meta, 'sp_latitude', 0 );
|
||||
$longitude = sportspress_array_value( $term_meta, 'sp_longitude', 0 );
|
||||
|
||||
$output .= '<h3>' . $venue->name . '</h3>';
|
||||
$output .= '<div class="sp-google-map" data-address="' . $address . '" data-latitude="' . $latitude . '" data-longitude="' . $longitude . '"></div>';
|
||||
$output .= '<h3>' . __( 'Venue', 'sportspress' ) . '</h3>';
|
||||
$output .= '<p>' . $venue->name . '<br><small>' . $address . '</small></p>';
|
||||
if ( $latitude != null && $longitude != null )
|
||||
$output .= '<div class="sp-google-map" data-address="' . $address . '" data-latitude="' . $latitude . '" data-longitude="' . $longitude . '"></div>';
|
||||
|
||||
endforeach;
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
/* Google Maps */
|
||||
.sp-google-map {
|
||||
height: 320px;
|
||||
margin-bottom: 32px;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 40em) {
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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' ) ) {
|
||||
|
||||
11
readme.txt
11
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.
|
||||
|
||||
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user