Add SportsEvent microdata to event blocks

This commit is contained in:
Brian Miyaji
2017-11-03 17:38:38 +11:00
parent 70dd825ba7
commit 5ad7219b03
2 changed files with 15 additions and 8 deletions

View File

@@ -228,7 +228,7 @@ if ( !function_exists( 'sp_flush_rewrite_rules' ) ) {
if ( !function_exists( 'sp_add_link' ) ) { if ( !function_exists( 'sp_add_link' ) ) {
function sp_add_link( $string, $link = false, $active = true ) { function sp_add_link( $string, $link = false, $active = true ) {
if ( empty( $link ) || ! $active ) return $string; if ( empty( $link ) || ! $active ) return $string;
return '<a href="' . $link . '">' . $string . '</a>'; return '<a href="' . $link . '" itemprop="url" content="' . $link . '">' . $string . '</a>';
} }
} }

View File

@@ -105,14 +105,21 @@ if ( $title )
$j = 0; $j = 0;
foreach( $teams as $team ): foreach( $teams as $team ):
$j++; $j++;
$team_name = get_the_title( $team );
if ( has_post_thumbnail ( $team ) ): if ( has_post_thumbnail ( $team ) ):
$logo = get_the_post_thumbnail( $team, 'sportspress-fit-icon', array( 'itemprop' => 'logo' ) );
if ( $link_teams ): if ( $link_teams ):
$logo = '<a class="team-logo logo-' . ( $j % 2 ? 'odd' : 'even' ) . '" href="' . get_permalink( $team, false, true ) . '" title="' . get_the_title( $team ) . '">' . get_the_post_thumbnail( $team, 'sportspress-fit-icon' ) . '</a>'; $team_permalink = get_permalink( $team, false, true );
$logo = '<a href="' . $team_permalink . '" itemprop="url" content="' . $team_permalink . '">' . $logo . '</a>';
endif;
$logo = '<span class="team-logo logo-' . ( $j % 2 ? 'odd' : 'even' ) . '" title="' . $team_name . '" itemprop="competitor" itemscope itemtype="http://schema.org/SportsTeam"><meta itemprop="name" content="' . $team_name . '" />' . $logo . '</span>';
else: else:
$logo = '<span class="team-logo logo-' . ( $j % 2 ? 'odd' : 'even' ) . '" title="' . get_the_title( $team ) . '">' . get_the_post_thumbnail( $team, 'sportspress-fit-icon' ) . '</span>'; $logo = '<meta itemprop="competitor" itemscope itemtype="http://schema.org/SportsTeam"><meta itemprop="name" content="' . $team_name . '" /></meta>';
endif; endif;
$logos[] = $logo; $logos[] = $logo;
endif;
endforeach; endforeach;
endif; endif;
@@ -124,10 +131,10 @@ if ( $title )
endif; endif;
endif; endif;
?> ?>
<tr class="sp-row sp-post<?php echo ( $i % 2 == 0 ? ' alternate' : '' ); ?>"> <tr class="sp-row sp-post<?php echo ( $i % 2 == 0 ? ' alternate' : '' ); ?>" itemscope itemtype="http://schema.org/SportsEvent">
<td> <td>
<?php echo implode( $logos, ' ' ); ?> <?php echo implode( $logos, ' ' ); ?>
<time class="sp-event-date" datetime="<?php echo $event->post_date; ?>"> <time class="sp-event-date" datetime="<?php echo $event->post_date; ?>" itemprop="startDate" content="<?php echo mysql2date( 'Y-m-d\TH:iP', $event->post_date ); ?>">
<?php echo sp_add_link( get_the_time( get_option( 'date_format' ), $event ), $permalink, $link_events ); ?> <?php echo sp_add_link( get_the_time( get_option( 'date_format' ), $event ), $permalink, $link_events ); ?>
</time> </time>
<h5 class="sp-event-results"> <h5 class="sp-event-results">
@@ -142,7 +149,7 @@ if ( $title )
<?php if ( $show_venue ): $venues = get_the_terms( $event, 'sp_venue' ); if ( $venues ): $venue = array_shift( $venues ); ?> <?php if ( $show_venue ): $venues = get_the_terms( $event, 'sp_venue' ); if ( $venues ): $venue = array_shift( $venues ); ?>
<div class="sp-event-venue"><?php echo $venue->name; ?></div> <div class="sp-event-venue"><?php echo $venue->name; ?></div>
<?php endif; endif; ?> <?php endif; endif; ?>
<h4 class="sp-event-title"> <h4 class="sp-event-title" itemprop="name">
<?php echo sp_add_link( $event->post_title, $permalink, $link_events ); ?> <?php echo sp_add_link( $event->post_title, $permalink, $link_events ); ?>
</h4> </h4>