Add template loader to enable themed templates

This commit is contained in:
Brian Miyaji
2014-04-18 19:47:36 +10:00
parent 086a8f1955
commit 0ec3ec5669
39 changed files with 916 additions and 139 deletions

View File

@@ -40,7 +40,7 @@
content: "\f307"; content: "\f307";
} }
.sp-icon-megaphone:before { .sp-icon-megaphone:before {
content: "\f322"; content: "\f155";
} }
.sp-icon-crown:before { .sp-icon-crown:before {
content: "\f313"; content: "\f313";

Binary file not shown.

View File

@@ -9,10 +9,10 @@
<glyph unicode="&#x20;" d="" horiz-adv-x="256" /> <glyph unicode="&#x20;" d="" horiz-adv-x="256" />
<glyph unicode="&#xf111;" d="M76.8 102.4h102.4v204.8h-102.4v-204.8zM204.8 102.4h102.4v307.2h-102.4v-307.2zM332.8 307.2v-204.8h102.4v204.8h-102.4z" /> <glyph unicode="&#xf111;" d="M76.8 102.4h102.4v204.8h-102.4v-204.8zM204.8 102.4h102.4v307.2h-102.4v-307.2zM332.8 307.2v-204.8h102.4v204.8h-102.4z" />
<glyph unicode="&#xf145;" d="M384 435.2h-51.2v-51.2h51.2v51.2zM435.2 435.2h-25.6v-76.8h-102.4v76.8h-102.4v-76.8h-102.4v76.8h-25.6c-14.16 0-25.6-11.44-25.6-25.6v-358.4c0-14.16 11.44-25.6 25.6-25.6h358.4c14.16 0 25.6 11.44 25.6 25.6v358.4c0 14.16-11.44 25.6-25.6 25.6zM409.6 76.8h-307.2v230.4h307.2v-230.4zM179.2 435.2h-51.2v-51.2h51.2v51.2zM281.6 256h-51.2v-51.2h51.2v51.2zM358.4 256h-51.2v-51.2h51.2v51.2zM204.8 179.2h-51.2v-51.2h51.2v51.2zM204.8 256h-51.2v-51.2h51.2v51.2zM281.6 179.2h-51.2v-51.2h51.2v51.2zM358.4 179.2h-51.2v-51.2h51.2v51.2z" /> <glyph unicode="&#xf145;" d="M384 435.2h-51.2v-51.2h51.2v51.2zM435.2 435.2h-25.6v-76.8h-102.4v76.8h-102.4v-76.8h-102.4v76.8h-25.6c-14.16 0-25.6-11.44-25.6-25.6v-358.4c0-14.16 11.44-25.6 25.6-25.6h358.4c14.16 0 25.6 11.44 25.6 25.6v358.4c0 14.16-11.44 25.6-25.6 25.6zM409.6 76.8h-307.2v230.4h307.2v-230.4zM179.2 435.2h-51.2v-51.2h51.2v51.2zM281.6 256h-51.2v-51.2h51.2v51.2zM358.4 256h-51.2v-51.2h51.2v51.2zM204.8 179.2h-51.2v-51.2h51.2v51.2zM204.8 256h-51.2v-51.2h51.2v51.2zM281.6 179.2h-51.2v-51.2h51.2v51.2zM358.4 179.2h-51.2v-51.2h51.2v51.2z" />
<glyph unicode="&#xf155;" d="M430.8 56.56l-116.8 97.2h-160.4v-76.8c0-7.2-2.56-13.28-7.6-18.24s-11.040-7.36-18-7.36h-25.6c-7.2 0-13.28 2.48-18.24 7.36s-7.36 11.040-7.36 18.24v76.8c-7.2 0-13.28 2.48-18.24 7.36s-7.36 11.040-7.36 18.24v128c0 7.2 2.48 13.28 7.36 18.24s11.040 7.36 18.24 7.36h237.2l116.8 97.2c2.96 3.2 6.88 4.88 11.84 4.96s9.2-0.88 12.8-3.040 5.44-4.8 5.44-8v-362c0-3.2-1.76-5.84-5.44-8s-7.84-3.040-12.8-2.8c-4.96 0.4-8.88 2.080-11.84 5.28zM243.2 332.96h-51.2c3.44 0 6.48-1.28 8.96-3.84s3.84-5.52 3.84-8.96v-153.6c0-3.44-1.28-6.48-3.84-8.96s-5.52-3.84-8.96-3.84h51.2c-3.76 0-6.8 1.28-9.2 3.84s-3.6 5.52-3.6 8.96v153.6c0 3.44 1.2 6.48 3.6 8.96s5.44 3.84 9.2 3.84z" />
<glyph unicode="&#xf163;" d="M153.6 332.8h51.2v-51.2h-51.2v51.2zM153.6 256h51.2v-51.2h-51.2v51.2zM153.6 179.2h51.2v-51.2h-51.2v51.2zM256 179.2h102.4v-51.2h-102.4v51.2zM435.2 435.2h-358.4c-14.16 0-25.6-11.44-25.6-25.6v-358.4c0-14.16 11.44-25.6 25.6-25.6h358.4c14.16 0 25.6 11.44 25.6 25.6v358.4c0 14.16-11.44 25.6-25.6 25.6zM409.6 76.8h-307.2v307.2h307.2v-307.2zM256 256h102.4v-51.2h-102.4v51.2zM256 332.8h102.4v-51.2h-102.4v51.2z" /> <glyph unicode="&#xf163;" d="M153.6 332.8h51.2v-51.2h-51.2v51.2zM153.6 256h51.2v-51.2h-51.2v51.2zM153.6 179.2h51.2v-51.2h-51.2v51.2zM256 179.2h102.4v-51.2h-102.4v51.2zM435.2 435.2h-358.4c-14.16 0-25.6-11.44-25.6-25.6v-358.4c0-14.16 11.44-25.6 25.6-25.6h358.4c14.16 0 25.6 11.44 25.6 25.6v358.4c0 14.16-11.44 25.6-25.6 25.6zM409.6 76.8h-307.2v307.2h307.2v-307.2zM256 256h102.4v-51.2h-102.4v51.2zM256 332.8h102.4v-51.2h-102.4v51.2z" />
<glyph unicode="&#xf307;" d="M384 102.4h-256v179.2h-76.8v102.4l130.4 25.6c8.56-33.12 38.56-57.6 74.4-57.6s65.84 24.48 74.4 57.6l130.4-25.6v-102.4h-76.8v-179.2zM384 76.8v-51.2h-256v51.2h256z" /> <glyph unicode="&#xf307;" d="M384 102.4h-256v179.2h-76.8v102.4l130.4 25.6c8.56-33.12 38.56-57.6 74.4-57.6s65.84 24.48 74.4 57.6l130.4-25.6v-102.4h-76.8v-179.2zM384 76.8v-51.2h-256v51.2h256z" />
<glyph unicode="&#xf313;" d="M435.2 332.8h-0.8l0.8-177.6v-1.6c0-6.96-2.56-12.96-7.6-18s-11.040-7.6-18-7.6h-307.2c-7.2 0-13.28 2.56-18.24 7.6s-7.36 11.040-7.36 18v1.6l0.8 177.6h-0.8c-7.2 0-13.28 2.48-18.24 7.36s-7.36 11.040-7.36 18.24 2.48 13.28 7.36 18.24 10.96 7.36 18.080 7.36 13.12-2.48 18.24-7.36 7.52-11.040 7.52-18.24c0-8.8-3.6-15.76-10.8-20.8l87.6-124 66.4 147.2c-4.56 1.84-8.16 4.96-11.040 9.2s-4.16 8.96-4.16 14c0 7.2 2.48 13.28 7.36 18.24s10.96 7.36 18 7.36c7.040 0 13.12-2.48 18.24-7.36s7.6-11.040 7.6-18.24c0-5.040-1.44-9.76-4.16-14s-6.48-7.36-11.040-9.2l66.4-147.2 87.6 124c-7.2 5.040-10.8 12-10.8 20.8 0 7.2 2.48 13.28 7.36 18.24s10.96 7.36 18 7.36 13.12-2.48 18.24-7.36 7.6-11.040 7.6-18.24-2.56-13.28-7.6-18.24-11.040-7.36-18-7.36zM76.8 102.4h358.4c6.96 0 12.96-2.48 18-7.36s7.6-10.96 7.6-18-2.56-13.12-7.6-18.24-11.040-7.6-18-7.6h-358.4c-6.96 0-12.96 2.56-18 7.6s-7.6 11.12-7.6 18.16 2.48 13.040 7.36 18 11.040 7.44 18.24 7.44z" /> <glyph unicode="&#xf313;" d="M435.2 332.8h-0.8l0.8-177.6v-1.6c0-6.96-2.56-12.96-7.6-18s-11.040-7.6-18-7.6h-307.2c-7.2 0-13.28 2.56-18.24 7.6s-7.36 11.040-7.36 18v1.6l0.8 177.6h-0.8c-7.2 0-13.28 2.48-18.24 7.36s-7.36 11.040-7.36 18.24 2.48 13.28 7.36 18.24 10.96 7.36 18.080 7.36 13.12-2.48 18.24-7.36 7.52-11.040 7.52-18.24c0-8.8-3.6-15.76-10.8-20.8l87.6-124 66.4 147.2c-4.56 1.84-8.16 4.96-11.040 9.2s-4.16 8.96-4.16 14c0 7.2 2.48 13.28 7.36 18.24s10.96 7.36 18 7.36c7.040 0 13.12-2.48 18.24-7.36s7.6-11.040 7.6-18.24c0-5.040-1.44-9.76-4.16-14s-6.48-7.36-11.040-9.2l66.4-147.2 87.6 124c-7.2 5.040-10.8 12-10.8 20.8 0 7.2 2.48 13.28 7.36 18.24s10.96 7.36 18 7.36 13.12-2.48 18.24-7.36 7.6-11.040 7.6-18.24-2.56-13.28-7.6-18.24-11.040-7.36-18-7.36zM76.8 102.4h358.4c6.96 0 12.96-2.48 18-7.36s7.6-10.96 7.6-18-2.56-13.12-7.6-18.24-11.040-7.6-18-7.6h-358.4c-6.96 0-12.96 2.56-18 7.6s-7.6 11.12-7.6 18.16 2.48 13.040 7.36 18 11.040 7.44 18.24 7.44z" />
<glyph unicode="&#xf322;" d="M430.8 56.56l-116.8 97.2h-160.4v-76.8c0-7.2-2.56-13.28-7.6-18.24s-11.040-7.36-18-7.36h-25.6c-7.2 0-13.28 2.48-18.24 7.36s-7.36 11.040-7.36 18.24v76.8c-7.2 0-13.28 2.48-18.24 7.36s-7.36 11.040-7.36 18.24v128c0 7.2 2.48 13.28 7.36 18.24s11.040 7.36 18.24 7.36h237.2l116.8 97.2c2.96 3.2 6.88 4.88 11.84 4.96s9.2-0.88 12.8-3.040 5.44-4.8 5.44-8v-362c0-3.2-1.76-5.84-5.44-8s-7.84-3.040-12.8-2.8c-4.96 0.4-8.88 2.080-11.84 5.28zM243.2 332.96h-51.2c3.44 0 6.48-1.28 8.96-3.84s3.84-5.52 3.84-8.96v-153.6c0-3.44-1.28-6.48-3.84-8.96s-5.52-3.84-8.96-3.84h51.2c-3.76 0-6.8 1.28-9.2 3.84s-3.6 5.52-3.6 8.96v153.6c0 3.44 1.2 6.48 3.6 8.96s5.44 3.84 9.2 3.84z" />
<glyph unicode="&#xf325;" d="M381.28 261.12c-8.56-52.4-48.16-94.16-99.68-104.8v-54c0-28.32 22.96-51.28 51.28-51.28h25.6v-25.6h-204.96v25.6h25.6c28.32 0 51.28 22.96 51.28 51.28v54c-51.44 10.64-91.12 52.4-99.68 104.8-60.48 15.84-105.36 70.4-105.36 135.84 0 4.4 0.88 8.56 1.28 12.8h101.2v51.2h256.24v-51.28h101.2c0.4-4.32 1.28-8.4 1.28-12.8 0-65.44-44.8-119.92-105.28-135.76zM127.92 384.080h-75.6c4.96-44.4 34.96-81.040 75.6-95.6v95.6zM384.080 384.080v-95.6c40.64 14.56 70.56 51.2 75.6 95.6h-75.6z" /> <glyph unicode="&#xf325;" d="M381.28 261.12c-8.56-52.4-48.16-94.16-99.68-104.8v-54c0-28.32 22.96-51.28 51.28-51.28h25.6v-25.6h-204.96v25.6h25.6c28.32 0 51.28 22.96 51.28 51.28v54c-51.44 10.64-91.12 52.4-99.68 104.8-60.48 15.84-105.36 70.4-105.36 135.84 0 4.4 0.88 8.56 1.28 12.8h101.2v51.2h256.24v-51.28h101.2c0.4-4.32 1.28-8.4 1.28-12.8 0-65.44-44.8-119.92-105.28-135.76zM127.92 384.080h-75.6c4.96-44.4 34.96-81.040 75.6-95.6v95.6zM384.080 384.080v-95.6c40.64 14.56 70.56 51.2 75.6 95.6h-75.6z" />
<glyph unicode="&#xf328;" d="M324 170.571q-10.572-34.572-39.428-55.714t-65.143-21.143-65.143 21.143-39.428 55.714q-2.285 7.143 1.143 13.857t10.857 9q7.143 2.286 13.857-1.143t9-10.857q7.143-22.857 26.428-37t43.286-14.143 43.286 14.143 26.428 37q2.286 7.428 9.143 10.857t14 1.143 10.572-9 1.143-13.857zM182.857 294.857q0-15.143-10.714-25.857t-25.857-10.714-25.857 10.714-10.715 25.857 10.715 25.857 25.857 10.714 25.857-10.714 10.714-25.857zM329.143 294.857q0-15.143-10.714-25.857t-25.857-10.714-25.857 10.714-10.714 25.857 10.714 25.857 25.857 10.714 25.857-10.714 10.714-25.857zM402.286 221.714q0 37.143-14.572 71t-39 58.286-58.286 39-71 14.572-71-14.572-58.285-39-39-58.286-14.572-71 14.572-71 39-58.286 58.285-39 71-14.572 71 14.572 58.286 39 39 58.286 14.572 71zM438.857 221.714q0-59.714-29.428-110.143t-79.857-79.857-110.143-29.428-110.143 29.428-79.857 79.857-29.428 110.143 29.428 110.143 79.857 79.857 110.143 29.428 110.143-29.428 79.857-79.857 29.428-110.143z" horiz-adv-x="439" /> <glyph unicode="&#xf328;" d="M324 170.571q-10.572-34.572-39.428-55.714t-65.143-21.143-65.143 21.143-39.428 55.714q-2.285 7.143 1.143 13.857t10.857 9q7.143 2.286 13.857-1.143t9-10.857q7.143-22.857 26.428-37t43.286-14.143 43.286 14.143 26.428 37q2.286 7.428 9.143 10.857t14 1.143 10.572-9 1.143-13.857zM182.857 294.857q0-15.143-10.714-25.857t-25.857-10.714-25.857 10.714-10.715 25.857 10.715 25.857 25.857 10.714 25.857-10.714 10.714-25.857zM329.143 294.857q0-15.143-10.714-25.857t-25.857-10.714-25.857 10.714-10.714 25.857 10.714 25.857 25.857 10.714 25.857-10.714 10.714-25.857zM402.286 221.714q0 37.143-14.572 71t-39 58.286-58.286 39-71 14.572-71-14.572-58.285-39-39-58.286-14.572-71 14.572-71 39-58.286 58.285-39 71-14.572 71 14.572 58.286 39 39 58.286 14.572 71zM438.857 221.714q0-59.714-29.428-110.143t-79.857-79.857-110.143-29.428-110.143 29.428-79.857 79.857-29.428 110.143 29.428 110.143 79.857 79.857 110.143 29.428 110.143-29.428 79.857-79.857 29.428-110.143z" horiz-adv-x="439" />
<glyph unicode="&#xf334;" d="M425.76 154.48c-6.16-15.76-14-29.84-23.2-42s-20.24-24.080-33.040-35.68c-12.8-11.52-24.56-21.2-35.36-28.88-10.88-7.6-22.080-14.88-33.84-21.68-11.84-6.8-20.16-11.44-25.12-13.92-4.96-2.4-8.96-4.24-11.92-5.52-2.24-1.2-4.64-1.68-7.28-1.68s-5.040 0.64-7.28 1.68c-3.040 1.28-6.88 3.12-11.92 5.52-5.040 2.4-13.36 7.040-25.12 13.92-11.76 6.8-23.040 14-33.84 21.68-10.88 7.68-22.56 17.28-35.36 28.88-12.8 11.52-23.84 23.36-33.040 35.68s-16.96 26.24-23.2 42c-6.32 15.76-9.44 31.76-9.44 47.76v215.040c0 4.8 1.68 9.12 5.28 12.64s7.76 5.28 12.64 5.28h322.56c4.8 0 9.12-1.68 12.64-5.28s5.28-7.76 5.28-12.64v-215.040c0-16-3.2-32-9.44-47.76zM384 384h-256v-181.92c0-33.36 22.4-67.52 67.12-102.32 17.92-14 38.24-27.040 60.88-38.96v0 0 0 0c22.64 11.92 42.96 24.96 60.88 38.96 44.72 34.88 67.12 68.96 67.12 102.32v181.92zM304.72 122.8c-14.32-11.6-30.56-22.4-48.72-32.24v0 0 267.68h102.4v-150.72c0-27.6-17.92-55.84-53.68-84.72z" /> <glyph unicode="&#xf334;" d="M425.76 154.48c-6.16-15.76-14-29.84-23.2-42s-20.24-24.080-33.040-35.68c-12.8-11.52-24.56-21.2-35.36-28.88-10.88-7.6-22.080-14.88-33.84-21.68-11.84-6.8-20.16-11.44-25.12-13.92-4.96-2.4-8.96-4.24-11.92-5.52-2.24-1.2-4.64-1.68-7.28-1.68s-5.040 0.64-7.28 1.68c-3.040 1.28-6.88 3.12-11.92 5.52-5.040 2.4-13.36 7.040-25.12 13.92-11.76 6.8-23.040 14-33.84 21.68-10.88 7.68-22.56 17.28-35.36 28.88-12.8 11.52-23.84 23.36-33.040 35.68s-16.96 26.24-23.2 42c-6.32 15.76-9.44 31.76-9.44 47.76v215.040c0 4.8 1.68 9.12 5.28 12.64s7.76 5.28 12.64 5.28h322.56c4.8 0 9.12-1.68 12.64-5.28s5.28-7.76 5.28-12.64v-215.040c0-16-3.2-32-9.44-47.76zM384 384h-256v-181.92c0-33.36 22.4-67.52 67.12-102.32 17.92-14 38.24-27.040 60.88-38.96v0 0 0 0c22.64 11.92 42.96 24.96 60.88 38.96 44.72 34.88 67.12 68.96 67.12 102.32v181.92zM304.72 122.8c-14.32-11.6-30.56-22.4-48.72-32.24v0 0 267.68h102.4v-150.72c0-27.6-17.92-55.84-53.68-84.72z" />

Before

Width:  |  Height:  |  Size: 6.1 KiB

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Binary file not shown.

View 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();

View File

@@ -7,11 +7,21 @@
* @author ThemeBoy * @author ThemeBoy
* @category Core * @category Core
* @package SportsPress/Functions * @package SportsPress/Functions
* @version 0.7 * @version 0.8
*/ */
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly 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' ) ) { if ( ! function_exists( 'is_ajax' ) ) {
/** /**

View File

@@ -7,7 +7,7 @@
* @author ThemeBoy * @author ThemeBoy
* @category Core * @category Core
* @package SportsPress/Functions * @package SportsPress/Functions
* @version 0.7 * @version 0.8
*/ */
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
@@ -17,6 +17,40 @@ include( 'sp-conditional-functions.php' );
include( 'sp-formatting-functions.php' ); include( 'sp-formatting-functions.php' );
include( 'sp-deprecated-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. * 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'; ?>"> <tr class="sp-row sp-post<?php if ( $i % 2 == 0 ) echo ' alternate'; ?>">
<td> <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">
<span class="sp-default-value-input"><?php echo $default_name; ?></span> <span class="sp-default-value-input"><?php echo $default_name; ?></span>
<a class="dashicons dashicons-edit sp-edit" title="<?php _e( 'Edit', 'sportspress' ); ?>"></a> <a class="dashicons dashicons-edit sp-edit" title="<?php _e( 'Edit', 'sportspress' ); ?>"></a>
@@ -5198,7 +5232,7 @@ function sp_get_sport_presets() {
), ),
array( array(
'post_title' => 'Yellow Cards', 'post_title' => 'Yellow Cards',
'post_name' => 'yellowcards', 'post_name' => 'yellospards',
'meta' => array( 'meta' => array(
'sp_calculate' => 'total', 'sp_calculate' => 'total',
), ),

View File

@@ -7,7 +7,260 @@
* @author ThemeBoy * @author ThemeBoy
* @category Core * @category Core
* @package SportsPress/Functions * @package SportsPress/Functions
* @version 0.7 * @version 0.8
*/ */
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly 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 ) );
}

View File

@@ -7,31 +7,77 @@
* @author ThemeBoy * @author ThemeBoy
* @category Core * @category Core
* @package SportsPress/Functions * @package SportsPress/Functions
* @version 0.7 * @version 0.8
*/ */
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
function sportspress_default_venue_content( $query ) { add_filter( 'body_class', 'sp_body_class' );
if ( ! is_tax( 'sp_venue' ) )
return;
$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; * Single Calendar Content
$venue_meta = get_option( "taxonomy_$t_id" ); *
$address = sp_array_value( $venue_meta, 'sp_address', null ); * @see sportspress_output_calendar()
$latitude = sp_array_value( $venue_meta, 'sp_latitude', null ); */
$longitude = sp_array_value( $venue_meta, 'sp_longitude', null ); 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>'; * Single Team Content
} *
add_action( 'loop_start', 'sportspress_default_venue_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 ) { function sportspress_the_title( $title, $id ) {
if ( is_singular( 'sp_player' ) && in_the_loop() && $id == get_the_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' ); add_filter( 'sanitize_title', 'sportspress_sanitize_title' );
function sportspress_the_content( $content ) { function sportspress_content_post_views( $content ) {
if ( is_single() || is_page() ) if ( is_single() || is_page() )
sp_set_post_views( get_the_ID() ); sp_set_post_views( get_the_ID() );
return $content; return $content;
} }
add_filter( 'the_content', 'sportspress_the_content' ); add_filter( 'the_content', 'sportspress_content_post_views' );
add_filter( 'get_the_content', 'sportspress_the_content' ); add_filter( 'get_the_content', 'sportspress_content_post_views' );
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( ' &mdash; ', $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' );
function sportspress_widget_text( $content ) { 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; return $content;
$content = do_shortcode( $content ); $content = do_shortcode( $content );

View File

@@ -3,7 +3,7 @@ Contributors: ThemeBoy
Tags: sports, press, sports journalism, teams, team management, fixtures, results, standings, league tables, leagues, reporting, themeboy, wordpress sports, configurable Tags: sports, press, sports journalism, teams, team management, fixtures, results, standings, league tables, leagues, reporting, themeboy, wordpress sports, configurable
Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=support@themeboy.com&item_name=Donation+for+SportsPress Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=support@themeboy.com&item_name=Donation+for+SportsPress
Requires at least: 3.8 Requires at least: 3.8
Tested up to: 3.8.2 Tested up to: 3.9
Stable tag: 0.8 Stable tag: 0.8
License: GPLv3 License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html License URI: http://www.gnu.org/licenses/gpl-3.0.html

View File

@@ -7,7 +7,7 @@
* Author: ThemeBoy * Author: ThemeBoy
* Author URI: http://themeboy.com * Author URI: http://themeboy.com
* Requires at least: 3.8 * Requires at least: 3.8
* Tested up to: 3.8 * Tested up to: 3.9
* *
* Text Domain: sportspress * Text Domain: sportspress
* Domain Path: /languages/ * Domain Path: /languages/
@@ -119,6 +119,7 @@ final class SportsPress {
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'action_links' ) ); add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'action_links' ) );
add_action( 'widgets_init', array( $this, 'include_widgets' ) ); add_action( 'widgets_init', array( $this, 'include_widgets' ) );
add_action( 'init', array( $this, 'init' ), 0 ); add_action( 'init', array( $this, 'init' ), 0 );
add_action( 'init', array( $this, 'include_template_functions' ) );
add_action( 'init', array( 'SP_Shortcodes', 'init' ) ); add_action( 'init', array( 'SP_Shortcodes', 'init' ) );
add_action( 'after_setup_theme', array( $this, 'setup_environment' ) ); add_action( 'after_setup_theme', array( $this, 'setup_environment' ) );
@@ -220,6 +221,7 @@ final class SportsPress {
* Include required frontend files. * Include required frontend files.
*/ */
public function frontend_includes() { public function frontend_includes() {
include_once( 'includes/class-sp-template-loader.php' ); // Template Loader
include_once( 'includes/class-sp-frontend-scripts.php' ); // Frontend Scripts include_once( 'includes/class-sp-frontend-scripts.php' ); // Frontend Scripts
include_once( 'includes/class-sp-shortcodes.php' ); // Shortcodes class include_once( 'includes/class-sp-shortcodes.php' ); // Shortcodes class
} }
@@ -298,7 +300,8 @@ final class SportsPress {
// Fit (Proportional) // Fit (Proportional)
add_image_size( 'sportspress-fit', 637, 637, false ); add_image_size( 'sportspress-fit', 637, 637, false );
add_image_size( 'sportspress-fit-thumbnail', 303, 303, false ); add_image_size( 'sportspress-fit-thumbnail', 303, 303, false );
add_image_size( 'sportspress-fit-icon', 32, 32, false ); add_image_size( 'sportspress-fit-icon', 128, 128, false );
add_image_size( 'sportspress-fit-mini', 32, 32, false );
} }
/** Helper functions ******************************************************/ /** Helper functions ******************************************************/

View File

@@ -0,0 +1,27 @@
<?php
/**
* The template for displaying calendar content.
*
* Override this template by copying it to yourtheme/sportspress/content-single-calendar.php
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?>
<?php
/**
* sportspress_before_single_calendar hook
*/
do_action( 'sportspress_before_single_calendar' );
if ( post_password_required() ) {
echo get_the_password_form();
return;
}
?>
<?php do_action( 'sportspress_single_calendar_content' ); ?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* The template for displaying event content.
*
* Override this template by copying it to yourtheme/sportspress/content-single-event.php
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?>
<?php
/**
* sportspress_before_single_event hook
*/
do_action( 'sportspress_before_single_event' );
if ( post_password_required() ) {
echo get_the_password_form();
return;
}
?>
<?php do_action( 'sportspress_single_event_content' ); ?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* The template for displaying list content.
*
* Override this template by copying it to yourtheme/sportspress/content-single-list.php
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?>
<?php
/**
* sportspress_before_single_list hook
*/
do_action( 'sportspress_before_single_list' );
if ( post_password_required() ) {
echo get_the_password_form();
return;
}
?>
<?php do_action( 'sportspress_single_list_content' ); ?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* The template for displaying player content.
*
* Override this template by copying it to yourtheme/sportspress/content-single-player.php
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?>
<?php
/**
* sportspress_before_single_player hook
*/
do_action( 'sportspress_before_single_player' );
if ( post_password_required() ) {
echo get_the_password_form();
return;
}
?>
<?php do_action( 'sportspress_single_player_content' ); ?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* The template for displaying staff content.
*
* Override this template by copying it to yourtheme/sportspress/content-single-staff.php
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?>
<?php
/**
* sportspress_before_single_staff hook
*/
do_action( 'sportspress_before_single_staff' );
if ( post_password_required() ) {
echo get_the_password_form();
return;
}
?>
<?php do_action( 'sportspress_single_staff_content' ); ?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* The template for displaying table content.
*
* Override this template by copying it to yourtheme/sportspress/content-single-table.php
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?>
<?php
/**
* sportspress_before_single_table hook
*/
do_action( 'sportspress_before_single_table' );
if ( post_password_required() ) {
echo get_the_password_form();
return;
}
?>
<?php do_action( 'sportspress_single_table_content' ); ?>

View File

@@ -0,0 +1,27 @@
<?php
/**
* The template for displaying team content.
*
* Override this template by copying it to yourtheme/sportspress/content-single-team.php
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
?>
<?php
/**
* sportspress_before_single_team hook
*/
do_action( 'sportspress_before_single_team' );
if ( post_password_required() ) {
echo get_the_password_form();
return;
}
?>
<?php do_action( 'sportspress_single_team_content' ); ?>

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Countdown
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
$defaults = array( $defaults = array(
'id' => null, 'id' => null,
'live' => get_option( 'sportspress_enable_live_countdowns', 'yes' ) == 'yes' ? true : false, 'live' => get_option( 'sportspress_enable_live_countdowns', 'yes' ) == 'yes' ? true : false,

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Event Calendar
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $wpdb, $m, $monthnum, $year, $wp_locale, $posts; global $wpdb, $m, $monthnum, $year, $wp_locale, $posts;
// Quick check. If we have no posts at all, abort! // Quick check. If we have no posts at all, abort!

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Event Details
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! isset( $id ) ) if ( ! isset( $id ) )
$id = get_the_ID(); $id = get_the_ID();

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Event List
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
$primary_result = get_option( 'sportspress_primary_result', null ); $primary_result = get_option( 'sportspress_primary_result', null );
$defaults = array( $defaults = array(

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Event Performance
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! isset( $id ) ) if ( ! isset( $id ) )
$id = get_the_ID(); $id = get_the_ID();

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Event Results
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! isset( $id ) ) if ( ! isset( $id ) )
$id = get_the_ID(); $id = get_the_ID();

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Event Staff
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! isset( $id ) ) if ( ! isset( $id ) )
$id = get_the_ID(); $id = get_the_ID();
$staff = (array)get_post_meta( $id, 'sp_staff', false ); $staff = (array)get_post_meta( $id, 'sp_staff', false );

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Event Venue
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! isset( $id ) ) if ( ! isset( $id ) )
$id = get_the_ID(); $id = get_the_ID();
@@ -12,15 +22,15 @@ $link_venues = get_option( 'sportspress_event_link_venues', 'no' ) == 'yes' ? tr
foreach( $venues as $venue ): foreach( $venues as $venue ):
$t_id = $venue->term_id; $t_id = $venue->term_id;
$term_meta = get_option( "taxonomy_$t_id" ); $meta = get_option( "taxonomy_$t_id" );
$name = $venue->name; $name = $venue->name;
if ( $link_venues ) if ( $link_venues )
$name = '<a href="' . get_term_link( $t_id, 'sp_venue' ) . '">' . $name . '</a>'; $name = '<a href="' . get_term_link( $t_id, 'sp_venue' ) . '">' . $name . '</a>';
$address = sp_array_value( $term_meta, 'sp_address', '' ); $address = sp_array_value( $meta, 'sp_address', '' );
$latitude = sp_array_value( $term_meta, 'sp_latitude', 0 ); $latitude = sp_array_value( $meta, 'sp_latitude', 0 );
$longitude = sp_array_value( $term_meta, 'sp_longitude', 0 ); $longitude = sp_array_value( $meta, 'sp_longitude', 0 );
?> ?>
<h3><?php echo SP()->text->string('Venue', 'event'); ?></h3> <h3><?php echo SP()->text->string('Venue', 'event'); ?></h3>
<table class="sp-data-table sp-event-venue"> <table class="sp-data-table sp-event-venue">
@@ -36,7 +46,7 @@ foreach( $venues as $venue ):
</tr> </tr>
<?php if ( $show_maps && $latitude != null && $longitude != null ): ?> <?php if ( $show_maps && $latitude != null && $longitude != null ): ?>
<tr> <tr>
<td><div class="sp-google-map" data-address="<?php echo $address; ?>" data-latitude="<?php echo $latitude; ?>" data-longitude="<?php echo $longitude; ?>"></div></td> <td><?php sp_get_template( 'venue-map.php', array( 'meta' => $meta ) ); ?></td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
</tbody> </tbody>

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Event Video
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! isset( $id ) ) if ( ! isset( $id ) )
$id = get_the_ID(); $id = get_the_ID();

View File

@@ -1,9 +0,0 @@
<?php
if ( ! isset( $id ) )
$id = get_the_ID();
sp_get_template( 'event-video.php', array( 'id' => $id ) );
sp_get_template( 'event-results.php', array( 'id' => $id ) );
sp_get_template( 'event-details.php', array( 'id' => $id ) );
sp_get_template( 'event-venue.php', array( 'id' => $id ) );
sp_get_template( 'event-performance.php', array( 'id' => $id ) );

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* League Table
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
$defaults = array( $defaults = array(
'id' => get_the_ID(), 'id' => get_the_ID(),
'number' => -1, 'number' => -1,

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Player Gallery
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
$defaults = array( $defaults = array(
'id' => get_the_ID(), 'id' => get_the_ID(),
'number' => -1, 'number' => -1,

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Player League Performance
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! isset( $league ) ) if ( ! isset( $league ) )
return false; return false;

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Player List
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
$defaults = array( $defaults = array(
'id' => get_the_ID(), 'id' => get_the_ID(),
'number' => -1, 'number' => -1,

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Player Metrics
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! isset( $id ) ) if ( ! isset( $id ) )
$id = get_the_ID(); $id = get_the_ID();

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Player Performance
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! isset( $id ) ) if ( ! isset( $id ) )
$id = get_the_ID(); $id = get_the_ID();

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Player Roster
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! $id ) if ( ! $id )
$id = get_the_ID(); $id = get_the_ID();

View File

@@ -1,6 +0,0 @@
<?php
if ( ! isset( $id ) )
$id = get_the_ID();
sp_get_template( 'player-metrics.php', array( 'id' => $id ) );
sp_get_template( 'player-performance.php', array( 'id' => $id ) );

View File

@@ -1,4 +1,14 @@
<?php <?php
/**
* Team Columns
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! isset( $id ) ) if ( ! isset( $id ) )
$id = get_the_ID(); $id = get_the_ID();

23
templates/venue-map.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
/**
* Venue Map
*
* @author ThemeBoy
* @package SportsPress/Templates
* @version 0.8
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
if ( ! isset( $meta ) )
return;
$address = sp_array_value( $meta, 'sp_address', null );
$latitude = sp_array_value( $meta, 'sp_latitude', null );
$longitude = sp_array_value( $meta, 'sp_longitude', null );
if ( $latitude != null && $longitude != null ):
?>
<div class="sp-google-map<?php if ( is_tax( 'sp_venue' ) ): ?> sp-venue-map<?php endif; ?>" data-address="<?php echo $address; ?>" data-latitude="<?php echo $latitude; ?>" data-longitude="<?php echo $longitude; ?>"></div>
<?php
endif;