Use template function and load as needed

This commit is contained in:
Brian Miyaji
2014-03-25 13:03:58 +11:00
parent 73f5a2468d
commit 4659cf0f05
53 changed files with 1839 additions and 1648 deletions

View File

@@ -9,25 +9,31 @@ add_filter( 'get_the_content', 'sportspress_the_content' );
function sportspress_default_event_content( $content ) {
if ( is_singular( 'sp_event' ) && in_the_loop() ):
$details = sportspress_event_details();
$results = sportspress_event_results();
$performance = sportspress_event_performance();
$staff = sportspress_event_staff();
$id = get_the_ID();
// Video
$video_url = get_post_meta( $id, 'sp_video', true );
if ( $video_url ):
global $wp_embed;
$video = $wp_embed->autoembed( $video_url );
else:
$video = '';
endif;
if ( $results ):
$content = $video . $results . $details . $performance . $staff . $content;
else:
$venue = sportspress_event_venue();
$content = $video . $details . $venue . $performance . $staff . $content;
echo $wp_embed->autoembed( $video_url );
endif;
// Results
sp_get_template( 'event-results.php' );
// Details
sp_get_template( 'event-details.php' );
// Venue
sp_get_template( 'event-venue.php' );
// Performance
sp_get_template( 'event-performance.php' );
// Staff
sp_get_template( 'event-staff.php' );
endif;
return $content;
}
add_filter( 'the_content', 'sportspress_default_event_content', 7 );
@@ -38,13 +44,17 @@ function sportspress_default_calendar_content( $content ) {
$format = get_post_meta( $id, 'sp_format', true );
switch ( $format ):
case 'list':
$calendar = sportspress_event_list( $id );
sp_get_template( 'event-list.php', array(
'id' => $id
) );
break;
default:
$calendar = sportspress_event_calendar( $id, false );
sp_get_template( 'event-calendar.php', array(
'id' => $id,
'initial' => false
) );
break;
endswitch;
$content = $calendar . $content;
endif;
return $content;
}
@@ -52,8 +62,7 @@ add_filter( 'the_content', 'sportspress_default_calendar_content' );
function sportspress_default_team_content( $content ) {
if ( is_singular( 'sp_team' ) && in_the_loop() ):
$columns = sportspress_team_columns();
$content = $content . $columns;
sp_get_template( 'team-columns.php' );
endif;
return $content;
}
@@ -75,10 +84,11 @@ function sportspress_default_table_content( $content ) {
endif;
$title = '';
if ( sizeof( $terms ) )
$title = '<h4 class="sp-table-caption">' . implode( ' &mdash; ', $terms ) . '</h4>';
$table = sportspress_league_table();
echo '<h4 class="sp-table-caption">' . implode( ' &mdash; ', $terms ) . '</h4>';
sp_get_template( 'league-table.php' );
$excerpt = has_excerpt() ? wpautop( get_the_excerpt() ) : '';
$content = $title . $table . $content . $excerpt;
$content = $content . $excerpt;
endif;
return $content;
}
@@ -86,9 +96,8 @@ add_filter( 'the_content', 'sportspress_default_table_content' );
function sportspress_default_player_content( $content ) {
if ( is_singular( 'sp_player' ) && in_the_loop() ):
$metrics = sportspress_player_metrics();
$performance = sportspress_player_performance();
$content .= $metrics . $performance;
sp_get_template( 'player-metrics.php' );
sp_get_template( 'player-performance.php' );
endif;
return $content;
}
@@ -100,13 +109,12 @@ function sportspress_default_list_content( $content ) {
$format = get_post_meta( $id, 'sp_format', true );
switch ( $format ):
case 'gallery':
$list = sportspress_player_gallery( $id );
sp_get_template( 'player-gallery.php' );
break;
default:
$list = sportspress_player_list( $id );
sp_get_template( 'player-list.php' );
break;
endswitch;
$content = $list . $content;
endif;
return $content;
}

View File

@@ -1,6 +1,6 @@
<?php
function sportspress_widget_text( $content ) {
if ( ! preg_match( '/\[[\r\n\t ]*(countdown|league-table|event(s)-(calendar|list)|player-(list|gallery))?[\r\n\t ].*?\]/', $content ) )
if ( ! preg_match( '/\[[\r\n\t ]*(countdown|league_table|event(s)_(calendar|list)|player_(list|gallery))?[\r\n\t ].*?\]/', $content ) )
return $content;
$content = do_shortcode( $content );

View File

@@ -62,7 +62,7 @@ function sportspress_calendar_shortcode_meta( $post ) {
<p class="howto">
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
</p>
<p><input type="text" value="[event-<?php echo $the_format; ?> <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<p><input type="text" value="[event_<?php echo $the_format; ?> <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<?php
}

View File

@@ -60,7 +60,7 @@ function sportspress_list_shortcode_meta( $post ) {
<p class="howto">
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
</p>
<p><input type="text" value="[player-<?php echo $the_format; ?> <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<p><input type="text" value="[player_<?php echo $the_format; ?> <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<?php
}

View File

@@ -57,7 +57,7 @@ function sportspress_table_shortcode_meta( $post ) {
<p class="howto">
<?php _e( 'Copy this code and paste it into your post, page or text widget content.', 'sportspress' ); ?>
</p>
<p><input type="text" value="[league-table <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<p><input type="text" value="[league_table <?php echo $post->ID; ?>]" readonly="readonly" class="wp-ui-text-highlight code"></p>
<?php
}

View File

@@ -1,32 +0,0 @@
<?php
function sportspress_league_term_init() {
$labels = array(
'name' => __( 'Leagues', 'sportspress' ),
'singular_name' => __( 'League', 'sportspress' ),
'all_items' => __( 'All', 'sportspress' ),
'edit_item' => __( 'Edit League', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'update_item' => __( 'Update', 'sportspress' ),
'add_new_item' => __( 'Add New', 'sportspress' ),
'new_item_name' => __( 'Name', 'sportspress' ),
'parent_item' => __( 'Parent', 'sportspress' ),
'parent_item_colon' => __( 'Parent:', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Leagues', 'sportspress' ),
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => false,
'show_tagcloud' => false,
'hierarchical' => true,
'rewrite' => array( 'slug' => get_option( 'sportspress_league_slug', 'league' ) ),
);
$object_types = array( 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' );
register_taxonomy( 'sp_league', $object_types, $args );
foreach ( $object_types as $object_type ):
register_taxonomy_for_object_type( 'sp_league', $object_type );
endforeach;
}
add_action( 'init', 'sportspress_league_term_init' );

View File

@@ -1,32 +0,0 @@
<?php
function sportspress_position_term_init() {
$labels = array(
'name' => __( 'Positions', 'sportspress' ),
'singular_name' => __( 'Position', 'sportspress' ),
'all_items' => __( 'All', 'sportspress' ),
'edit_item' => __( 'Edit Position', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'update_item' => __( 'Update', 'sportspress' ),
'add_new_item' => __( 'Add New', 'sportspress' ),
'new_item_name' => __( 'Name', 'sportspress' ),
'parent_item' => __( 'Parent', 'sportspress' ),
'parent_item_colon' => __( 'Parent:', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Positions', 'sportspress' ),
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => false,
'show_tagcloud' => false,
'hierarchical' => true,
'rewrite' => array( 'slug' => get_option( 'sportspress_position_slug', 'position' ) ),
);
$object_types = array( 'sp_player', 'sp_performance', 'sp_metric', 'attachment' );
register_taxonomy( 'sp_position', $object_types, $args );
foreach ( $object_types as $object_type ):
register_taxonomy_for_object_type( 'sp_league', $object_type );
endforeach;
}
add_action( 'init', 'sportspress_position_term_init' );

View File

@@ -1,32 +0,0 @@
<?php
function sportspress_season_term_init() {
$labels = array(
'name' => __( 'Seasons', 'sportspress' ),
'singular_name' => __( 'Season', 'sportspress' ),
'all_items' => __( 'All', 'sportspress' ),
'edit_item' => __( 'Edit Season', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'update_item' => __( 'Update', 'sportspress' ),
'add_new_item' => __( 'Add New', 'sportspress' ),
'new_item_name' => __( 'Name', 'sportspress' ),
'parent_item' => __( 'Parent', 'sportspress' ),
'parent_item_colon' => __( 'Parent:', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Seasons', 'sportspress' ),
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => false,
'show_tagcloud' => false,
'hierarchical' => true,
'rewrite' => array( 'slug' => get_option( 'sportspress_season_slug', 'season' ) ),
);
$object_types = array( 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' );
register_taxonomy( 'sp_season', $object_types, $args );
foreach ( $object_types as $object_type ):
register_taxonomy_for_object_type( 'sp_league', $object_type );
endforeach;
}
add_action( 'init', 'sportspress_season_term_init' );

View File

@@ -1,36 +1,4 @@
<?php
function sportspress_venue_term_init() {
$labels = array(
'name' => __( 'Venues', 'sportspress' ),
'singular_name' => __( 'Venue', 'sportspress' ),
'all_items' => __( 'All', 'sportspress' ),
'edit_item' => __( 'Edit Venue', 'sportspress' ),
'view_item' => __( 'View', 'sportspress' ),
'update_item' => __( 'Update', 'sportspress' ),
'add_new_item' => __( 'Add New', 'sportspress' ),
'new_item_name' => __( 'Name', 'sportspress' ),
'parent_item' => __( 'Parent', 'sportspress' ),
'parent_item_colon' => __( 'Parent:', 'sportspress' ),
'search_items' => __( 'Search', 'sportspress' ),
'not_found' => __( 'No results found.', 'sportspress' ),
);
$args = array(
'label' => __( 'Venues', 'sportspress' ),
'labels' => $labels,
'public' => true,
'show_in_nav_menus' => false,
'show_tagcloud' => false,
'hierarchical' => true,
'rewrite' => array( 'slug' => get_option( 'sportspress_venue_slug', 'venue' ) ),
);
$object_types = array( 'sp_event', 'sp_calendar', 'attachment' );
register_taxonomy( 'sp_venue', $object_types, $args );
foreach ( $object_types as $object_type ):
register_taxonomy_for_object_type( 'sp_league', $object_type );
endforeach;
}
add_action( 'init', 'sportspress_venue_term_init' );
function sportspress_venue_edit_form_fields( $term ) {
$t_id = $term->term_id;
$term_meta = get_option( "taxonomy_$t_id" ); ?>