Add venue column to event list and prompt to select details if new calendar
This commit is contained in:
@@ -43,14 +43,14 @@ class SP_Admin_Menus {
|
||||
global $typenow;
|
||||
if ( in_array( $typenow, array( 'sp_result', 'sp_outcome', 'sp_column', 'sp_performance', 'sp_metric' ) ) )
|
||||
sportspress_highlight_admin_menu();
|
||||
elseif ( $typenow == 'sp_calendar' )
|
||||
sportspress_highlight_admin_menu( 'edit.php?post_type=sp_event', 'edit.php?post_type=sp_calendar' );
|
||||
elseif ( $typenow == 'sp_table' )
|
||||
sportspress_highlight_admin_menu( 'edit.php?post_type=sp_team', 'edit.php?post_type=sp_table' );
|
||||
elseif ( $typenow == 'sp_list' )
|
||||
sportspress_highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_list' );
|
||||
elseif ( $typenow == 'sp_staff' )
|
||||
sportspress_highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_staff' );
|
||||
elseif ( $typenow == 'sp_directory' )
|
||||
sportspress_highlight_admin_menu( 'edit.php?post_type=sp_player', 'edit.php?post_type=sp_directory' );
|
||||
sportspress_highlight_admin_menu( 'edit.php?post_type=sp_staff', 'edit.php?post_type=sp_directory' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -120,7 +120,7 @@ class SP_Admin_Meta_Boxes {
|
||||
add_meta_box( 'sp_shortcodediv', __( 'Shortcode', 'sportspress' ), 'SP_Meta_Box_List_Shortcode::output', 'sp_list', 'side', 'default' );
|
||||
add_meta_box( 'sp_formatdiv', __( 'Layout', 'sportspress' ), 'SP_Meta_Box_List_Format::output', 'sp_list', 'side', 'default' );
|
||||
add_meta_box( 'sp_detailsdiv', __( 'Details', 'sportspress' ), 'SP_Meta_Box_List_Details::output', 'sp_list', 'side', 'default' );
|
||||
add_meta_box( 'sp_datadiv', __( 'Player List', 'sportspress' ), 'SP_Meta_Box_List_Data::output', 'sp_list', 'normal', 'default' );
|
||||
add_meta_box( 'sp_datadiv', __( 'Player List', 'sportspress' ), 'SP_Meta_Box_List_Data::output', 'sp_list', 'normal', 'high' );
|
||||
add_meta_box( 'sp_descriptiondiv', __( 'Description', 'sportspress' ), 'SP_Meta_Box_List_Description::output', 'sp_list', 'normal', 'high' );
|
||||
}
|
||||
|
||||
|
||||
@@ -402,6 +402,7 @@ class SP_Post_types {
|
||||
'has_archive' => false,
|
||||
'show_in_nav_menus' => true,
|
||||
'show_in_menu' => 'edit.php?post_type=sp_event',
|
||||
'show_in_admin_bar' => true,
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -462,6 +463,7 @@ class SP_Post_types {
|
||||
'has_archive' => false,
|
||||
'show_in_nav_menus' => true,
|
||||
'show_in_menu' => 'edit.php?post_type=sp_team',
|
||||
'show_in_admin_bar' => true,
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -522,6 +524,7 @@ class SP_Post_types {
|
||||
'has_archive' => false,
|
||||
'show_in_nav_menus' => true,
|
||||
'show_in_menu' => 'edit.php?post_type=sp_player',
|
||||
'show_in_admin_bar' => true,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
@@ -889,6 +889,12 @@ if ( !function_exists( 'sp_edit_calendar_table' ) ) {
|
||||
<?php _e( 'Time', 'sportspress' ); ?>
|
||||
</label>
|
||||
</th>
|
||||
<th class="column-venue">
|
||||
<label for="sp_columns_venue">
|
||||
<input type="checkbox" name="sp_columns[]" value="venue" id="sp_columns_venue" <?php checked( ! is_array( $usecolumns ) || in_array( 'venue', $usecolumns ) ); ?>>
|
||||
<?php _e( 'Venue', 'sportspress' ); ?>
|
||||
</label>
|
||||
</th>
|
||||
<th class="column-article">
|
||||
<label for="sp_columns_article">
|
||||
<input type="checkbox" name="sp_columns[]" value="article" id="sp_columns_article" <?php checked( ! is_array( $usecolumns ) || in_array( 'article', $usecolumns ) ); ?>>
|
||||
@@ -941,6 +947,7 @@ if ( !function_exists( 'sp_edit_calendar_table' ) ) {
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo get_post_time( get_option( 'time_format' ), false, $event ); ?></td>
|
||||
<td><?php the_terms( $event->ID, 'sp_venue' ); ?></td>
|
||||
<td>
|
||||
<a href="<?php echo get_edit_post_link( $event->ID ); ?>#sp_articlediv">
|
||||
<?php if ( $video ): ?>
|
||||
@@ -966,7 +973,7 @@ if ( !function_exists( 'sp_edit_calendar_table' ) ) {
|
||||
else:
|
||||
?>
|
||||
<tr class="sp-row alternate">
|
||||
<td colspan="4">
|
||||
<td colspan="6">
|
||||
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Details', 'sportspress' ) ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -1074,6 +1081,7 @@ if ( !function_exists( 'sp_edit_player_list_table' ) ) {
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
if ( is_array( $data ) && sizeof( $data ) > 0 ):
|
||||
$i = 0;
|
||||
foreach ( $data as $player_id => $player_stats ):
|
||||
if ( !$player_id ) continue;
|
||||
@@ -1095,6 +1103,15 @@ if ( !function_exists( 'sp_edit_player_list_table' ) ) {
|
||||
<?php
|
||||
$i++;
|
||||
endforeach;
|
||||
else:
|
||||
?>
|
||||
<tr class="sp-row alternate">
|
||||
<td colspan="<?php $colspan = sizeof( $columns ) + 1; echo $colspan; ?>">
|
||||
<?php printf( __( 'Select %s', 'sportspress' ), __( 'Players', 'sportspress' ) ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
endif;
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -1607,6 +1624,7 @@ if ( !function_exists( 'sp_event_players_sub_filter' ) ) {
|
||||
|
||||
if ( !function_exists( 'sp_get_calendar_data' ) ) {
|
||||
function sp_get_calendar_data( $post_id = null, $admin = false ) {
|
||||
global $pagenow;
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'sp_event',
|
||||
@@ -1620,7 +1638,7 @@ if ( !function_exists( 'sp_get_calendar_data' ) ) {
|
||||
),
|
||||
);
|
||||
|
||||
if ( $post_id ):
|
||||
if ( $pagenow != 'post-new.php' && $post_id ):
|
||||
$leagues = get_the_terms( $post_id, 'sp_league' );
|
||||
$seasons = get_the_terms( $post_id, 'sp_season' );
|
||||
$venues = get_the_terms( $post_id, 'sp_venue' );
|
||||
@@ -1671,11 +1689,12 @@ if ( !function_exists( 'sp_get_calendar_data' ) ) {
|
||||
),
|
||||
);
|
||||
endif;
|
||||
else:
|
||||
$usecolumns = null;
|
||||
endif;
|
||||
|
||||
$events = get_posts( $args );
|
||||
else:
|
||||
$usecolumns = null;
|
||||
$events = null;
|
||||
endif;
|
||||
|
||||
if ( $admin ):
|
||||
return array( $events, $usecolumns );
|
||||
|
||||
@@ -10,12 +10,13 @@ class SP_Widget_Event_List extends WP_Widget {
|
||||
extract($args);
|
||||
$title = apply_filters('widget_title', empty($instance['title']) ? '' : $instance['title'], $instance, $this->id_base);
|
||||
$id = empty($instance['id']) ? null : $instance['id'];
|
||||
$number = empty($instance['number']) ? null : $instance['number'];
|
||||
$columns = empty($instance['columns']) ? null : $instance['columns'];
|
||||
$show_all_events_link = empty($instance['show_all_events_link']) ? false : $instance['show_all_events_link'];
|
||||
echo $before_widget;
|
||||
if ( $title )
|
||||
echo $before_title . $title . $after_title;
|
||||
sp_get_template( 'event-list.php', array( 'id' => $id, 'columns' => $columns, 'show_all_events_link' => $show_all_events_link ) );
|
||||
sp_get_template( 'event-list.php', array( 'id' => $id, 'number' => $number, 'columns' => $columns, 'show_all_events_link' => $show_all_events_link ) );
|
||||
echo $after_widget;
|
||||
}
|
||||
|
||||
@@ -23,6 +24,7 @@ class SP_Widget_Event_List extends WP_Widget {
|
||||
$instance = $old_instance;
|
||||
$instance['title'] = strip_tags($new_instance['title']);
|
||||
$instance['id'] = intval($new_instance['id']);
|
||||
$instance['number'] = intval($new_instance['number']);
|
||||
$instance['columns'] = (array)$new_instance['columns'];
|
||||
$instance['show_all_events_link'] = $new_instance['show_all_events_link'];
|
||||
|
||||
@@ -30,9 +32,10 @@ class SP_Widget_Event_List extends WP_Widget {
|
||||
}
|
||||
|
||||
function form( $instance ) {
|
||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'columns' => null, 'show_all_events_link' => true ) );
|
||||
$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'id' => null, 'number' => 5, 'columns' => null, 'show_all_events_link' => true ) );
|
||||
$title = strip_tags($instance['title']);
|
||||
$id = intval($instance['id']);
|
||||
$number = intval($instance['number']);
|
||||
$columns = $instance['columns'];
|
||||
$show_all_events_link = $instance['show_all_events_link'];
|
||||
?>
|
||||
@@ -56,6 +59,10 @@ class SP_Widget_Event_List extends WP_Widget {
|
||||
?>
|
||||
</p>
|
||||
|
||||
<p><label for="<?php echo $this->get_field_id('number'); ?>"><?php _e( 'Number of events to show:', 'sportspress' ); ?></label>
|
||||
<input id="<?php echo $this->get_field_id('number'); ?>" name="<?php echo $this->get_field_name('number'); ?>" type="text" value="<?php echo esc_attr($number); ?>" size="3"></p>
|
||||
|
||||
|
||||
<p class="sp-prefs">
|
||||
<?php _e( 'Columns:', 'sportspress' ); ?><br>
|
||||
<?php
|
||||
@@ -63,6 +70,7 @@ class SP_Widget_Event_List extends WP_Widget {
|
||||
'event' => __( 'Event', 'sportspress' ),
|
||||
'teams' => __( 'Teams', 'sportspress' ),
|
||||
'time' => __( 'Time', 'sportspress' ),
|
||||
'venue' => __( 'Venue', 'sportspress' ),
|
||||
'article' => __( 'Article', 'sportspress' ),
|
||||
);
|
||||
$field_name = $this->get_field_name('columns') . '[]';
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,52 +1,66 @@
|
||||
<?php
|
||||
global $sportspress_options;
|
||||
$main_result = sportspress_array_value( $sportspress_options, 'main_result', null );
|
||||
$primary_result = sportspress_array_value( $sportspress_options, 'sportspress_primary_result', null );
|
||||
|
||||
$defaults = array(
|
||||
'number' => -1,
|
||||
'show_all_events_link' => false,
|
||||
);
|
||||
|
||||
extract( $defaults, EXTR_SKIP );
|
||||
|
||||
$output = '<div class="sp-table-wrapper">' .
|
||||
'<table class="sp-event-list sp-data-table sp-responsive-table">' . '<thead>' . '<tr>';
|
||||
|
||||
?>
|
||||
<div class="sp-table-wrapper">
|
||||
<table class="sp-event-list sp-data-table sp-responsive-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php
|
||||
list( $data, $usecolumns ) = sportspress_get_calendar_data( $id, true );
|
||||
|
||||
if ( isset( $columns ) )
|
||||
$usecolumns = $columns;
|
||||
|
||||
$output .= '<th class="data-date">' . SP()->text->string('Date', 'event') . '</th>';
|
||||
echo '<th class="data-date">' . SP()->text->string('Date', 'event') . '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
|
||||
$output .= '<th class="data-event">' . SP()->text->string('Event', 'event') . '</th>';
|
||||
echo '<th class="data-event">' . SP()->text->string('Event', 'event') . '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'teams', $usecolumns ) )
|
||||
$output .= '<th class="data-teams">' . SP()->text->string('Teams', 'event') . '</th>';
|
||||
echo '<th class="data-teams">' . SP()->text->string('Teams', 'event') . '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
|
||||
$output .= '<th class="data-time">' . SP()->text->string('Time', 'event') . '</th>';
|
||||
echo '<th class="data-time">' . SP()->text->string('Time', 'event') . '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'venue', $usecolumns ) )
|
||||
echo '<th class="data-venue">' . SP()->text->string('Venue', 'event') . '</th>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'article', $usecolumns ) )
|
||||
$output .= '<th class="data-article">' . SP()->text->string('Article', 'event') . '</th>';
|
||||
|
||||
$output .= '</tr>' . '</thead>' . '<tbody>';
|
||||
|
||||
echo '<th class="data-article">' . SP()->text->string('Article', 'event') . '</th>';
|
||||
?>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$i = 0;
|
||||
|
||||
if ( is_int( $number ) && $number > 0 )
|
||||
$limit = $number;
|
||||
|
||||
foreach ( $data as $event ):
|
||||
if ( isset( $limit ) && $i >= $limit ) continue;
|
||||
|
||||
$teams = get_post_meta( $event->ID, 'sp_team' );
|
||||
$results = get_post_meta( $event->ID, 'sp_results', true );
|
||||
$video = get_post_meta( $event->ID, 'sp_video', true );
|
||||
|
||||
$output .= '<tr class="sp-row sp-post' . ( $i % 2 == 0 ? ' alternate' : '' ) . '">';
|
||||
echo '<tr class="sp-row sp-post' . ( $i % 2 == 0 ? ' alternate' : '' ) . '">';
|
||||
|
||||
$output .= '<td class="data-date">' . get_post_time( get_option( 'date_format' ), false, $event ) . '</td>';
|
||||
echo '<td class="data-date">' . get_post_time( get_option( 'date_format' ), false, $event ) . '</td>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'event', $usecolumns ) )
|
||||
$output .= '<td class="data-event">' . $event->post_title . '</td>';
|
||||
echo '<td class="data-event">' . $event->post_title . '</td>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'teams', $usecolumns ) ):
|
||||
$output .= '<td class="data-teams">';
|
||||
echo '<td class="data-teams">';
|
||||
|
||||
$teams = get_post_meta( $event->ID, 'sp_team', false );
|
||||
if ( $teams ):
|
||||
@@ -55,8 +69,8 @@ foreach ( $data as $event ):
|
||||
if ( $name ):
|
||||
$team_results = sportspress_array_value( $results, $team, null );
|
||||
|
||||
if ( $main_result ):
|
||||
$team_result = sportspress_array_value( $team_results, $main_result, null );
|
||||
if ( $primary_result ):
|
||||
$team_result = sportspress_array_value( $team_results, $primary_result, null );
|
||||
else:
|
||||
if ( is_array( $team_results ) ):
|
||||
end( $team_results );
|
||||
@@ -66,56 +80,61 @@ foreach ( $data as $event ):
|
||||
endif;
|
||||
endif;
|
||||
|
||||
$output .= $name;
|
||||
echo $name;
|
||||
|
||||
if ( $team_result != null ):
|
||||
$output .= ' (' . $team_result . ')';
|
||||
echo ' (' . $team_result . ')';
|
||||
endif;
|
||||
|
||||
$output .= '<br>';
|
||||
echo '<br>';
|
||||
endif;
|
||||
endforeach;
|
||||
else:
|
||||
$output .= '—';
|
||||
echo '—';
|
||||
endif;
|
||||
|
||||
$output .= '</td>';
|
||||
echo '</td>';
|
||||
endif;
|
||||
|
||||
if ( $usecolumns == null || in_array( 'time', $usecolumns ) )
|
||||
$output .= '<td class="data-time">' . get_post_time( get_option( 'time_format' ), false, $event ) . '</td>';
|
||||
echo '<td class="data-time">' . get_post_time( get_option( 'time_format' ), false, $event ) . '</td>';
|
||||
|
||||
if ( $usecolumns == null || in_array( 'venue', $usecolumns ) ):
|
||||
echo '<td class="data-venue">';
|
||||
the_terms( $event->ID, 'sp_venue' );
|
||||
echo '</td>';
|
||||
endif;
|
||||
|
||||
if ( $usecolumns == null || in_array( 'article', $usecolumns ) ):
|
||||
$output .= '<td class="data-article">
|
||||
echo '<td class="data-article">
|
||||
<a href="' . get_permalink( $event->ID ) . '">';
|
||||
|
||||
if ( $video ):
|
||||
$output .= '<div class="dashicons dashicons-video-alt"></div>';
|
||||
echo '<div class="dashicons dashicons-video-alt"></div>';
|
||||
elseif ( has_post_thumbnail( $event->ID ) ):
|
||||
$output .= '<div class="dashicons dashicons-camera"></div>';
|
||||
echo '<div class="dashicons dashicons-camera"></div>';
|
||||
endif;
|
||||
if ( $event->post_content !== null ):
|
||||
if ( $event->post_status == 'publish' ):
|
||||
$output .= SP()->text->string('Recap', 'event');
|
||||
echo SP()->text->string('Recap', 'event');
|
||||
else:
|
||||
$output .= SP()->text->string('Preview', 'event');
|
||||
echo SP()->text->string('Preview', 'event');
|
||||
endif;
|
||||
endif;
|
||||
|
||||
$output .= '</a>
|
||||
echo '</a>
|
||||
</td>';
|
||||
endif;
|
||||
|
||||
$output .= '</tr>';
|
||||
echo '</tr>';
|
||||
|
||||
$i++;
|
||||
endforeach;
|
||||
|
||||
$output .= '</tbody>' . '</table>';
|
||||
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php
|
||||
if ( $id && $show_all_events_link )
|
||||
$output .= '<a class="sp-calendar-link" href="' . get_permalink( $id ) . '">' . SP()->text->string('View all events', 'event') . '</a>';
|
||||
|
||||
$output .= '</div>';
|
||||
|
||||
echo apply_filters( 'sportspress_event_list', $output );
|
||||
echo '<a class="sp-calendar-link" href="' . get_permalink( $id ) . '">' . SP()->text->string('View all events', 'event') . '</a>';
|
||||
?>
|
||||
</div>
|
||||
Reference in New Issue
Block a user