Add views counter and style tweaks

This commit is contained in:
Brian Miyaji
2014-01-22 17:33:25 +11:00
parent 86b06e3ec6
commit bb15a05338
18 changed files with 190 additions and 93 deletions

View File

@@ -17,8 +17,9 @@ function sportspress_admin_menu( $position ) {
$menu[ $position ] = array( '', 'read', 'separator-sportspress', '', 'wp-menu-separator sportspress' );
endif;
// Remove "Positions" link from Media submenu
// Remove "Venues" and "Positions" link from Media submenu
unset( $submenu['upload.php'][17] );
unset( $submenu['upload.php'][18] );
// Remove "Leagues" link from Players submenu
unset( $submenu['edit.php?post_type=sp_player'][15] );

View File

@@ -1,10 +1,19 @@
<?php
function sportspress_manage_posts_columns( $defaults ){
$defaults['sp_views'] = __( 'Views', 'sportspress' );
return $defaults;
}
add_filter( 'manage_posts_columns', 'sportspress_manage_posts_columns' );
function sportspress_manage_posts_custom_column( $column, $post_id ) {
global $post;
switch ( $column ):
case 'sp_icon':
edit_post_link( get_the_post_thumbnail( $post_id, 'sportspress-icon' ), '', '', $post_id );
break;
case 'sp_views':
echo sportspress_get_post_views( $post_id );
break;
case 'sp_position':
echo get_the_terms( $post_id, 'sp_position' ) ? the_terms( $post_id, 'sp_position' ) : '&mdash;';
break;

View File

@@ -1,67 +1,66 @@
<?php
function sportspress_the_content( $content ) {
sportspress_set_post_views( get_the_ID() );
if ( is_singular( 'sp_event' ) && in_the_loop() ):
global $post;
$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;
$content = apply_filters( 'sportspress_event_content', $content );
elseif ( is_singular( 'sp_calendar' ) && in_the_loop() ):
global $post;
$calendar = sportspress_events_calendar( $post->ID );
$content = $calendar . $content;
$content = apply_filters( 'sportspress_calendar_content', $content );
elseif ( is_singular( 'sp_team' ) && in_the_loop() ):
global $post;
$columns = sportspress_team_columns( $post->ID );
$content = $columns . $content;
$content = apply_filters( 'sportspress_team_content', $content );
elseif ( is_singular( 'sp_table' ) && in_the_loop() ):
global $post;
$table = sportspress_league_table( $post->ID );
$content = $table . $content;
$content = apply_filters( 'sportspress_table_content', $content );
elseif ( is_singular( 'sp_list' ) && in_the_loop() ):
global $post;
$list = sportspress_player_list( $post->ID );
$content = $list . $content;
$content = apply_filters( 'sportspress_list_content', $content );
elseif ( is_singular( 'sp_player' ) && in_the_loop() ):
global $post;
$metrics = sportspress_player_metrics( $post->ID );
$statistics = sportspress_player_statistics( $post->ID );
$content = $metrics . $statistics . $content;
$content = apply_filters( 'sportspress_player_content', $content );
endif;
return $content;
}
add_filter( 'the_content', 'sportspress_the_content' );
add_filter( 'get_the_content', 'sportspress_the_content' );
add_filter( 'get_the_content', 'sportspress_the_content' );
function sportspress_default_event_content( $content ) {
$details = sportspress_event_details( get_the_ID() );
$results = sportspress_event_results( get_the_ID() );
$players = sportspress_event_players( get_the_ID() );
$staff = sportspress_event_staff( get_the_ID() );
if ( ! empty( $results ) )
return $results . $details . $players . $staff . $content;
$venue = sportspress_event_venue( get_the_ID() );
return $details . $venue . $players . $staff . $content;
}
add_filter( 'sportspress_event_content', 'sportspress_default_event_content' );
function sportspress_default_calendar_content( $content ) {
$calendar = sportspress_events_calendar( get_the_ID() );
return $calendar . $content;
}
add_filter( 'sportspress_calendar_content', 'sportspress_default_calendar_content' );
function sportspress_default_team_content( $content ) {
$columns = sportspress_team_columns( get_the_ID() );
return $columns . $content;
}
add_filter( 'sportspress_team_content', 'sportspress_default_team_content' );
function sportspress_default_table_content( $content ) {
$table = sportspress_league_table( get_the_ID() );
$excerpt = has_excerpt() ? '<p>' . nl2br( get_the_excerpt() ) . '</p>' : '';
return $table . $content . $excerpt;
}
add_filter( 'sportspress_table_content', 'sportspress_default_table_content' );
function sportspress_default_player_content( $content ) {
$metrics = sportspress_player_metrics( get_the_ID() );
$statistics = sportspress_player_statistics( get_the_ID() );
return $metrics . $statistics . $content;
}
add_filter( 'sportspress_player_content', 'sportspress_default_player_content' );
function sportspress_default_list_content( $content ) {
$list = sportspress_player_list( get_the_ID() );
return $list . $content;
}
add_filter( 'sportspress_list_content', 'sportspress_default_list_content' );

View File

@@ -27,6 +27,7 @@ function sportspress_calendar_edit_columns() {
'sp_league' => __( 'Leagues', 'sportspress' ),
'sp_season' => __( 'Seasons', 'sportspress' ),
'sp_venue' => __( 'Venues', 'sportspress' ),
'sp_views' => __( 'Views', 'sportspress' ),
);
return $columns;
}

View File

@@ -196,7 +196,8 @@ function sportspress_event_edit_columns() {
'sp_league' => __( 'League', 'sportspress' ),
'sp_season' => __( 'Season', 'sportspress' ),
'sp_venue' => __( 'Venue', 'sportspress' ),
'sp_kickoff' => __( 'Date/Time', 'sportspress' )
'sp_kickoff' => __( 'Date/Time', 'sportspress' ),
'sp_views' => __( 'Views', 'sportspress' ),
);
return $columns;
}

View File

@@ -28,6 +28,7 @@ function sportspress_list_edit_columns() {
'sp_league' => __( 'League', 'sportspress' ),
'sp_season' => __( 'Season', 'sportspress' ),
'sp_team' => __( 'Team', 'sportspress' ),
'sp_views' => __( 'Views', 'sportspress' ),
);
return $columns;
}

View File

@@ -28,6 +28,7 @@ function sportspress_player_edit_columns() {
'sp_team' => __( 'Teams', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' ),
'sp_season' => __( 'Seasons', 'sportspress' ),
'sp_views' => __( 'Views', 'sportspress' ),
);
return $columns;
}
@@ -80,6 +81,7 @@ function sportspress_player_details_meta( $post ) {
<p>
<select id="sp_nationality" name="sp_nationality">
<?php foreach ( $continents as $continent => $countries ): ?>
<option value=""><?php _e( '-- Not set --', 'sportspress' ); ?></option>
<optgroup label="<?php echo $continent; ?>">
<?php foreach ( $countries as $code => $country ): ?>
<option value="<?php echo $code; ?>" <?php selected ( $nationality, $code ); ?>>

View File

@@ -46,6 +46,7 @@ function sportspress_staff_edit_columns() {
'sp_team' => __( 'Teams', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' ),
'sp_season' => __( 'Seasons', 'sportspress' ),
'sp_views' => __( 'Views', 'sportspress' ),
);
return $columns;
}

View File

@@ -27,6 +27,7 @@ function sportspress_table_edit_columns() {
'sp_league' => __( 'League', 'sportspress' ),
'sp_season' => __( 'Season', 'sportspress' ),
'sp_team' => __( 'Teams', 'sportspress' ),
'sp_views' => __( 'Views', 'sportspress' ),
);
return $columns;
}

View File

@@ -40,6 +40,7 @@ function sportspress_team_edit_columns() {
'title' => __( 'Team', 'sportspress' ),
'sp_league' => __( 'Leagues', 'sportspress' ),
'sp_season' => __( 'Seasons', 'sportspress' ),
'sp_views' => __( 'Views', 'sportspress' ),
);
return $columns;
}

View File

@@ -9,16 +9,27 @@ if ( !function_exists( 'sportspress_league_table' ) ) {
$defaults = array(
'number_label' => __( 'Pos', 'sportspress' ),
'thumbnails' => 1,
'thumbnails' => 0,
'thumbnail_size' => 'thumbnail'
);
$r = wp_parse_args( $args, $defaults );
$data = sportspress_get_league_table_data( $id );
$leagues = get_the_terms( $id, 'sp_league' );
$seasons = get_the_terms( $id, 'sp_season' );
$terms = array();
if ( isset( $leagues[0] ) )
$terms[] = $leagues[0]->name;
if ( isset( $seasons[0] ) )
$terms[] = $seasons[0]->name;
$title = sizeof( $terms ) ? implode( ' &mdash; ', $terms ) : get_the_title( $id );
$output = '<table class="sp-league-table sp-data-table">' .
'<caption>' . get_the_title( $id ) . '</caption>' . '<thead>' . '<tr>';
'<caption>' . $title . '</caption>' . '<thead>' . '<tr>';
$data = sportspress_get_league_table_data( $id );
// The first row should be column labels
$labels = $data[0];

View File

@@ -13,11 +13,9 @@ if ( !function_exists( 'sportspress_player_metrics' ) ) {
$nationality = get_post_meta( $id, 'sp_nationality', true );
$metrics = sportspress_get_player_metrics_data( $id );
$flag_image = '<img src="' . SPORTSPRESS_PLUGIN_URL . 'assets/images/flags/' . strtolower( $nationality ) . '.png" class="sp-flag">';
$common = array(
__( 'Number', 'sportspress' ) => $number,
__( 'Nationality', 'sportspress' ) => $flag_image . ' ' . sportspress_array_value( $sportspress_countries, $nationality, '&mdash;' ),
__( 'Nationality', 'sportspress' ) => sportspress_array_value( $sportspress_countries, $nationality, '&mdash;' ),
);
$data = array_merge( $common, $metrics );

View File

@@ -3,7 +3,7 @@ function sportspress_venue_term_init() {
$name = __( 'Venues', 'sportspress' );
$singular_name = __( 'Venue', 'sportspress' );
$lowercase_name = __( 'venue', 'sportspress' );
$object_type = array( 'sp_event', 'sp_calendar' );
$object_type = array( 'sp_event', 'sp_calendar', 'attachment' );
$labels = sportspress_get_term_labels( $name, $singular_name, $lowercase_name );
$args = array(
'label' => $name,
@@ -15,6 +15,7 @@ function sportspress_venue_term_init() {
register_taxonomy( 'sp_venue', $object_type, $args );
register_taxonomy_for_object_type( 'sp_venue', 'sp_event' );
register_taxonomy_for_object_type( 'sp_venue', 'sp_calendar' );
register_taxonomy_for_object_type( 'sp_venue', 'attachment' );
}
add_action( 'init', 'sportspress_venue_term_init' );

View File

@@ -26,12 +26,6 @@
content: "\f140";
position: absolute;
}
.sp-data-table .data-number.sorting_asc {
cursor: default;
}
.sp-data-table .data-number:after {
content: "";
}
.sp-data-table .data-name .logo {
vertical-align: middle;
height: 2.5em;

View File

@@ -13,10 +13,7 @@
"sSortAscending": "",
"sSortDescending": ""
}
},
"aoColumnDefs": [
{ "asSorting": [ "asc" ], "aTargets": [ 0 ] },
]
}
});
// Player List Sorting

View File

@@ -107,21 +107,28 @@ if ( !function_exists( 'sportspress_get_the_term_id' ) ) {
}
}
if ( !function_exists( 'sportspress_get_post_format' ) ) {
function sportspress_get_post_format( $post_id ) {
$format = get_post_meta ( $post_id, 'sp_format', true );
if ( $format ):
$formats = sportspress_get_config_formats();
$format_str = sportspress_array_value( $formats, $format, '&mdash;' );
if ( in_array( $format, array( 'decimal', 'time' ) ) ):
return $format_str . ' (' . sportspress_get_post_precision( $post_id ) . ')';
else:
return $format_str;
endif;
else:
return '&mdash;';
endif;
}
function sportspress_get_post_views( $post_id ) {
$count_key = 'sp_views';
$count = get_post_meta( $post_id, $count_key, true );
if ( $count == '' ):
delete_post_meta( $post_id, $count_key );
add_post_meta( $post_id, $count_key, '0' );
return sprintf( _n( '1 View', '%1$s Views', '0', 'sportspress' ), '0' );
endif;
return sprintf( _n( '1 View', '%1$s Views', $count, 'sportspress' ), $count );
}
function sportspress_set_post_views( $post_id ) {
$count_key = 'sp_views';
$count = get_post_meta( $post_id, $count_key, true );
if ( $count == '' ):
$count = 0;
delete_post_meta( $post_id, $count_key );
add_post_meta( $post_id, $count_key, '0' );
else:
$count++;
update_post_meta( $post_id, $count_key, $count );
endif;
}
if ( !function_exists( 'sportspress_get_post_precision' ) ) {

View File

@@ -3,14 +3,86 @@ Contributors: themeboy
Tags: sports, sports journalism, teams, team management, fixtures, results, standings, league tables, leagues, reporting, themeboy, wordpress sports, configurable
Requires at least: 3.5
Tested up to: 3.8
Stable tag: 0.1.6
Stable tag: 0.1.10
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html
SportsPress is a flexible sports management plugin that adds team management functionality to WordPress. Currently in beta for internal testing.
== Installation ==
= Minimum Requirements =
* WordPress 3.5 or greater
* PHP version 5.2.4 or greater
* MySQL version 5.0 or greater
= Automatic installation =
Automatic installation is the easiest option as WordPress handles the file transfers itself and you dont even need to leave your web browser. To do an automatic install of SportsPress, log in to your WordPress admin panel, navigate to the Plugins menu and click Add New.
In the search field type “SportsPress” and click Search Plugins. Once youve found our sports plugin you can view details about it such as the the point release, rating and description. Most importantly of course, you can install it by simply clicking Install Now. After clicking that link you will be asked if youre sure you want to install the plugin. Click yes and WordPress will automatically complete the installation.
= Manual installation =
The manual installation method involves downloading our sports plugin and uploading it to your webserver via your favorite FTP application.
1. Download the plugin file to your computer and unzip it
2. Using an FTP program, or your hosting control panel, upload the unzipped plugin folder to your WordPress installations wp-content/plugins/ directory.
3. Activate the plugin from the Plugins menu within the WordPress admin.
= Upgrading =
Automatic updates should work like a charm; as always though, ensure you backup your site just in case.
If on the off-chance you do encounter issues with the event/team/player/staff pages after an update you simply need to flush the permalinks by going to WordPress > Settings > Permalinks and hitting 'save'. That should return things to normal.
= Settings =
SportsPress comes with settings for some sports that you can apply by going to WordPress > Settings > SportsPress. You can also add your own table columns, event results, and player statistics by clicking on the tabs on this screen.
== Frequently Asked Questions ==
= Which sports does this plugin support? =
The plugin will support most team sports with a scoring system. You can customize the table columns and player statistics by going to WordPress > Settings > SportsPress. It includes presets for many of the popular sports, and you can also add your own.
= Will SportsPress work with my theme? =
Yes; SportsPress will work with any theme, but may require some styling to make it match nicely.
= Where can I report bugs or contribute to the project? =
Bugs can be reported either in our support forum or preferably on the [SportsPress GitHub repository](https://github.com/ThemeBoy/SportsPress/issues).
= SportsPress is awesome! Can I contribute? =
Yes you can! Join in on our [GitHub repository](http://github.com/ThemeBoy/SportsPress/) :)
= Is this plugin ready for production? =
SportsPress is currently in beta and is undergoing testing. We are still actively making adjustments to the code, so we do not recommend installing it on a live server until we officially leave the beta phase.
== Screenshots ==
1. Events admin.
2. Teams admin.
3. Players admin.
4. SportsPress Settings panel.
== Changelog ==
= 0.1.10 =
* Documentation - Add Installation, FAQ and Screenshots to assets.
= 0.1.9 =
* Fix - Calculation dependencies.
= 0.1.8 =
* Tweak - Update subversion.
= 0.1.7 =
* Feature - Enable selecting venues to use uploaded images.
= 0.1.6 =
* Tweak - Activate per post type permissions.
* Tweak - Give admin all permissions for custom posts.
@@ -45,4 +117,4 @@ SportsPress is a flexible sports management plugin that adds team management fun
* Tweak - Update description.
= 0.1 =
* Alpha release for first look and testing.
* Alpha release for first look and testing.

View File

@@ -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.1.6
Version: 0.1.10
Author: ThemeBoy
Author URI: http://themeboy.com/
License: GPLv3
@@ -18,7 +18,7 @@ if ( !function_exists( 'add_action' ) ) {
exit;
}
define( 'SPORTSPRESS_VERSION', '0.1.6' );
define( 'SPORTSPRESS_VERSION', '0.1.10' );
define( 'SPORTSPRESS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'SPORTSPRESS_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
define( 'SPORTSPRESS_PLUGIN_FILE', __FILE__ );
@@ -84,7 +84,7 @@ require_once dirname( __FILE__ ) . '/admin/hooks/admin-print-styles.php';
require_once dirname( __FILE__ ) . '/admin/hooks/admin-head.php';
// Administrative actions
require_once dirname( __FILE__ ) . '/admin/hooks/manage-posts-custom-column.php';
require_once dirname( __FILE__ ) . '/admin/hooks/manage-posts-columns.php';
require_once dirname( __FILE__ ) . '/admin/hooks/post-thumbnail-html.php';
require_once dirname( __FILE__ ) . '/admin/hooks/restrict-manage-posts.php';
require_once dirname( __FILE__ ) . '/admin/hooks/save-post.php';