Add views counter and style tweaks
This commit is contained in:
@@ -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] );
|
||||
|
||||
@@ -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' ) : '—';
|
||||
break;
|
||||
@@ -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' );
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 ); ?>>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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( ' — ', $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];
|
||||
|
||||
@@ -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, '—' ),
|
||||
__( 'Nationality', 'sportspress' ) => sportspress_array_value( $sportspress_countries, $nationality, '—' ),
|
||||
);
|
||||
|
||||
$data = array_merge( $common, $metrics );
|
||||
|
||||
@@ -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' );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user