Event list title format selector close #46
This commit is contained in:
@@ -135,6 +135,12 @@ jQuery(document).ready(function($){
|
|||||||
$(".sp-dummy."+name+"-dummy").val(val).trigger("change");
|
$(".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
|
// Custom value editor
|
||||||
$(".sp-data-table .sp-default-value").click(function() {
|
$(".sp-data-table .sp-default-value").click(function() {
|
||||||
$(this).hide().siblings(".sp-custom-value").show().find(".sp-custom-value-input").focus();
|
$(this).hide().siblings(".sp-custom-value").show().find(".sp-custom-value-input").focus();
|
||||||
|
|||||||
@@ -22,20 +22,22 @@ class SP_Meta_Box_Calendar_Data {
|
|||||||
$calendar = new SP_Calendar( $post );
|
$calendar = new SP_Calendar( $post );
|
||||||
$data = $calendar->data();
|
$data = $calendar->data();
|
||||||
$usecolumns = $calendar->columns;
|
$usecolumns = $calendar->columns;
|
||||||
self::table( $data, $usecolumns );
|
$title_format = $calendar->title_format;
|
||||||
|
self::table( $data, $usecolumns, $title_format );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save meta box data
|
* Save meta box data
|
||||||
*/
|
*/
|
||||||
public static function save( $post_id, $post ) {
|
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() ) );
|
update_post_meta( $post_id, 'sp_columns', sp_array_value( $_POST, 'sp_columns', array() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Admin edit table
|
* 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 ) )
|
if ( is_array( $usecolumns ) )
|
||||||
$usecolumns = array_filter( $usecolumns );
|
$usecolumns = array_filter( $usecolumns );
|
||||||
?>
|
?>
|
||||||
@@ -49,13 +51,11 @@ class SP_Meta_Box_Calendar_Data {
|
|||||||
<th class="column-event">
|
<th class="column-event">
|
||||||
<label for="sp_columns_event">
|
<label for="sp_columns_event">
|
||||||
<input type="checkbox" name="sp_columns[]" value="event" id="sp_columns_event" <?php checked( ! is_array( $usecolumns ) || in_array( 'event', $usecolumns ) ); ?>>
|
<input type="checkbox" name="sp_columns[]" value="event" id="sp_columns_event" <?php checked( ! is_array( $usecolumns ) || in_array( 'event', $usecolumns ) ); ?>>
|
||||||
<?php _e( 'Event', 'sportspress' ); ?>
|
<select name="sp_title_format" class="sp-title-format-select">
|
||||||
</label>
|
<option value="title" <?php selected( $title_format, 'title' ); ?>><?php _e( 'Title', 'sportspress' ); ?></option>
|
||||||
</th>
|
<option value="teams" <?php selected( $title_format, 'teams' ); ?>><?php _e( 'Teams', 'sportspress' ); ?></option>
|
||||||
<th class="column-teams">
|
<option value="homeaway" <?php selected( $title_format, 'homeaway' ); ?>><?php _e( 'Home', 'sportspress' ); ?> | <?php _e( 'Away', 'sportspress' ); ?></option>
|
||||||
<label for="sp_columns_teams">
|
</select>
|
||||||
<input type="checkbox" name="sp_columns[]" value="teams" id="sp_columns_teams" <?php checked( ! is_array( $usecolumns ) || in_array( 'teams', $usecolumns ) ); ?>>
|
|
||||||
<?php _e( 'Teams', 'sportspress' ); ?>
|
|
||||||
</label>
|
</label>
|
||||||
</th>
|
</th>
|
||||||
<th class="column-time">
|
<th class="column-time">
|
||||||
@@ -92,8 +92,9 @@ class SP_Meta_Box_Calendar_Data {
|
|||||||
?>
|
?>
|
||||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||||
<td><?php echo get_post_time( get_option( 'date_format' ), false, $event, true ); ?></td>
|
<td><?php echo get_post_time( get_option( 'date_format' ), false, $event, true ); ?></td>
|
||||||
<td><?php echo $event->post_title; ?></td>
|
|
||||||
<td>
|
<td>
|
||||||
|
<div class="sp-title-format sp-title-format-title<?php if ( $title_format != 'title' ): ?> hidden<?php endif; ?>"><?php echo $event->post_title; ?></div>
|
||||||
|
<div class="sp-title-format sp-title-format-teams sp-title-format-homeaway<?php if ( ! in_array( $title_format, array( 'teams', 'homeaway' ) ) ): ?> hidden<?php endif; ?>">
|
||||||
<?php
|
<?php
|
||||||
if ( $teams ): foreach ( $teams as $team ):
|
if ( $teams ): foreach ( $teams as $team ):
|
||||||
$name = get_the_title( $team );
|
$name = get_the_title( $team );
|
||||||
@@ -124,6 +125,7 @@ class SP_Meta_Box_Calendar_Data {
|
|||||||
echo '—';
|
echo '—';
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
@@ -21,12 +21,12 @@ $seasons = get_the_terms( $id, 'sp_season' );
|
|||||||
$data = array( __( 'Date', 'sportspress' ) => $date, __( 'Time', 'sportspress' ) => $time );
|
$data = array( __( 'Date', 'sportspress' ) => $date, __( 'Time', 'sportspress' ) => $time );
|
||||||
|
|
||||||
if ( $leagues ):
|
if ( $leagues ):
|
||||||
$league = array_pop( $leagues );
|
$league = array_shift( $leagues );
|
||||||
$data[ __( 'League', 'sportspress' ) ] = $league->name;
|
$data[ __( 'League', 'sportspress' ) ] = $league->name;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( $seasons ):
|
if ( $seasons ):
|
||||||
$season = array_pop( $seasons );
|
$season = array_shift( $seasons );
|
||||||
$data[ __( 'Season', 'sportspress' ) ] = $season->name;
|
$data[ __( 'Season', 'sportspress' ) ] = $season->name;
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ if ( $order != 'default' )
|
|||||||
$calendar->order = $order;
|
$calendar->order = $order;
|
||||||
$data = $calendar->data();
|
$data = $calendar->data();
|
||||||
$usecolumns = $calendar->columns;
|
$usecolumns = $calendar->columns;
|
||||||
|
$title_format = $calendar->title_format;
|
||||||
|
|
||||||
if ( isset( $columns ) ):
|
if ( isset( $columns ) ):
|
||||||
if ( is_array( $columns ) )
|
if ( is_array( $columns ) )
|
||||||
@@ -55,11 +56,16 @@ endif;
|
|||||||
<?php
|
<?php
|
||||||
echo '<th class="data-date">' . __( 'Date', 'sportspress' ) . '</th>';
|
echo '<th class="data-date">' . __( 'Date', 'sportspress' ) . '</th>';
|
||||||
|
|
||||||
if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
|
if ( $usecolumns == null || in_array( 'event', $usecolumns ) ):
|
||||||
echo '<th class="data-event">' . __( 'Event', 'sportspress' ) . '</th>';
|
if ( $title_format == 'homeaway' ):
|
||||||
|
echo '<th class="data-home">' . __( 'Home', 'sportspress' ) . '</th>';
|
||||||
if ( $usecolumns == null || in_array( 'teams', $usecolumns ) )
|
echo '<th class="data-away">' . __( 'Away', 'sportspress' ) . '</th>';
|
||||||
|
elseif ( $title_format == 'teams' ):
|
||||||
echo '<th class="data-teams">' . __( 'Teams', 'sportspress' ) . '</th>';
|
echo '<th class="data-teams">' . __( 'Teams', 'sportspress' ) . '</th>';
|
||||||
|
else:
|
||||||
|
echo '<th class="data-event">' . __( 'Event', 'sportspress' ) . '</th>';
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
|
|
||||||
if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
|
if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
|
||||||
echo '<th class="data-time">' . __( 'Time/Results', 'sportspress' ) . '</th>';
|
echo '<th class="data-time">' . __( 'Time/Results', 'sportspress' ) . '</th>';
|
||||||
@@ -88,6 +94,7 @@ endif;
|
|||||||
|
|
||||||
$main_results = array();
|
$main_results = array();
|
||||||
$teams_output = '';
|
$teams_output = '';
|
||||||
|
$teams_array = '';
|
||||||
|
|
||||||
if ( $teams ):
|
if ( $teams ):
|
||||||
foreach ( $teams as $team ):
|
foreach ( $teams as $team ):
|
||||||
@@ -107,17 +114,19 @@ endif;
|
|||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( $link_teams ):
|
if ( $link_teams ):
|
||||||
$teams_output .= '<a href="' . get_post_permalink( $team ) . '">' . $name . '</a>';
|
$team_output = '<a href="' . get_post_permalink( $team ) . '">' . $name . '</a>';
|
||||||
else:
|
else:
|
||||||
$teams_output .= $name;
|
$team_output = $name;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( $team_result != null ):
|
if ( $team_result != null ):
|
||||||
$main_results[] = $team_result;
|
$main_results[] = $team_result;
|
||||||
$teams_output .= ' (' . $team_result . ')';
|
$team_output .= ' (' . $team_result . ')';
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
$teams_output .= '<br>';
|
$teams_array[] = $team_output;
|
||||||
|
|
||||||
|
$teams_output .= $team_output . '<br>';
|
||||||
endif;
|
endif;
|
||||||
endforeach;
|
endforeach;
|
||||||
else:
|
else:
|
||||||
@@ -128,23 +137,29 @@ endif;
|
|||||||
|
|
||||||
echo '<td class="data-date"><a href="' . get_permalink( $event->ID ) . '">' . get_post_time( get_option( 'date_format' ), false, $event, true ) . '</a></td>';
|
echo '<td class="data-date"><a href="' . get_permalink( $event->ID ) . '">' . get_post_time( get_option( 'date_format' ), false, $event, true ) . '</a></td>';
|
||||||
|
|
||||||
if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
|
if ( $usecolumns == null || in_array( 'event', $usecolumns ) ):
|
||||||
echo '<td class="data-event">' . $event->post_title . '</td>';
|
if ( $title_format == 'homeaway' ):
|
||||||
|
$team = array_shift( $teams_array );
|
||||||
if ( $usecolumns == null || in_array( 'teams', $usecolumns ) ):
|
echo '<td class="data-home">' . $team . '</td>';
|
||||||
echo '<td class="data-teams">';
|
$team = array_shift( $teams_array );
|
||||||
echo $teams_output;
|
echo '<td class="data-away">' . $team . '</td>';
|
||||||
echo '</td>';
|
else:
|
||||||
|
if ( $title_format == 'teams' ):
|
||||||
|
echo '<td class="data-event">' . $teams_output . '</td>';
|
||||||
|
else:
|
||||||
|
echo '<td class="data-event"><a href="' . get_permalink( $event->ID ) . '">' . $event->post_title . '</a></td>';
|
||||||
|
endif;
|
||||||
|
endif;
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( $usecolumns == null || in_array( 'time', $usecolumns ) ):
|
if ( $usecolumns == null || in_array( 'time', $usecolumns ) ):
|
||||||
echo '<td class="data-time">';
|
echo '<td class="data-time"><a href="' . get_permalink( $event->ID ) . '">';
|
||||||
if ( ! empty( $main_results ) ):
|
if ( ! empty( $main_results ) ):
|
||||||
echo implode( ' - ', $main_results );
|
echo implode( ' - ', $main_results );
|
||||||
else:
|
else:
|
||||||
echo get_post_time( get_option( 'time_format' ), false, $event, true );
|
echo get_post_time( get_option( 'time_format' ), false, $event, true );
|
||||||
endif;
|
endif;
|
||||||
echo '</td>';
|
echo '</a></td>';
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
if ( $usecolumns == null || in_array( 'venue', $usecolumns ) ):
|
if ( $usecolumns == null || in_array( 'venue', $usecolumns ) ):
|
||||||
|
|||||||
Reference in New Issue
Block a user