function match_title($title, $id = null)
{
    if (get_post_type($id) == 'wpcm_match') {
        $default_club = get_default_club();
        $title_format = get_match_title_format();
        $separator = get_option('wpcm_match_clubs_separator');
        $home_id = (int) get_post_meta($id, 'wpcm_home_club', true);
        $away_id = (int) get_post_meta($id, 'wpcm_away_club', true);
        $home_club = get_post($home_id);
        $away_club = get_post($away_id);
        if ($title_format == '%home% vs %away%') {
            $side1 = wpcm_get_team_name($home_club, $id);
            $side2 = wpcm_get_team_name($away_club, $id);
        } else {
            $side1 = wpcm_get_team_name($away_club, $id);
            $side2 = wpcm_get_team_name($home_club, $id);
        }
        $title = $side1 . ' ' . $separator . ' ' . $side2;
        return $title;
    }
    return $title;
}
 public function wp_insert_post_data($data, $postarr)
 {
     if ($data['post_type'] == 'wpcm_match' && $data['post_title'] == '') {
         $default_club = get_default_club();
         $title_format = get_match_title_format();
         $separator = get_option('wpcm_match_clubs_separator');
         $home_id = $_POST['wpcm_home_club'];
         $away_id = $_POST['wpcm_away_club'];
         $home_club = get_post($home_id);
         $away_club = get_post($away_id);
         if ($title_format == '%home% vs %away%') {
             $side1 = wpcm_get_team_name($home_club, $postarr['ID']);
             $side2 = wpcm_get_team_name($away_club, $postarr['ID']);
         } else {
             $side1 = wpcm_get_team_name($away_club, $postarr['ID']);
             $side2 = wpcm_get_team_name($home_club, $postarr['ID']);
         }
         $title = $side1 . ' ' . $separator . ' ' . $side2;
         $post_name = sanitize_title_with_dashes($postarr['ID'] . '-' . $title);
         $data['post_title'] = $title;
         $data['post_name'] = $post_name;
     }
     return $data;
 }
    foreach ($comps as $comp) {
        echo '<span>' . $comp->name . '&nbsp;' . $comp_status . '</span>';
    }
    echo '</div>';
}
echo '</div>';
echo '<a href="' . get_permalink($postid) . '">';
echo '<div class="clubs">';
echo '<h4 class="home-clubs">';
echo '<div class="home-logo">' . $crest1 . '</div>';
echo wpcm_get_team_name($side1, $postid);
echo '<div class="score">' . ($played ? $goals1 : '') . '</div>';
echo '</h4>';
echo '<h4 class="away-clubs">';
echo '<div class="away-logo">' . $crest2 . '</div>';
echo wpcm_get_team_name($side2, $postid);
echo '<div class="score">' . ($played ? $goals2 : '') . '</div>';
echo '</h4>';
echo '</div>';
echo '</a>';
echo '<div class="wpcm-date">';
echo '<div class="kickoff">';
if ($show_date) {
    echo the_time('j M Y');
}
if ($show_time) {
    echo ' - ';
    echo the_time('g:i a');
}
echo '</div>';
echo '</div>';
        /**
         * Show status widget
         */
        public function upcoming_matches_widget()
        {
            $club = get_default_club();
            $format = get_match_title_format();
            $year = date('Y');
            $week = date('W');
            // get matches
            $query_args = array('numberposts' => '-1', 'order' => 'ASC', 'orderby' => 'post_date', 'post_type' => 'wpcm_match', 'post_status' => array('future'), 'posts_per_page' => '-1', 'date_query' => array(array('year' => $year, 'week' => $week)));
            $query_args['meta_query'] = array('relation' => 'OR', array('key' => 'wpcm_home_club', 'value' => $club), array('key' => 'wpcm_away_club', 'value' => $club));
            $matches = get_posts($query_args);
            ?>

		<ul class="wpcm-matches-list">
		
		<?php 
            if ($matches) {
                foreach ($matches as $match) {
                    $home_club = get_post_meta($match->ID, 'wpcm_home_club', true);
                    $away_club = get_post_meta($match->ID, 'wpcm_away_club', true);
                    $timestamp = strtotime($match->post_date);
                    $time_format = get_option('time_format');
                    $neutral = get_post_meta($match->ID, 'wpcm_neutral', true);
                    $comps = get_the_terms($match->ID, 'wpcm_comp');
                    $comp_status = get_post_meta($match->ID, 'wpcm_comp_status', true);
                    $separator = get_option('wpcm_match_clubs_separator');
                    if ($format == '%home% vs %away%') {
                        $side1 = $home_club;
                        $side2 = $away_club;
                    } else {
                        $side1 = $away_club;
                        $side2 = $home_club;
                    }
                    if (is_array($comps)) {
                        foreach ($comps as $comp) {
                            $comp = reset($comps);
                            $t_id = $comp->term_id;
                            $comp_meta = get_option("taxonomy_term_{$t_id}");
                            $comp_label = $comp_meta['wpcm_comp_label'];
                            $competition = $comp->name . '&nbsp;' . $comp_status;
                        }
                    }
                    ?>

				<li class="wpcm-matches-list-item">

					<div class="wpcm-matches-list-link">
				
						<span class="wpcm-matches-list-col wpcm-matches-list-club1">
							<?php 
                    if ($club == $side1) {
                        echo '<strong>';
                    }
                    echo wpcm_get_team_name($side1, $match->ID);
                    if ($club == $side1) {
                        echo '</strong>';
                    }
                    ?>
						</span>

						<span class="wpcm-matches-list-col wpcm-matches-list-status">
							<span class="wpcm-matches-list-sep">
								<?php 
                    echo $separator;
                    ?>
							</span>
						</span>

						<span class="wpcm-matches-list-col wpcm-matches-list-club2">
							<?php 
                    if ($club == $side2) {
                        echo '<strong>';
                    }
                    echo wpcm_get_team_name($side2, $match->ID);
                    if ($club == $side2) {
                        echo '</strong>';
                    }
                    ?>
						</span>

					</div>

					<a href="<?php 
                    echo get_edit_post_link($match->ID);
                    ?>
" class="wpcm-matches-list-additional">

						<span class="wpcm-matches-list-additional-col wpcm-matches-list-date">
							<?php 
                    echo date_i18n('l jS F', $timestamp);
                    ?>
						</span>

						<span class="wpcm-matches-list-additional-col wpcm-matches-list-status">
							<span class="wpcm-matches-list-time">
								<?php 
                    echo date_i18n($time_format, $timestamp);
                    ?>
							</span>
						</span>

						<span class="wpcm-matches-list-additional-col wpcm-matches-list-info">
							<?php 
                    echo $competition;
                    ?>
						</span>

					</a>
				
				</li>

			<?php 
                }
            } else {
                ?>

			<li><?php 
                _e('No upcoming matches.', 'wp-club-manager');
                ?>
</li>

		<?php 
            }
            wp_reset_postdata();
            ?>

		</ul>

		<div class="add-new-match-link">
			<a class="button btn" href="post-new.php?post_type=wpcm_match"><?php 
            _e('Add New Match', 'wp-club-manager');
            ?>
</a>
		</div>

	<?php 
        }
<?php

/**
 * Single Match - Away Club
 *
 * @author 		ClubPress
 * @package 	WPClubManager/Templates
 * @version     1.3.0
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
global $wpclubmanager, $post;
$format = get_match_title_format();
$home_club = get_post_meta($post->ID, 'wpcm_home_club', true);
$away_club = get_post_meta($post->ID, 'wpcm_away_club', true);
if ($format == '%home% vs %away%') {
    $side2 = wpcm_get_team_name($away_club, $post->ID);
} else {
    $side2 = wpcm_get_team_name($home_club, $post->ID);
}
?>

<div class="wpcm-match-away-club">

	<?php 
echo $side2;
?>

</div>
<?php

/**
 * Single Match - Home Club
 *
 * @author 		ClubPress
 * @package 	WPClubManager/Templates
 * @version     1.3.0
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
global $wpclubmanager, $post;
$format = get_match_title_format();
$home_club = get_post_meta($post->ID, 'wpcm_home_club', true);
$away_club = get_post_meta($post->ID, 'wpcm_away_club', true);
if ($format == '%home% vs %away%') {
    $side1 = wpcm_get_team_name($home_club, $post->ID);
} else {
    $side1 = wpcm_get_team_name($away_club, $post->ID);
}
?>

<div class="wpcm-match-home-club">

	<?php 
echo $side1;
?>

</div>
    function wpcm_head_to_heads($post)
    {
        $club = get_default_club();
        // get matches
        $query_args = array('numberposts' => '-1', 'order' => 'ASC', 'orderby' => 'post_date', 'post_type' => 'wpcm_match', 'post_status' => array('publish'), 'posts_per_page' => '-1');
        $query_args['meta_query'] = array('relation' => 'OR', array('relation' => 'AND', array('key' => 'wpcm_home_club', 'value' => $club), array('key' => 'wpcm_away_club', 'value' => $post)), array('relation' => 'AND', array('key' => 'wpcm_home_club', 'value' => $post), array('key' => 'wpcm_away_club', 'value' => $club)));
        $matches = get_posts($query_args);
        $size = count($matches);
        if ($size > 0) {
            $wins = 0;
            $losses = 0;
            $draws = 0;
            foreach ($matches as $match) {
                $home_club = get_post_meta($match->ID, 'wpcm_home_club', true);
                $home_goals = get_post_meta($match->ID, 'wpcm_home_goals', true);
                $away_goals = get_post_meta($match->ID, 'wpcm_away_goals', true);
                if ($home_goals == $away_goals) {
                    $draws++;
                }
                if ($club == $home_club) {
                    if ($home_goals > $away_goals) {
                        $wins++;
                    }
                    if ($home_goals < $away_goals) {
                        $losses++;
                    }
                } else {
                    if ($home_goals > $away_goals) {
                        $losses++;
                    }
                    if ($home_goals < $away_goals) {
                        $wins++;
                    }
                }
            }
            ?>

			<ul class="wpcm-h2h-list">
				<li class="wpcm-h2h-list-p">
					<span class="wpcm-h2h-list-count"><?php 
            echo $size;
            ?>
</span> <span class="wpcm-h2h-list-desc">games</span>
				</li>
				<li class="wpcm-h2h-list-w">
					<span class="wpcm-h2h-list-count"><?php 
            echo $wins;
            ?>
</span> <span class="wpcm-h2h-list-desc">wins</span>
				</li>
				<li class="wpcm-h2h-list-d">
					<span class="wpcm-h2h-list-count"><?php 
            echo $draws;
            ?>
</span> <span class="wpcm-h2h-list-desc">draws</span>
				</li>
				<li class="wpcm-h2h-list-l">
					<span class="wpcm-h2h-list-count"><?php 
            echo $losses;
            ?>
</span> <span class="wpcm-h2h-list-desc">losses</span>
				</li>
			</ul>

			<ul class="wpcm-matches-list">

			<?php 
            foreach ($matches as $match) {
                $sport = get_option('wpcm_sport');
                $home_club = get_post_meta($match->ID, 'wpcm_home_club', true);
                $away_club = get_post_meta($match->ID, 'wpcm_away_club', true);
                $home_goals = get_post_meta($match->ID, 'wpcm_home_goals', true);
                $away_goals = get_post_meta($match->ID, 'wpcm_away_goals', true);
                if ($sport == 'gaelic') {
                    $home_gaa_goals = get_post_meta($match->ID, 'wpcm_home_gaa_goals', true);
                    $home_gaa_points = get_post_meta($match->ID, 'wpcm_home_gaa_points', true);
                    $away_gaa_goals = get_post_meta($match->ID, 'wpcm_away_gaa_goals', true);
                    $away_gaa_points = get_post_meta($match->ID, 'wpcm_away_gaa_points', true);
                }
                $played = get_post_meta($match->ID, 'wpcm_played', true);
                $timestamp = strtotime($match->post_date);
                $time_format = get_option('time_format');
                $neutral = get_post_meta($match->ID, 'wpcm_neutral', true);
                $comps = get_the_terms($match->ID, 'wpcm_comp');
                $comp_status = get_post_meta($match->ID, 'wpcm_comp_status', true);
                if ($home_goals == $away_goals) {
                    $class = 'draw';
                }
                if ($club == $home_club) {
                    if ($home_goals > $away_goals) {
                        $class = 'win';
                    }
                    if ($home_goals < $away_goals) {
                        $class = 'loss';
                    }
                } else {
                    if ($home_goals > $away_goals) {
                        $class = 'loss';
                    }
                    if ($home_goals < $away_goals) {
                        $class = 'win';
                    }
                }
                if (is_array($comps)) {
                    foreach ($comps as $comp) {
                        $comp = reset($comps);
                        $t_id = $comp->term_id;
                        $comp_meta = get_option("taxonomy_term_{$t_id}");
                        $comp_label = $comp_meta['wpcm_comp_label'];
                        if ($comp_label) {
                            $info = $comp_label . '&nbsp;' . $comp_status;
                        } else {
                            $info = $comp->name . '&nbsp;' . $comp_status;
                        }
                    }
                }
                if ($played) {
                    if ($sport == 'gaelic') {
                        $status = '<span class="wpcm-matches-list-result">' . ($played ? $home_gaa_goals . '-' . $home_gaa_points . ' ' . get_option('wpcm_match_goals_delimiter') . ' ' . $away_gaa_goals . '-' . $away_gaa_points : '') . '</span>';
                    } else {
                        $status = '<span class="wpcm-matches-list-result">' . ($played ? $home_goals . ' ' . get_option('wpcm_match_goals_delimiter') . ' ' . $away_goals : '') . '</span>';
                    }
                } else {
                    $status = '<span class="wpcm-matches-list-time">' . date_i18n($time_format, $timestamp) . '</span>';
                }
                ?>


				<li class="wpcm-matches-list-item"><a href="<?php 
                echo get_post_permalink($match->ID, false, true);
                ?>
" class="wpcm-matches-list-link">
				
				<span class="wpcm-matches-list-col wpcm-matches-list-date"><?php 
                echo date_i18n('d M Y', $timestamp);
                ?>
</span>

				<span class="wpcm-matches-list-col wpcm-matches-list-club1"><?php 
                echo wpcm_get_team_name($home_club, $match->ID);
                ?>
</span>

				<span class="wpcm-matches-list-col wpcm-matches-list-status">
					<span class="wpcm-matches-list-result <?php 
                echo $class;
                ?>
">
						<?php 
                echo $status;
                ?>
					</span>
				</span>

				<span class="wpcm-matches-list-col wpcm-matches-list-club2"><?php 
                echo wpcm_get_team_name($away_club, $match->ID);
                ?>
</span>

				<span class="wpcm-matches-list-col wpcm-matches-list-info"><?php 
                echo $info;
                ?>
</span>

				</a></li>
			<?php 
            }
            ?>

			</ul>

		<?php 
        }
    }
    /**
     * Output the standings shortcode.
     *
     * @param array $atts
     */
    public static function output($atts)
    {
        extract(shortcode_atts(array(), $atts));
        $type = isset($atts['type']) ? $atts['type'] : '1';
        $title = isset($atts['title']) ? $atts['title'] : __('Fixtures & Results', 'wp-club-manager');
        $comp = isset($atts['comp']) ? $atts['comp'] : null;
        $season = isset($atts['season']) ? $atts['season'] : null;
        $team = isset($atts['team']) ? $atts['team'] : null;
        $month = isset($atts['month']) ? $atts['month'] : null;
        $venue = isset($atts['venue']) ? $atts['venue'] : null;
        $thumb = isset($atts['thumb']) ? $atts['thumb'] : null;
        $link_club = isset($atts['link_club']) ? $atts['link_club'] : null;
        $linktext = isset($atts['linktext']) ? $atts['linktext'] : __('View all results', 'wp-club-manager');
        $linkpage = isset($atts['linkpage']) ? $atts['linkpage'] : null;
        if ($comp <= 0) {
            $comp = null;
        }
        // if ( $season <= 0  )
        // 	$season = null;
        // if ( $team <= 0  )
        // 	$team = null;
        // if ( $venue <= 0  )
        // 	$venue = null;
        $club = get_default_club();
        // get matches
        $query_args = array('tax_query' => array(), 'numberposts' => '-1', 'order' => 'ASC', 'orderby' => 'post_date', 'post_type' => 'wpcm_match', 'post_status' => array('publish', 'future'), 'posts_per_page' => '-1');
        if (isset($club)) {
            $query_args['meta_query'] = array('relation' => 'OR', array('key' => 'wpcm_home_club', 'value' => $club), array('key' => 'wpcm_away_club', 'value' => $club));
        }
        if (isset($comp)) {
            $query_args['tax_query'][] = array('taxonomy' => 'wpcm_comp', 'terms' => $comp, 'field' => 'term_id');
        }
        if (isset($season)) {
            $query_args['tax_query'][] = array('taxonomy' => 'wpcm_season', 'terms' => $season, 'field' => 'term_id');
        }
        if (isset($team)) {
            $query_args['tax_query'][] = array('taxonomy' => 'wpcm_team', 'terms' => $team, 'field' => 'term_id');
        }
        if (isset($venue)) {
            $query_args['tax_query'][] = array('taxonomy' => 'wpcm_venue', 'terms' => $venue, 'field' => 'term_id');
        }
        if (isset($month)) {
            $query_args['date_query'] = array('month' => $month);
        }
        $matches = get_posts($query_args);
        ?>

		<?php 
        if ($matches) {
            if ($type == '2') {
                if ($title) {
                    echo '<h3>' . $title . '</h3>';
                }
                ?>

					<ul class="wpcm-matches-list">

			<?php 
            } else {
                ?>

				<div class="cp-table-wrap wpcm-fixtures-shortcode">

				<table class="cp-table cp-table-full">

				<?php 
                if ($title) {
                    echo '<caption>' . $title . '</caption>';
                }
                ?>

				<thead>
						
					<tr>
						<th class="wpcm-date"><?php 
                _e('Date', 'wp-club-manager');
                ?>
</th>
						<th class="venue"><?php 
                _e('Venue', 'wp-club-manager');
                ?>
</th>
						<?php 
                if ($thumb == '1') {
                    ?>
							<th class="club-thumb">&nbsp;</th>
						<?php 
                }
                ?>
						<th class="opponent"><?php 
                _e('Opponent', 'wp-club-manager');
                ?>
</th>
						<th class="competition"><?php 
                _e('Competition', 'wp-club-manager');
                ?>
</th>
						<th class="result"><?php 
                _e('Result', 'wp-club-manager');
                ?>
</th>
					</tr>

				</thead>
				<tbody>
			<?php 
            }
        } else {
            ?>

			<p><?php 
            _e('No matches played yet.', 'wp-club-manager');
            ?>
</p>

		<?php 
        }
        if ($matches) {
            foreach ($matches as $match) {
                // Get match data
                $sport = get_option('wpcm_sport');
                $format = get_match_title_format();
                $home_club = get_post_meta($match->ID, 'wpcm_home_club', true);
                $away_club = get_post_meta($match->ID, 'wpcm_away_club', true);
                $home_goals = get_post_meta($match->ID, 'wpcm_home_goals', true);
                $away_goals = get_post_meta($match->ID, 'wpcm_away_goals', true);
                if ($sport == 'gaelic') {
                    $home_gaa_goals = get_post_meta($match->ID, 'wpcm_home_gaa_goals', true);
                    $home_gaa_points = get_post_meta($match->ID, 'wpcm_home_gaa_points', true);
                    $away_gaa_goals = get_post_meta($match->ID, 'wpcm_away_gaa_goals', true);
                    $away_gaa_points = get_post_meta($match->ID, 'wpcm_away_gaa_points', true);
                }
                $played = get_post_meta($match->ID, 'wpcm_played', true);
                $timestamp = strtotime($match->post_date);
                $time_format = get_option('time_format');
                $neutral = get_post_meta($match->ID, 'wpcm_neutral', true);
                $comps = get_the_terms($match->ID, 'wpcm_comp');
                $comp_status = get_post_meta($match->ID, 'wpcm_comp_status', true);
                $match_link = get_post_permalink($match->ID, false, true);
                // Display Badge
                if ($thumb == '1') {
                    if (has_post_thumbnail($home_club)) {
                        $home_crest = '<td class="club-thumb">' . get_the_post_thumbnail($home_club, 'crest-small') . '</td>';
                    } else {
                        $home_crest = '<td class="club-thumb">' . wpcm_crest_placeholder_img('crest-small') . '</td>';
                    }
                    if (has_post_thumbnail($away_club)) {
                        $away_crest = '<td class="club-thumb">' . get_the_post_thumbnail($away_club, 'crest-small') . '</td>';
                    } else {
                        $away_crest = '<td class="club-thumb">' . wpcm_crest_placeholder_img('crest-small') . '</td>';
                    }
                } else {
                    $home_crest = '';
                    $away_crest = '';
                }
                // Display Outcome
                if ($home_goals == $away_goals) {
                    $outcome = '<span class="draw"></span>';
                    $class = 'draw';
                }
                if ($club == $home_club) {
                    if ($home_goals > $away_goals) {
                        $outcome = '<span class="win"></span>';
                        $class = 'win';
                    }
                    if ($home_goals < $away_goals) {
                        $outcome = '<span class="lose"></span>';
                        $class = 'loss';
                    }
                } else {
                    if ($home_goals > $away_goals) {
                        $outcome = '<span class="lose"></span>';
                        $class = 'loss';
                    }
                    if ($home_goals < $away_goals) {
                        $outcome = '<span class="win"></span>';
                        $class = 'win';
                    }
                }
                // Display venue and opponent
                if ($type == '1' && $club == $home_club) {
                    if ($neutral) {
                        $venue = __('N', 'wp-club-manager');
                    } else {
                        $venue = __('H', 'wp-club-manager');
                    }
                    $opponent = ($link_club ? '<a href="' . get_post_permalink($away_club, false, true) . '">' : '') . '' . get_the_title($away_club, true) . '' . ($link_club ? '</a>' : '');
                    $crest = $away_crest;
                } elseif ($type == '1' && $club == $away_club) {
                    if ($neutral) {
                        $venue = __('N', 'wp-club-manager');
                    } else {
                        $venue = __('A', 'wp-club-manager');
                    }
                    $opponent = ($link_club ? '<a href="' . get_post_permalink($home_club, false, true) . '">' : '') . '' . get_the_title($home_club, true) . '' . ($link_club ? '</a>' : '');
                    $crest = $home_crest;
                }
                // Display competition
                if (is_array($comps)) {
                    foreach ($comps as $comp) {
                        $comp = reset($comps);
                        $t_id = $comp->term_id;
                        $comp_meta = get_option("taxonomy_term_{$t_id}");
                        $comp_label = $comp_meta['wpcm_comp_label'];
                        if ($comp_label) {
                            $competition = $comp_label . '&nbsp;' . $comp_status;
                        } else {
                            $competition = $comp->name . '&nbsp;' . $comp_status;
                        }
                    }
                }
                // Display result - match.php Template
                if (get_option('wpcm_hide_scores') == 'yes' && !is_user_logged_in()) {
                    $result = $played ? __('x', 'wp-club-manager') . ' ' . get_option('wpcm_match_goals_delimiter') . ' ' . __('x', 'wp-club-manager') : '';
                } else {
                    if ($sport == 'gaelic') {
                        $result = ($played ? $home_gaa_goals . '-' . $home_gaa_points . ' ' . get_option('wpcm_match_goals_delimiter') . ' ' . $away_gaa_goals . '-' . $away_gaa_points : '') . ' ' . ($played ? $outcome : '');
                    } else {
                        $result = ($played ? $home_goals . ' ' . get_option('wpcm_match_goals_delimiter') . ' ' . $away_goals : '') . ' ' . ($played ? $outcome : '');
                    }
                }
                // Display status - match-2.php Template
                if ($played) {
                    $status_class = 'result';
                    if (get_option('wpcm_hide_scores') == 'yes' && !is_user_logged_in()) {
                        $status = __('x', 'wp-club-manager') . ' ' . get_option('wpcm_match_goals_delimiter') . ' ' . __('x', 'wp-club-manager');
                    } else {
                        if ($format == '%home% vs %away%') {
                            if ($sport == 'gaelic') {
                                $status = $home_gaa_goals . '-' . $home_gaa_points . ' ' . get_option('wpcm_match_goals_delimiter') . ' ' . $away_gaa_goals . '-' . $away_gaa_points;
                            } else {
                                $status = $home_goals . ' ' . get_option('wpcm_match_goals_delimiter') . ' ' . $away_goals;
                            }
                        } else {
                            if ($sport == 'gaelic') {
                                $status = $away_gaa_goals . '-' . $away_gaa_points . ' ' . get_option('wpcm_match_goals_delimiter') . ' ' . $home_gaa_goals . '-' . $home_gaa_points;
                            } else {
                                $status = $away_goals . ' ' . get_option('wpcm_match_goals_delimiter') . ' ' . $home_goals;
                            }
                        }
                    }
                } else {
                    $status_class = 'time';
                    $status = date_i18n($time_format, $timestamp);
                }
                // Display clubs format - match-2.php Template
                if ($format == '%home% vs %away%') {
                    $side1 = wpcm_get_team_name($home_club, $match->ID);
                    $side2 = wpcm_get_team_name($away_club, $match->ID);
                } else {
                    $side1 = wpcm_get_team_name($away_club, $match->ID);
                    $side2 = wpcm_get_team_name($home_club, $match->ID);
                }
                if ($type == '2') {
                    wpclubmanager_get_template('shortcodes/matches-2.php', array('match_link' => $match_link, 'timestamp' => $timestamp, 'status' => $status, 'status_class' => $status_class, 'competition' => $competition, 'side1' => $side1, 'side2' => $side2, 'class' => $class));
                } else {
                    wpclubmanager_get_template('shortcodes/matches.php', array('match_link' => $match_link, 'timestamp' => $timestamp, 'time_format' => $time_format, 'venue' => $venue, 'crest' => $crest, 'opponent' => $opponent, 'competition' => $competition, 'result' => $result, 'class' => $class));
                }
            }
        }
        if ($type == '2') {
            ?>

			</ul>

		<?php 
        } else {
            ?>

			</tbody>
			</table>
			</div>

		<?php 
        }
        if (isset($linkpage)) {
            ?>
		<a href="<?php 
            echo get_page_link($linkpage);
            ?>
" class="wpcm-view-link"><?php 
            echo $linktext;
            ?>
</a>
	<?php 
        }
    }