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
?>
				</tr>
			</thead>
			<tbody>
				<?php 
$i = 0;
if (is_numeric($number) && $number > 0) {
    $limit = $number;
}
foreach ($data as $event) {
    if (isset($limit) && $i >= $limit) {
        continue;
    }
    $teams = get_post_meta($event->ID, 'sp_team');
    $video = get_post_meta($event->ID, 'sp_video', true);
    $main_results = sp_get_main_results($event);
    $teams_output = '';
    $teams_array = array();
    $team_logos = array();
    if ($teams) {
        foreach ($teams as $team) {
            $name = get_the_title($team);
            if ($name) {
                if ($show_team_logo) {
                    $name = sp_get_logo($team, 'mini') . ' ' . $name;
                    $team_logos[] = sp_get_logo($team, 'mini');
                }
                if ($link_teams) {
                    $team_output = '<a href="' . get_post_permalink($team) . '">' . $name . '</a>';
                } else {
                    $team_output = $name;
예제 #3
0
?>
				</tr>
			</thead>
			<tbody>
				<?php 
$i = 0;
if (is_numeric($number) && $number > 0) {
    $limit = $number;
}
foreach ($data as $event) {
    if (isset($limit) && $i >= $limit) {
        continue;
    }
    $teams = get_post_meta($event->ID, 'sp_team');
    $video = get_post_meta($event->ID, 'sp_video', true);
    $main_results = apply_filters('sportspress_event_list_main_results', sp_get_main_results($event), $event->ID);
    $teams_output = '';
    $teams_array = array();
    $team_logos = array();
    if ($teams) {
        foreach ($teams as $team) {
            $name = get_the_title($team);
            if ($name) {
                if ($show_team_logo) {
                    $name = sp_get_logo($team, 'mini') . ' ' . $name;
                    $team_logos[] = sp_get_logo($team, 'mini');
                }
                if ($link_teams) {
                    $team_output = '<a href="' . get_post_permalink($team) . '">' . $name . '</a>';
                } else {
                    $team_output = $name;
예제 #4
0
 * @version     1.9
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
if (get_option('sportspress_event_show_logos', 'yes') === 'no') {
    return;
}
$show_team_names = get_option('sportspress_event_logos_show_team_names', 'no') === 'yes' ? true : false;
$show_results = get_option('sportspress_event_logos_show_results', 'no') === 'yes' ? true : false;
if (!isset($id)) {
    $id = get_the_ID();
}
if ($show_results) {
    $results = sp_get_main_results($id);
    if (empty($results)) {
        $show_results = false;
    }
}
$teams = get_post_meta($id, 'sp_team');
$teams = array_filter($teams, 'sp_filter_positive');
if ($teams) {
    $team_logos = array();
    $i = 0;
    foreach ($teams as $team) {
        if (!has_post_thumbnail($team)) {
            continue;
        }
        $logo = get_the_post_thumbnail($team, 'sportspress-fit-icon');
        $alt = sizeof($teams) == 2 && $i % 2;
    /**
     * 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 
    }