コード例 #1
0
function sp_get_main_results_or_time($post = 0)
{
    $results = sp_get_main_results($post);
    if (sizeof($results)) {
        return $results;
    } else {
        return array(sp_get_time($post));
    }
}
コード例 #2
0
ファイル: event-list.php プロジェクト: kleitz/ProSports
                     echo '<td class="data-results"><a href="' . get_permalink($event->ID) . '">';
                     if (!empty($main_results)) {
                         echo implode(' - ', $main_results);
                     } else {
                         echo '-';
                     }
                     echo '</a></td>';
                 }
                 break;
             default:
                 if (sp_column_active($usecolumns, 'time')) {
                     echo '<td class="data-time"><a href="' . get_permalink($event->ID) . '">';
                     if (!empty($main_results)) {
                         echo implode(' - ', $main_results);
                     } else {
                         echo '<date>&nbsp;' . get_post_time('H:i:s', false, $event) . '</date>' . sp_get_time($event);
                     }
                     echo '</a></td>';
                 }
         }
 }
 if (sp_column_active($usecolumns, 'league')) {
     echo '<td class="data-league">';
     $leagues = get_the_terms($event->ID, 'sp_league');
     if ($leagues) {
         foreach ($leagues as $league) {
             echo $league->name;
         }
     }
     echo '</td>';
 }
コード例 #3
0
}
?>
						<time class="sp-event-date" datetime="<?php 
echo get_the_time('Y-m-d H:i:s');
?>
">
							<?php 
echo get_the_time(get_option('date_format'));
?>
						</time>
						<?php 
if ($show_time) {
    ?>
							<h5 class="sp-event-results">
								<?php 
    echo '<span class="sp-result">' . apply_filters('sportspress_event_time', sp_get_time($id), $id) . '</span>';
    ?>
							</h5>
							<?php 
    $status = __('Preview', 'sportspress');
}
if ($show_results && !empty($results)) {
    ?>
							<h5 class="sp-event-results">
								<?php 
    echo '<span class="sp-result">' . implode('</span> - <span class="sp-result">', apply_filters('sportspress_event_blocks_team_result_or_time', $results, $id)) . '</span>';
    ?>
							</h5>
							<?php 
    $status = __('Full Time', 'sportspress');
}
コード例 #4
0
ファイル: event-list.php プロジェクト: krmkrl/SportsPress
                     if ($link_events) {
                         echo '</a>';
                     }
                     echo '</td>';
                 }
                 break;
             default:
                 if (sp_column_active($usecolumns, 'time')) {
                     echo '<td class="data-time">';
                     if ($link_events) {
                         echo '<a href="' . get_post_permalink($event->ID, false, true) . '">';
                     }
                     if (!empty($main_results)) {
                         echo implode(' - ', $main_results);
                     } else {
                         echo '<date>&nbsp;' . get_post_time('H:i:s', false, $event) . '</date>' . apply_filters('sportspress_event_time', sp_get_time($event), $event->ID);
                     }
                     if ($link_events) {
                         echo '</a>';
                     }
                     echo '</td>';
                 }
         }
 }
 if (sp_column_active($usecolumns, 'league')) {
     echo '<td class="data-league">';
     $leagues = get_the_terms($event->ID, 'sp_league');
     if ($leagues) {
         foreach ($leagues as $league) {
             echo $league->name;
         }
コード例 #5
0
    /**
     * Admin edit table
     */
    public static function table($labels = array(), $data = null, $rounds = 3, $rows = 23, $post_id = null)
    {
        $args = array('post_type' => 'sp_team', 'posts_per_page' => -1, 'tax_query' => array());
        // Filter by league if selected
        $leagues = get_the_terms($post_id, 'sp_league', 0);
        if ($leagues && !is_wp_error($leagues)) {
            // Get league IDs
            $league_ids = array();
            foreach ($leagues as $league) {
                $league_ids[] = $league->term_id;
            }
            $args['tax_query'][] = array('taxonomy' => 'sp_league', 'field' => 'id', 'terms' => $league_ids);
        }
        // Filter by season if selected
        $seasons = get_the_terms($post_id, 'sp_season', 0);
        if ($seasons && !is_wp_error($seasons)) {
            // Get seasons IDs
            $season_ids = array();
            foreach ($seasons as $seasons) {
                $season_ids[] = $seasons->term_id;
            }
            $args['tax_query'][] = array('taxonomy' => 'sp_season', 'field' => 'id', 'terms' => $season_ids);
        }
        // Get teams
        $teams = get_posts($args);
        ?>
		<table class="widefat sp-tournament-container">
			<thead>
				<tr>
					<?php 
        for ($round = 0; $round < $rounds; $round++) {
            ?>
						<th>
							<input type="text" class="widefat" name="sp_labels[]" value="<?php 
            echo esc_attr(sp_array_value($labels, $round, ''));
            ?>
" placeholder="<?php 
            printf(esc_attr__('Round %s', 'sportspress'), $round + 1);
            ?>
">
						</th>
					<?php 
        }
        ?>
				</tr>
			</thead>
			<tbody>
				<?php 
        for ($row = 0; $row < $rows; $row++) {
            ?>
					<tr>
						<?php 
            for ($round = 0; $round < $rounds; $round++) {
                $cell = sp_array_value(sp_array_value($data, $row, array()), $round, null);
                if ($cell === null) {
                    continue;
                }
                $index = sp_array_value($cell, 'index');
                if (sp_array_value($cell, 'type', null) === 'event') {
                    $event = sp_array_value($cell, 'id', 0);
                    if ($event) {
                        $results = sp_get_main_results($event);
                    } else {
                        $results = null;
                    }
                    ?>
								<td rowspan="<?php 
                    echo sp_array_value($cell, 'rows', 1);
                    ?>
" class="sp-event<?php 
                    if (0 === $round) {
                        ?>
 sp-first-round<?php 
                    }
                    if ($rounds - 1 === $round) {
                        ?>
 sp-last-round<?php 
                    }
                    ?>
">
									<input type="hidden" name="sp_event[<?php 
                    echo $index;
                    ?>
][id]" value="<?php 
                    echo $event ? $event : 0;
                    ?>
">
									<label><?php 
                    _e('Date', 'sportspress');
                    ?>
:</label>
									<?php 
                    if ($event) {
                        ?>
										<a title="<?php 
                        _e('Edit Event', 'sportspress');
                        ?>
" class="sp-edit sp-desc-tip dashicons dashicons-edit" href="<?php 
                        echo get_edit_post_link($event, '');
                        ?>
" target="_blank"></a>
									<?php 
                    }
                    ?>
									<input type="text" class="sp-datepicker" name="sp_event[<?php 
                    echo $index;
                    ?>
][date]" value="<?php 
                    if ($event) {
                        echo sp_get_time($event, 'Y-m-d');
                    }
                    ?>
" size="10" autocomplete="off"><hr>
									<label><?php 
                    _e('Time', 'sportspress');
                    ?>
:</label>
									<input type="text" size="2" maxlength="2" name="sp_event[<?php 
                    echo $index;
                    ?>
][hh]" autocomplete="off" value="<?php 
                    if ($event) {
                        echo sp_get_time($event, 'H');
                    }
                    ?>
">
									:
									<input type="text" size="2" maxlength="2" name="sp_event[<?php 
                    echo $index;
                    ?>
][mm]" autocomplete="off" value="<?php 
                    if ($event) {
                        echo sp_get_time($event, 'i');
                    }
                    ?>
"><hr>
									<label><?php 
                    _e('Results', 'sportspress');
                    ?>
:</label>
									<input type="text" size="2" name="sp_event[<?php 
                    echo $index;
                    ?>
][results][]" value="<?php 
                    echo sp_array_value($results, 0);
                    ?>
" autocomplete="off">
									-
									<input type="text" size="2" name="sp_event[<?php 
                    echo $index;
                    ?>
][results][]" value="<?php 
                    echo sp_array_value($results, 1);
                    ?>
" autocomplete="off">
								</td>
								<?php 
                } elseif (sp_array_value($cell, 'type', null) === 'team') {
                    $select = sp_array_value($cell, 'select', false);
                    $team = sp_array_value($cell, 'id', 0);
                    echo '<td rowspan="' . sp_array_value($cell, 'rows', 1) . '" class="sp-team' . ($round === 0 ? ' sp-first-round' : '') . ($round === $rounds - 1 ? ' sp-last-round' : '') . '">';
                    if ($select) {
                        self::dropdown($teams, $index, $team);
                    } else {
                        echo '<input type="hidden" name="sp_event[' . $index . '][teams][]" value="' . $team . '">';
                        echo '<input type="text" readonly="readonly" class="widefat sp-team-display" value="' . get_the_title($team) . '">';
                    }
                    echo '</td>';
                } else {
                    echo '<td rowspan="' . sp_array_value($cell, 'rows', 1) . '">&nbsp;</td>';
                }
            }
            ?>
					</tr>
				<?php 
        }
        ?>
			</tbody>
		</table>
		<?php 
    }