Add template loader to enable themed templates
This commit is contained in:
152
includes/class-sp-template-loader.php
Normal file
152
includes/class-sp-template-loader.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<?php
|
||||
/**
|
||||
* Template Loader
|
||||
*
|
||||
* @class SP_Template_Loader
|
||||
* @version 0.8
|
||||
* @package SportsPress/Classes
|
||||
* @category Class
|
||||
* @author ThemeBoy
|
||||
*/
|
||||
class SP_Template_Loader {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
add_filter( 'template_include', array( $this, 'template_loader' ) );
|
||||
add_filter( 'the_content', array( $this, 'event_content' ) );
|
||||
add_filter( 'the_content', array( $this, 'calendar_content' ) );
|
||||
add_filter( 'the_content', array( $this, 'team_content' ) );
|
||||
add_filter( 'the_content', array( $this, 'table_content' ) );
|
||||
add_filter( 'the_content', array( $this, 'player_content' ) );
|
||||
add_filter( 'the_content', array( $this, 'list_content' ) );
|
||||
add_filter( 'the_content', array( $this, 'staff_content' ) );
|
||||
}
|
||||
|
||||
public function event_content( $content ) {
|
||||
if ( is_singular( 'sp_event' ) )
|
||||
sp_get_template_part( 'content', 'single-event' );
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function calendar_content( $content ) {
|
||||
if ( is_singular( 'sp_calendar' ) )
|
||||
sp_get_template_part( 'content', 'single-calendar' );
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function team_content( $content ) {
|
||||
if ( is_singular( 'sp_team' ) )
|
||||
sp_get_template_part( 'content', 'single-team' );
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function table_content( $content ) {
|
||||
if ( is_singular( 'sp_table' ) )
|
||||
sp_get_template_part( 'content', 'single-table' );
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function player_content( $content ) {
|
||||
if ( is_singular( 'sp_player' ) )
|
||||
sp_get_template_part( 'content', 'single-player' );
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function list_content( $content ) {
|
||||
if ( is_singular( 'sp_list' ) )
|
||||
sp_get_template_part( 'content', 'single-list' );
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function staff_content( $content ) {
|
||||
if ( is_singular( 'sp_staff' ) )
|
||||
sp_get_template_part( 'content', 'single-staff' );
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a template.
|
||||
*
|
||||
* Handles template usage so that we can use our own templates instead of the themes.
|
||||
*
|
||||
* Templates are in the 'templates' folder. sportspress looks for theme
|
||||
* overrides in /theme/sportspress/ by default
|
||||
*
|
||||
* For beginners, it also looks for a sportspress.php template first. If the user adds
|
||||
* this to the theme (containing a sportspress() inside) this will be used for all
|
||||
* sportspress templates.
|
||||
*
|
||||
* @param mixed $template
|
||||
* @return string
|
||||
*/
|
||||
public function template_loader( $template ) {
|
||||
$find = array( 'sportspress.php' );
|
||||
$file = '';
|
||||
|
||||
if ( is_single() ):
|
||||
|
||||
switch( get_post_type() ):
|
||||
case 'sp_event':
|
||||
$file = 'single-event.php';
|
||||
$find[] = $file;
|
||||
$find[] = SP_TEMPLATE_PATH . $file;
|
||||
break;
|
||||
case 'sp_calendar':
|
||||
$file = 'single-calendar.php';
|
||||
$find[] = $file;
|
||||
$find[] = SP_TEMPLATE_PATH . $file;
|
||||
break;
|
||||
case 'sp_team':
|
||||
$file = 'single-team.php';
|
||||
$find[] = $file;
|
||||
$find[] = SP_TEMPLATE_PATH . $file;
|
||||
break;
|
||||
case 'sp_table':
|
||||
$file = 'single-table.php';
|
||||
$find[] = $file;
|
||||
$find[] = SP_TEMPLATE_PATH . $file;
|
||||
break;
|
||||
case 'sp_player':
|
||||
$file = 'single-player.php';
|
||||
$find[] = $file;
|
||||
$find[] = SP_TEMPLATE_PATH . $file;
|
||||
break;
|
||||
case 'sp_list':
|
||||
$file = 'single-list.php';
|
||||
$find[] = $file;
|
||||
$find[] = SP_TEMPLATE_PATH . $file;
|
||||
break;
|
||||
case 'sp_staff':
|
||||
$file = 'single-staff.php';
|
||||
$find[] = $file;
|
||||
$find[] = SP_TEMPLATE_PATH . $file;
|
||||
break;
|
||||
endswitch;
|
||||
|
||||
elseif ( is_tax( 'sp_venue' ) || is_tax( 'sp_season' ) ):
|
||||
|
||||
$term = get_queried_object();
|
||||
|
||||
$file = 'taxonomy-' . $term->taxonomy . '.php';
|
||||
$find[] = 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
|
||||
$find[] = SP_TEMPLATE_PATH . 'taxonomy-' . $term->taxonomy . '-' . $term->slug . '.php';
|
||||
$find[] = $file;
|
||||
$find[] = SP_TEMPLATE_PATH . $file;
|
||||
|
||||
endif;
|
||||
|
||||
if ( $file ):
|
||||
$located = locate_template( $find );
|
||||
if ( $located ):
|
||||
$template = $located;
|
||||
endif;
|
||||
endif;
|
||||
|
||||
return $template;
|
||||
}
|
||||
}
|
||||
|
||||
new SP_Template_Loader();
|
||||
|
||||
@@ -7,11 +7,21 @@
|
||||
* @author ThemeBoy
|
||||
* @category Core
|
||||
* @package SportsPress/Functions
|
||||
* @version 0.7
|
||||
* @version 0.8
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
/**
|
||||
* is_sportspress - Returns true if on a page which uses SportsPress templates
|
||||
*
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
function is_sportspress() {
|
||||
return apply_filters( 'is_sportspress', ( is_singular( array( 'sp_event', 'sp_calendar', 'sp_team', 'sp_table', 'sp_player', 'sp_list', 'sp_staff' ) ) ) ? true : false );
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'is_ajax' ) ) {
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* @author ThemeBoy
|
||||
* @category Core
|
||||
* @package SportsPress/Functions
|
||||
* @version 0.7
|
||||
* @version 0.8
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
@@ -17,6 +17,40 @@ include( 'sp-conditional-functions.php' );
|
||||
include( 'sp-formatting-functions.php' );
|
||||
include( 'sp-deprecated-functions.php' );
|
||||
|
||||
/**
|
||||
* Get template part.
|
||||
*
|
||||
* @access public
|
||||
* @param mixed $slug
|
||||
* @param string $name (default: '')
|
||||
* @return void
|
||||
*/
|
||||
function sp_get_template_part( $slug, $name = '' ) {
|
||||
$template = '';
|
||||
|
||||
// Look in yourtheme/slug-name.php and yourtheme/sportspress/slug-name.php
|
||||
if ( $name ) {
|
||||
$template = locate_template( array( "{$slug}-{$name}.php", SP()->template_path() . "{$slug}-{$name}.php" ) );
|
||||
}
|
||||
|
||||
// Get default slug-name.php
|
||||
if ( ! $template && $name && file_exists( SP()->plugin_path() . "/templates/{$slug}-{$name}.php" ) ) {
|
||||
$template = SP()->plugin_path() . "/templates/{$slug}-{$name}.php";
|
||||
}
|
||||
|
||||
// If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sportspress/slug.php
|
||||
if ( ! $template ) {
|
||||
$template = locate_template( array( "{$slug}.php", SP()->template_path() . "{$slug}.php" ) );
|
||||
}
|
||||
|
||||
// Allow 3rd party plugin filter template file from their plugin
|
||||
$template = apply_filters( 'sp_get_template_part', $template, $slug, $name );
|
||||
|
||||
if ( $template ) {
|
||||
load_template( $template, false );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get templates passing attributes and including the file.
|
||||
*
|
||||
@@ -973,7 +1007,7 @@ if ( !function_exists( 'sp_edit_league_table' ) ) {
|
||||
?>
|
||||
<tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
|
||||
<td>
|
||||
<?php if ( $show_team_logo ) echo get_the_post_thumbnail( $team_id, 'sportspress-fit-icon' ); ?>
|
||||
<?php if ( $show_team_logo ) echo get_the_post_thumbnail( $team_id, 'sportspress-fit-mini' ); ?>
|
||||
<span class="sp-default-value">
|
||||
<span class="sp-default-value-input"><?php echo $default_name; ?></span>
|
||||
<a class="dashicons dashicons-edit sp-edit" title="<?php _e( 'Edit', 'sportspress' ); ?>"></a>
|
||||
@@ -5198,7 +5232,7 @@ function sp_get_sport_presets() {
|
||||
),
|
||||
array(
|
||||
'post_title' => 'Yellow Cards',
|
||||
'post_name' => 'yellowcards',
|
||||
'post_name' => 'yellospards',
|
||||
'meta' => array(
|
||||
'sp_calculate' => 'total',
|
||||
),
|
||||
|
||||
@@ -7,7 +7,260 @@
|
||||
* @author ThemeBoy
|
||||
* @category Core
|
||||
* @package SportsPress/Functions
|
||||
* @version 0.7
|
||||
* @version 0.8
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
/**
|
||||
* Output generator tag to aid debugging.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
function sp_generator_tag( $gen, $type ) {
|
||||
switch ( $type ) {
|
||||
case 'html':
|
||||
$gen .= "\n" . '<meta name="generator" content="SportsPress ' . esc_attr( SP_VERSION ) . '">';
|
||||
break;
|
||||
case 'xhtml':
|
||||
$gen .= "\n" . '<meta name="generator" content="SportsPress ' . esc_attr( SP_VERSION ) . '" />';
|
||||
break;
|
||||
}
|
||||
return $gen;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add body classes for SP pages
|
||||
*
|
||||
* @param array $classes
|
||||
* @return array
|
||||
*/
|
||||
function sp_body_class( $classes ) {
|
||||
$classes = (array) $classes;
|
||||
|
||||
if ( is_sportspress() ) {
|
||||
$classes[] = 'sportspress';
|
||||
$classes[] = 'sportspress-page';
|
||||
}
|
||||
|
||||
return array_unique( $classes );
|
||||
}
|
||||
|
||||
/** Template pages ********************************************************/
|
||||
|
||||
if ( ! function_exists( 'sportspress_taxonomy_archive_description' ) ) {
|
||||
|
||||
/**
|
||||
* Show an archive description on taxonomy archives
|
||||
*
|
||||
* @access public
|
||||
* @subpackage Archives
|
||||
* @return void
|
||||
*/
|
||||
function sportspress_taxonomy_archive_description() {
|
||||
echo 'test';
|
||||
if ( is_tax( array( 'sp_season', 'sp_league', 'sp_venue', 'sp_position' ) ) && get_query_var( 'paged' ) == 0 ) {
|
||||
$description = apply_filters( 'the_content', term_description() );
|
||||
if ( $description ) {
|
||||
echo '<div class="term-description">' . $description . '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Single Event ********************************************************/
|
||||
|
||||
if ( ! function_exists( 'sportspress_output_event_video' ) ) {
|
||||
|
||||
/**
|
||||
* Output the event video.
|
||||
*
|
||||
* @access public
|
||||
* @subpackage Event/Video
|
||||
* @return void
|
||||
*/
|
||||
function sportspress_output_event_video() {
|
||||
sp_get_template( 'event-video.php' );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'sportspress_output_event_results' ) ) {
|
||||
|
||||
/**
|
||||
* Output the event results.
|
||||
*
|
||||
* @access public
|
||||
* @subpackage Event/Results
|
||||
* @return void
|
||||
*/
|
||||
function sportspress_output_event_results() {
|
||||
sp_get_template( 'event-results.php' );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'sportspress_output_event_details' ) ) {
|
||||
|
||||
/**
|
||||
* Output the event details.
|
||||
*
|
||||
* @access public
|
||||
* @subpackage Event/Details
|
||||
* @return void
|
||||
*/
|
||||
function sportspress_output_event_details() {
|
||||
sp_get_template( 'event-details.php' );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'sportspress_output_event_venue' ) ) {
|
||||
|
||||
/**
|
||||
* Output the event venue.
|
||||
*
|
||||
* @access public
|
||||
* @subpackage Event/Venue
|
||||
* @return void
|
||||
*/
|
||||
function sportspress_output_event_venue() {
|
||||
sp_get_template( 'event-venue.php' );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'sportspress_output_event_performance' ) ) {
|
||||
|
||||
/**
|
||||
* Output the event performance.
|
||||
*
|
||||
* @access public
|
||||
* @subpackage Event/Performance
|
||||
* @return void
|
||||
*/
|
||||
function sportspress_output_event_performance() {
|
||||
sp_get_template( 'event-performance.php' );
|
||||
}
|
||||
}
|
||||
|
||||
/** Single Calendar ********************************************************/
|
||||
|
||||
if ( ! function_exists( 'sportspress_output_calendar' ) ) {
|
||||
|
||||
/**
|
||||
* Output the calendar.
|
||||
*
|
||||
* @access public
|
||||
* @subpackage Calendar
|
||||
* @return void
|
||||
*/
|
||||
function sportspress_output_calendar() {
|
||||
$id = get_the_ID();
|
||||
$format = get_post_meta( $id, 'sp_format', true );
|
||||
switch ( $format ):
|
||||
case 'list':
|
||||
sp_get_template( 'event-list.php', array( 'id' => $id ) );
|
||||
break;
|
||||
default:
|
||||
sp_get_template( 'event-calendar.php', array( 'id' => $id ) );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
}
|
||||
|
||||
/** Single Team ********************************************************/
|
||||
|
||||
if ( ! function_exists( 'sportspress_output_team_columns' ) ) {
|
||||
|
||||
/**
|
||||
* Output the team columns.
|
||||
*
|
||||
* @access public
|
||||
* @subpackage Team/Columns
|
||||
* @return void
|
||||
*/
|
||||
function sportspress_output_team_columns() {
|
||||
sp_get_template( 'team-columns.php' );
|
||||
}
|
||||
}
|
||||
|
||||
/** Single League Table ********************************************************/
|
||||
|
||||
if ( ! function_exists( 'sportspress_output_league_table' ) ) {
|
||||
|
||||
/**
|
||||
* Output the team columns.
|
||||
*
|
||||
* @access public
|
||||
* @subpackage Table
|
||||
* @return void
|
||||
*/
|
||||
function sportspress_output_league_table() {
|
||||
sp_get_template( 'league-table.php' );
|
||||
}
|
||||
}
|
||||
|
||||
/** Single Player ********************************************************/
|
||||
|
||||
if ( ! function_exists( 'sportspress_output_player_metrics' ) ) {
|
||||
|
||||
/**
|
||||
* Output the player metrics.
|
||||
*
|
||||
* @access public
|
||||
* @subpackage Player/Metrics
|
||||
* @return void
|
||||
*/
|
||||
function sportspress_output_player_metrics() {
|
||||
sp_get_template( 'player-metrics.php' );
|
||||
}
|
||||
}
|
||||
if ( ! function_exists( 'sportspress_output_player_performance' ) ) {
|
||||
|
||||
/**
|
||||
* Output the player performance.
|
||||
*
|
||||
* @access public
|
||||
* @subpackage Player/Performance
|
||||
* @return void
|
||||
*/
|
||||
function sportspress_output_player_performance() {
|
||||
sp_get_template( 'player-performance.php' );
|
||||
}
|
||||
}
|
||||
|
||||
/** Single Player List ********************************************************/
|
||||
|
||||
if ( ! function_exists( 'sportspress_output_player_list' ) ) {
|
||||
|
||||
/**
|
||||
* Output the player list.
|
||||
*
|
||||
* @access public
|
||||
* @subpackage List
|
||||
* @return void
|
||||
*/
|
||||
function sportspress_output_player_list() {
|
||||
$id = get_the_ID();
|
||||
$format = get_post_meta( $id, 'sp_format', true );
|
||||
switch ( $format ):
|
||||
case 'gallery':
|
||||
sp_get_template( 'player-gallery.php', array( 'id' => $id ) );
|
||||
break;
|
||||
default:
|
||||
sp_get_template( 'player-list.php', array( 'id' => $id ) );
|
||||
break;
|
||||
endswitch;
|
||||
}
|
||||
}
|
||||
|
||||
/** Venue Archive ********************************************************/
|
||||
|
||||
function sportspress_output_venue_map( $query ) {
|
||||
if ( ! is_tax( 'sp_venue' ) )
|
||||
return;
|
||||
|
||||
$slug = sp_array_value( $query->query, 'sp_venue', null );
|
||||
|
||||
if ( ! $slug )
|
||||
return;
|
||||
|
||||
$venue = get_term_by( 'slug', $slug, 'sp_venue' );
|
||||
$t_id = $venue->term_id;
|
||||
$meta = get_option( "taxonomy_$t_id" );
|
||||
sp_get_template( 'venue-map.php', array( 'meta' => $meta ) );
|
||||
}
|
||||
|
||||
@@ -7,31 +7,77 @@
|
||||
* @author ThemeBoy
|
||||
* @category Core
|
||||
* @package SportsPress/Functions
|
||||
* @version 0.7
|
||||
* @version 0.8
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
function sportspress_default_venue_content( $query ) {
|
||||
if ( ! is_tax( 'sp_venue' ) )
|
||||
return;
|
||||
add_filter( 'body_class', 'sp_body_class' );
|
||||
|
||||
$slug = sp_array_value( $query->query, 'sp_venue', null );
|
||||
/**
|
||||
* WP Header
|
||||
*
|
||||
* @see sp_generator_tag()
|
||||
*/
|
||||
add_action( 'get_the_generator_html', 'sp_generator_tag', 10, 2 );
|
||||
add_action( 'get_the_generator_xhtml', 'sp_generator_tag', 10, 2 );
|
||||
|
||||
if ( ! $slug )
|
||||
return;
|
||||
/**
|
||||
* Single Event Content
|
||||
*
|
||||
* @see sportspress_output_event_video()
|
||||
* @see sportspress_output_event_results()
|
||||
* @see sportspress_output_event_details()
|
||||
* @see sportspress_output_event_venue()
|
||||
* @see sportspress_output_event_performance()
|
||||
*/
|
||||
add_action( 'sportspress_single_event_content', 'sportspress_output_event_video', 10 );
|
||||
add_action( 'sportspress_single_event_content', 'sportspress_output_event_results', 20 );
|
||||
add_action( 'sportspress_single_event_content', 'sportspress_output_event_details', 30 );
|
||||
add_action( 'sportspress_single_event_content', 'sportspress_output_event_venue', 40 );
|
||||
add_action( 'sportspress_single_event_content', 'sportspress_output_event_performance', 50 );
|
||||
|
||||
$venue = get_term_by( 'slug', $slug, 'sp_venue' );
|
||||
$t_id = $venue->term_id;
|
||||
$venue_meta = get_option( "taxonomy_$t_id" );
|
||||
$address = sp_array_value( $venue_meta, 'sp_address', null );
|
||||
$latitude = sp_array_value( $venue_meta, 'sp_latitude', null );
|
||||
$longitude = sp_array_value( $venue_meta, 'sp_longitude', null );
|
||||
/**
|
||||
* Single Calendar Content
|
||||
*
|
||||
* @see sportspress_output_calendar()
|
||||
*/
|
||||
add_action( 'sportspress_single_calendar_content', 'sportspress_output_calendar', 10 );
|
||||
|
||||
if ( $latitude != null && $longitude != null )
|
||||
echo '<div class="sp-google-map sp-venue-map" data-address="' . $address . '" data-latitude="' . $latitude . '" data-longitude="' . $longitude . '"></div>';
|
||||
}
|
||||
add_action( 'loop_start', 'sportspress_default_venue_content' );
|
||||
/**
|
||||
* Single Team Content
|
||||
*
|
||||
* @see sportspress_output_team_columns()
|
||||
*/
|
||||
add_action( 'sportspress_single_team_content', 'sportspress_output_team_columns', 10 );
|
||||
|
||||
/**
|
||||
* Single Table Content
|
||||
*
|
||||
* @see sportspress_output_league_table()
|
||||
*/
|
||||
add_action( 'sportspress_single_table_content', 'sportspress_output_league_table', 10 );
|
||||
|
||||
/**
|
||||
* Single Player Content
|
||||
*
|
||||
* @see sportspress_output_player_metrics()
|
||||
* @see sportspress_output_player_performance()
|
||||
*/
|
||||
add_action( 'sportspress_single_player_content', 'sportspress_output_player_metrics', 10 );
|
||||
add_action( 'sportspress_single_player_content', 'sportspress_output_player_performance', 20 );
|
||||
|
||||
/**
|
||||
* Single List Content
|
||||
*
|
||||
* @see sportspress_output_player_list()
|
||||
*/
|
||||
add_action( 'sportspress_single_list_content', 'sportspress_output_player_list', 10 );
|
||||
|
||||
/**
|
||||
* Venue Archive Content
|
||||
*/
|
||||
add_action( 'loop_start', 'sportspress_output_venue_map' );
|
||||
|
||||
function sportspress_the_title( $title, $id ) {
|
||||
if ( is_singular( 'sp_player' ) && in_the_loop() && $id == get_the_ID() ):
|
||||
@@ -152,104 +198,16 @@ function sportspress_sanitize_title( $title ) {
|
||||
}
|
||||
add_filter( 'sanitize_title', 'sportspress_sanitize_title' );
|
||||
|
||||
function sportspress_the_content( $content ) {
|
||||
function sportspress_content_post_views( $content ) {
|
||||
if ( is_single() || is_page() )
|
||||
sp_set_post_views( get_the_ID() );
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'the_content', 'sportspress_the_content' );
|
||||
add_filter( 'get_the_content', 'sportspress_the_content' );
|
||||
|
||||
function sportspress_default_event_content( $content ) {
|
||||
if ( is_singular( 'sp_event' ) && in_the_loop() )
|
||||
sp_get_template( 'event.php' );
|
||||
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'the_content', 'sportspress_default_event_content', 7 );
|
||||
|
||||
function sportspress_default_calendar_content( $content ) {
|
||||
if ( is_singular( 'sp_calendar' ) && in_the_loop() ):
|
||||
$id = get_the_ID();
|
||||
$format = get_post_meta( $id, 'sp_format', true );
|
||||
switch ( $format ):
|
||||
case 'list':
|
||||
sp_get_template( 'event-list.php', array(
|
||||
'id' => $id
|
||||
) );
|
||||
break;
|
||||
default:
|
||||
sp_get_template( 'event-calendar.php', array(
|
||||
'id' => $id,
|
||||
'initial' => false
|
||||
) );
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'the_content', 'sportspress_default_calendar_content' );
|
||||
|
||||
function sportspress_default_team_content( $content ) {
|
||||
if ( is_singular( 'sp_team' ) && in_the_loop() ):
|
||||
sp_get_template( 'team-columns.php' );
|
||||
endif;
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'the_content', 'sportspress_default_team_content' );
|
||||
|
||||
function sportspress_default_table_content( $content ) {
|
||||
if ( is_singular( 'sp_table' ) && in_the_loop() ):
|
||||
$id = get_the_ID();
|
||||
$leagues = get_the_terms( $id, 'sp_league' );
|
||||
$seasons = get_the_terms( $id, 'sp_season' );
|
||||
$terms = array();
|
||||
if ( $leagues ):
|
||||
$league = reset( $leagues );
|
||||
$terms[] = $league->name;
|
||||
endif;
|
||||
if ( $seasons ):
|
||||
$season = reset( $seasons );
|
||||
$terms[] = $season->name;
|
||||
endif;
|
||||
$title = '';
|
||||
if ( sizeof( $terms ) )
|
||||
echo '<h4 class="sp-table-caption">' . implode( ' — ', $terms ) . '</h4>';
|
||||
|
||||
sp_get_template( 'league-table.php' );
|
||||
$excerpt = has_excerpt() ? wpautop( get_the_excerpt() ) : '';
|
||||
$content = $content . $excerpt;
|
||||
endif;
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'the_content', 'sportspress_default_table_content' );
|
||||
|
||||
function sportspress_default_player_content( $content ) {
|
||||
if ( is_singular( 'sp_player' ) && in_the_loop() )
|
||||
sp_get_template( 'player.php' );
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'the_content', 'sportspress_default_player_content' );
|
||||
|
||||
function sportspress_default_list_content( $content ) {
|
||||
if ( is_singular( 'sp_list' ) && in_the_loop() ):
|
||||
$id = get_the_ID();
|
||||
$format = get_post_meta( $id, 'sp_format', true );
|
||||
switch ( $format ):
|
||||
case 'gallery':
|
||||
sp_get_template( 'player-gallery.php' );
|
||||
break;
|
||||
default:
|
||||
sp_get_template( 'player-list.php' );
|
||||
break;
|
||||
endswitch;
|
||||
endif;
|
||||
return $content;
|
||||
}
|
||||
add_filter( 'the_content', 'sportspress_default_list_content' );
|
||||
add_filter( 'the_content', 'sportspress_content_post_views' );
|
||||
add_filter( 'get_the_content', 'sportspress_content_post_views' );
|
||||
|
||||
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|events?(_|-)(calendar|list)|player(_|-)(list|gallery))?[\r\n\t ].*?\]/', $content ) )
|
||||
return $content;
|
||||
|
||||
$content = do_shortcode( $content );
|
||||
|
||||
Reference in New Issue
Block a user