diff --git a/assets/js/admin/sportspress-admin.js b/assets/js/admin/sportspress-admin.js
index 455ced27..52bf2eec 100644
--- a/assets/js/admin/sportspress-admin.js
+++ b/assets/js/admin/sportspress-admin.js
@@ -135,6 +135,12 @@ jQuery(document).ready(function($){
$(".sp-dummy."+name+"-dummy").val(val).trigger("change");
});
+ // Title format switcher
+ $(".sp-title-format-select").change(function() {
+ val = $(this).val();
+ $(".sp-title-format").hide().filter(".sp-title-format-"+val).show();
+ });
+
// Custom value editor
$(".sp-data-table .sp-default-value").click(function() {
$(this).hide().siblings(".sp-custom-value").show().find(".sp-custom-value-input").focus();
diff --git a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php
index e038c606..fdd49066 100644
--- a/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php
+++ b/includes/admin/post-types/meta-boxes/class-sp-meta-box-calendar-data.php
@@ -22,20 +22,22 @@ class SP_Meta_Box_Calendar_Data {
$calendar = new SP_Calendar( $post );
$data = $calendar->data();
$usecolumns = $calendar->columns;
- self::table( $data, $usecolumns );
+ $title_format = $calendar->title_format;
+ self::table( $data, $usecolumns, $title_format );
}
/**
* Save meta box data
*/
public static function save( $post_id, $post ) {
+ update_post_meta( $post_id, 'sp_title_format', sp_array_value( $_POST, 'sp_title_format', 'title' ) );
update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) );
}
/**
* Admin edit table
*/
- public static function table( $data = array(), $usecolumns = null ) {
+ public static function table( $data = array(), $usecolumns = null, $title_format = null ) {
if ( is_array( $usecolumns ) )
$usecolumns = array_filter( $usecolumns );
?>
@@ -49,13 +51,11 @@ class SP_Meta_Box_Calendar_Data {
|
- post_title; ?> |
- hidden">post_title; ?>
+
|
$date, __( 'Time', 'sportspress' ) => $time );
if ( $leagues ):
- $league = array_pop( $leagues );
+ $league = array_shift( $leagues );
$data[ __( 'League', 'sportspress' ) ] = $league->name;
endif;
if ( $seasons ):
- $season = array_pop( $seasons );
+ $season = array_shift( $seasons );
$data[ __( 'Season', 'sportspress' ) ] = $season->name;
endif;
?>
diff --git a/templates/event-list.php b/templates/event-list.php
index feadcf17..8f01e26d 100644
--- a/templates/event-list.php
+++ b/templates/event-list.php
@@ -39,6 +39,7 @@ if ( $order != 'default' )
$calendar->order = $order;
$data = $calendar->data();
$usecolumns = $calendar->columns;
+$title_format = $calendar->title_format;
if ( isset( $columns ) ):
if ( is_array( $columns ) )
@@ -55,11 +56,16 @@ endif;
' . __( 'Date', 'sportspress' ) . '';
- if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
- echo ' | ' . __( 'Event', 'sportspress' ) . ' | ';
-
- if ( $usecolumns == null || in_array( 'teams', $usecolumns ) )
- echo '' . __( 'Teams', 'sportspress' ) . ' | ';
+ if ( $usecolumns == null || in_array( 'event', $usecolumns ) ):
+ if ( $title_format == 'homeaway' ):
+ echo '' . __( 'Home', 'sportspress' ) . ' | ';
+ echo '' . __( 'Away', 'sportspress' ) . ' | ';
+ elseif ( $title_format == 'teams' ):
+ echo '' . __( 'Teams', 'sportspress' ) . ' | ';
+ else:
+ echo '' . __( 'Event', 'sportspress' ) . ' | ';
+ endif;
+ endif;
if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
echo '' . __( 'Time/Results', 'sportspress' ) . ' | ';
@@ -88,6 +94,7 @@ endif;
$main_results = array();
$teams_output = '';
+ $teams_array = '';
if ( $teams ):
foreach ( $teams as $team ):
@@ -107,17 +114,19 @@ endif;
endif;
if ( $link_teams ):
- $teams_output .= '' . $name . '';
+ $team_output = '' . $name . '';
else:
- $teams_output .= $name;
+ $team_output = $name;
endif;
if ( $team_result != null ):
$main_results[] = $team_result;
- $teams_output .= ' (' . $team_result . ')';
+ $team_output .= ' (' . $team_result . ')';
endif;
- $teams_output .= '
';
+ $teams_array[] = $team_output;
+
+ $teams_output .= $team_output . '
';
endif;
endforeach;
else:
@@ -128,58 +137,64 @@ endif;
echo '' . get_post_time( get_option( 'date_format' ), false, $event, true ) . ' | ';
- if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
- echo '' . $event->post_title . ' | ';
+ if ( $usecolumns == null || in_array( 'event', $usecolumns ) ):
+ if ( $title_format == 'homeaway' ):
+ $team = array_shift( $teams_array );
+ echo '' . $team . ' | ';
+ $team = array_shift( $teams_array );
+ echo '' . $team . ' | ';
+ else:
+ if ( $title_format == 'teams' ):
+ echo '' . $teams_output . ' | ';
+ else:
+ echo '' . $event->post_title . ' | ';
+ endif;
+ endif;
+ endif;
- if ( $usecolumns == null || in_array( 'teams', $usecolumns ) ):
- echo '';
- echo $teams_output;
+ if ( $usecolumns == null || in_array( 'time', $usecolumns ) ):
+ echo ' | ';
+ if ( ! empty( $main_results ) ):
+ echo implode( ' - ', $main_results );
+ else:
+ echo get_post_time( get_option( 'time_format' ), false, $event, true );
+ endif;
+ echo ' | ';
+ endif;
+
+ if ( $usecolumns == null || in_array( 'venue', $usecolumns ) ):
+ echo '';
+ if ( $link_venues ):
+ the_terms( $event->ID, 'sp_venue' );
+ else:
+ $venues = get_the_terms( $event->ID, 'sp_venue' );
+ foreach ( $venues as $venue ):
+ echo $venue->name;
+ endforeach;
+ endif;
echo ' | ';
endif;
- if ( $usecolumns == null || in_array( 'time', $usecolumns ) ):
- echo '';
- if ( ! empty( $main_results ) ):
- echo implode( ' - ', $main_results );
- else:
- echo get_post_time( get_option( 'time_format' ), false, $event, true );
- endif;
- echo ' | ';
- endif;
+ if ( $usecolumns == null || in_array( 'article', $usecolumns ) ):
+ echo '
+ ';
- if ( $usecolumns == null || in_array( 'venue', $usecolumns ) ):
- echo ' | ';
- if ( $link_venues ):
- the_terms( $event->ID, 'sp_venue' );
- else:
- $venues = get_the_terms( $event->ID, 'sp_venue' );
- foreach ( $venues as $venue ):
- echo $venue->name;
- endforeach;
- endif;
- echo ' | ';
- endif;
-
- if ( $usecolumns == null || in_array( 'article', $usecolumns ) ):
- echo '
- ';
-
- if ( $video ):
- echo '';
- elseif ( has_post_thumbnail( $event->ID ) ):
- echo '';
- endif;
- if ( $event->post_content !== null ):
- if ( $event->post_status == 'publish' ):
- _e( 'Recap', 'sportspress' );
- else:
- _e( 'Preview', 'sportspress' );
+ if ( $video ):
+ echo '';
+ elseif ( has_post_thumbnail( $event->ID ) ):
+ echo '';
+ endif;
+ if ( $event->post_content !== null ):
+ if ( $event->post_status == 'publish' ):
+ _e( 'Recap', 'sportspress' );
+ else:
+ _e( 'Preview', 'sportspress' );
+ endif;
endif;
- endif;
- echo '
- | ';
- endif;
+ echo '
+ ';
+ endif;
echo '
';