Move presets to json objects
This commit is contained in:
@@ -599,95 +599,6 @@ class SP_Admin_Settings {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Configure sport
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function configure_sport( $sport ) {
|
|
||||||
// Get array of taxonomies to insert
|
|
||||||
$term_groups = sp_array_value( $sport, 'term', array() );
|
|
||||||
|
|
||||||
foreach( $term_groups as $taxonomy => $terms ):
|
|
||||||
// Find empty terms and destroy
|
|
||||||
$allterms = get_terms( $taxonomy, 'hide_empty=0' );
|
|
||||||
|
|
||||||
foreach( $allterms as $term ):
|
|
||||||
if ( $term->count == 0 )
|
|
||||||
wp_delete_term( $term->term_id, $taxonomy );
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
// Insert terms
|
|
||||||
foreach( $terms as $term ):
|
|
||||||
wp_insert_term( $term['name'], $taxonomy, array( 'slug' => $term['slug'] ) );
|
|
||||||
endforeach;
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
// Get array of post types to insert
|
|
||||||
$post_groups = sp_array_value( $sport, 'posts', array() );
|
|
||||||
|
|
||||||
// Loop through each post type
|
|
||||||
foreach( $post_groups as $post_type => $posts ):
|
|
||||||
|
|
||||||
$args = array(
|
|
||||||
'post_type' => $post_type,
|
|
||||||
'numberposts' => -1,
|
|
||||||
'posts_per_page' => -1,
|
|
||||||
'meta_query' => array(
|
|
||||||
array(
|
|
||||||
'key' => '_sp_preset',
|
|
||||||
'value' => 1
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Delete posts
|
|
||||||
$old_posts = get_posts( $args );
|
|
||||||
|
|
||||||
foreach( $old_posts as $post ):
|
|
||||||
wp_delete_post( $post->ID, true);
|
|
||||||
endforeach;
|
|
||||||
|
|
||||||
// Add posts
|
|
||||||
foreach( $posts as $index => $post ):
|
|
||||||
|
|
||||||
// Make sure post doesn't overlap
|
|
||||||
if ( ! get_page_by_path( $post['post_name'], OBJECT, $post_type ) ):
|
|
||||||
|
|
||||||
// Translate post title
|
|
||||||
$post['post_title'] = __( $post['post_title'], 'sportspress' );
|
|
||||||
|
|
||||||
// Set post type
|
|
||||||
$post['post_type'] = $post_type;
|
|
||||||
|
|
||||||
// Increment menu order by 2 and publish post
|
|
||||||
$post['menu_order'] = $index * 2 + 2;
|
|
||||||
$post['post_status'] = 'publish';
|
|
||||||
$id = wp_insert_post( $post );
|
|
||||||
|
|
||||||
// Flag as preset
|
|
||||||
update_post_meta( $id, '_sp_preset', 1 );
|
|
||||||
|
|
||||||
// Update meta
|
|
||||||
if ( array_key_exists( 'meta', $post ) ):
|
|
||||||
foreach ( $post['meta'] as $key => $value ):
|
|
||||||
update_post_meta( $id, $key, $value );
|
|
||||||
endforeach;
|
|
||||||
endif;
|
|
||||||
|
|
||||||
// Update terms
|
|
||||||
if ( array_key_exists( 'tax_input', $post ) ):
|
|
||||||
foreach ( $post['tax_input'] as $taxonomy => $terms ):
|
|
||||||
wp_set_object_terms( $id, $terms, $taxonomy, false );
|
|
||||||
endforeach;
|
|
||||||
endif;
|
|
||||||
endif;
|
|
||||||
endforeach;
|
|
||||||
endforeach;
|
|
||||||
update_option( 'sportspress_primary_result', 0 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
endif;
|
endif;
|
||||||
|
|||||||
@@ -11,7 +11,9 @@
|
|||||||
* @author ThemeBoy
|
* @author ThemeBoy
|
||||||
*/
|
*/
|
||||||
class SP_Admin_Sports {
|
class SP_Admin_Sports {
|
||||||
private static $presets = array();
|
|
||||||
|
public static $presets = array();
|
||||||
|
public static $options = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Include the preset classes
|
* Include the preset classes
|
||||||
@@ -19,14 +21,11 @@ class SP_Admin_Sports {
|
|||||||
public static function get_presets() {
|
public static function get_presets() {
|
||||||
if ( empty( self::$presets ) ) {
|
if ( empty( self::$presets ) ) {
|
||||||
$presets = array();
|
$presets = array();
|
||||||
|
|
||||||
include( 'presets/class-sp-preset-sport.php' );
|
|
||||||
|
|
||||||
$dir = scandir( SP()->plugin_path() . '/presets' );
|
$dir = scandir( SP()->plugin_path() . '/presets' );
|
||||||
$files = array();
|
$files = array();
|
||||||
if ( $dir ) {
|
if ( $dir ) {
|
||||||
foreach ( $dir as $key => $value ) {
|
foreach ( $dir as $key => $value ) {
|
||||||
if ( ! in_array( $value, array( ".",".." ) ) ) {
|
if ( substr( $value, 0, 1 ) !== '.' ) {
|
||||||
$files[] = $value;
|
$files[] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,41 +33,163 @@ class SP_Admin_Sports {
|
|||||||
foreach( $files as $file ) {
|
foreach( $files as $file ) {
|
||||||
$json_data = file_get_contents( SP()->plugin_path() . '/presets/' . $file );
|
$json_data = file_get_contents( SP()->plugin_path() . '/presets/' . $file );
|
||||||
$data = json_decode( $json_data, true );
|
$data = json_decode( $json_data, true );
|
||||||
pr( $data );
|
if ( ! is_array( $data ) ) continue;
|
||||||
|
$id = preg_replace('/\\.[^.\\s]{3,4}$/', '', $file );
|
||||||
|
$presets[ $id ] = $data;
|
||||||
|
$name = array_key_exists( 'name', $data ) ? $data['name'] : $id;
|
||||||
|
self::$options[ $id ] = $name;
|
||||||
}
|
}
|
||||||
|
self::$options[ 'custom' ] = __( 'Custom', 'sportspress' );
|
||||||
//$presets[] = include( 'presets/class-sp-preset-soccer.php' );
|
|
||||||
//$presets[] = include( 'presets/class-sp-preset-baseball.php' );SP_TEMPLATE_PATH
|
|
||||||
|
|
||||||
self::$presets = apply_filters( 'sportspress_get_presets', $presets );
|
self::$presets = apply_filters( 'sportspress_get_presets', $presets );
|
||||||
}
|
}
|
||||||
return self::$presets;
|
return self::$presets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function get_preset_options() {
|
public static function get_preset( $id ) {
|
||||||
$presets = self::get_presets();
|
$json_data = file_get_contents( SP()->plugin_path() . '/presets/' . $id . '.json' );
|
||||||
$options = apply_filters( 'sportspress_sport_presets_array', array() );
|
return json_decode( $json_data, true );
|
||||||
return $options;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var array Array of sports */
|
public static function get_preset_options() {
|
||||||
private $data;
|
$presets = self::get_presets();
|
||||||
|
return self::$options;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for the sports class - defines all preset sports.
|
* Apply preset
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public static function apply_preset( $id ) {
|
||||||
$this->data = sp_get_sport_presets();
|
if ( 'custom' == $id ) {
|
||||||
|
$preset = array();
|
||||||
|
} else {
|
||||||
|
$preset = self::get_preset( $id );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Outcomes
|
||||||
|
$post_type = 'sp_outcome';
|
||||||
|
$outcomes = sp_array_value( $preset, 'outcomes', array() );
|
||||||
|
self::delete_preset_posts( $post_type );
|
||||||
|
foreach ( $outcomes as $index => $outcome ) {
|
||||||
|
$post = self::get_post_array( $outcome, $post_type );
|
||||||
|
if ( empty( $post ) ) continue;
|
||||||
|
$id = self::insert_preset_post( $post, $index );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Results
|
||||||
|
$post_type = 'sp_result';
|
||||||
|
$results = sp_array_value( $preset, 'results', array() );
|
||||||
|
self::delete_preset_posts( $post_type );
|
||||||
|
$main_result = 0;
|
||||||
|
foreach ( $results as $index => $result ) {
|
||||||
|
$post = self::get_post_array( $result, $post_type );
|
||||||
|
if ( empty( $post ) ) continue;
|
||||||
|
$id = self::insert_preset_post( $post, $index );
|
||||||
|
if ( array_key_exists( 'main', $result ) ) $main_result = $post['post_name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Performance
|
||||||
|
$post_type = 'sp_performance';
|
||||||
|
$performances = sp_array_value( $preset, 'performance', array() );
|
||||||
|
self::delete_preset_posts( $post_type );
|
||||||
|
foreach ( $performances as $index => $performance ) {
|
||||||
|
$post = self::get_post_array( $performance, $post_type );
|
||||||
|
if ( empty( $post ) ) continue;
|
||||||
|
$id = self::insert_preset_post( $post, $index );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Columns
|
||||||
|
$post_type = 'sp_column';
|
||||||
|
$columns = sp_array_value( $preset, 'columns', array() );
|
||||||
|
self::delete_preset_posts( $post_type );
|
||||||
|
foreach ( $columns as $index => $column ) {
|
||||||
|
$post = self::get_post_array( $column, $post_type );
|
||||||
|
if ( empty( $post ) ) continue;
|
||||||
|
$id = self::insert_preset_post( $post, $index );
|
||||||
|
update_post_meta( $id, 'sp_equation', sp_array_value( $column, 'equation', null ) );
|
||||||
|
update_post_meta( $id, 'sp_precision', sp_array_value( $column, 'precision', 0 ) );
|
||||||
|
update_post_meta( $id, 'sp_priority', sp_array_value( $column, 'priority', null ) );
|
||||||
|
update_post_meta( $id, 'sp_order', sp_array_value( $column, 'order', 'DESC' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Metrics
|
||||||
|
$post_type = 'sp_metric';
|
||||||
|
$metrics = sp_array_value( $preset, 'metrics', array() );
|
||||||
|
self::delete_preset_posts( $post_type );
|
||||||
|
foreach ( $metrics as $index => $metric ) {
|
||||||
|
$post = self::get_post_array( $metric, $post_type );
|
||||||
|
if ( empty( $post ) ) continue;
|
||||||
|
$id = self::insert_preset_post( $post, $index );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Statistics
|
||||||
|
$post_type = 'sp_statistic';
|
||||||
|
$statistics = sp_array_value( $preset, 'statistics', array() );
|
||||||
|
self::delete_preset_posts( $post_type );
|
||||||
|
foreach ( $statistics as $index => $statistic ) {
|
||||||
|
$post = self::get_post_array( $statistic, $post_type );
|
||||||
|
if ( empty( $post ) ) continue;
|
||||||
|
$id = self::insert_preset_post( $post, $index );
|
||||||
|
update_post_meta( $id, 'sp_equation', sp_array_value( $statistic, 'equation', null ) );
|
||||||
|
update_post_meta( $id, 'sp_precision', sp_array_value( $statistic, 'precision', 0 ) );
|
||||||
|
}
|
||||||
|
update_option( 'sportspress_primary_result', $main_result );
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __get( $key ) {
|
public static function delete_preset_posts( $post_type = null ) {
|
||||||
return ( array_key_exists( $key, $this->data ) ? $this->data[ $key ] : null );
|
$args = array(
|
||||||
|
'post_type' => $post_type,
|
||||||
|
'numberposts' => -1,
|
||||||
|
'posts_per_page' => -1,
|
||||||
|
'meta_query' => array(
|
||||||
|
array(
|
||||||
|
'key' => '_sp_preset',
|
||||||
|
'value' => 1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Delete posts
|
||||||
|
$old_posts = get_posts( $args );
|
||||||
|
foreach( $old_posts as $post ):
|
||||||
|
wp_delete_post( $post->ID, true);
|
||||||
|
endforeach;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __set( $key, $value ){
|
public static function get_post_array( $post = array(), $post_type = null ) {
|
||||||
$this->data[ $key ] = $value;
|
$post_array = array();
|
||||||
|
if ( is_string( $post ) ) {
|
||||||
|
$post_array['post_title'] = $post;
|
||||||
|
$post_array['post_name'] = sp_get_eos_safe_slug( $post_array['post_title'] );
|
||||||
|
} elseif ( is_array( $post ) ) {
|
||||||
|
if ( ! array_key_exists( 'name', $post ) ) $post_array = array();
|
||||||
|
$post_array['post_title'] = $post['name'];
|
||||||
|
$post_array['post_name'] = sp_array_value( $post, 'id', sp_get_eos_safe_slug( $post_array['post_title'] ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return empty array if post with same slug already exists
|
||||||
|
if ( get_page_by_path( $post_array['post_name'], OBJECT, $post_type ) ) return array();
|
||||||
|
|
||||||
|
// Set post type
|
||||||
|
$post_array['post_type'] = $post_type;
|
||||||
|
|
||||||
|
// Add post excerpt
|
||||||
|
$post_array['post_excerpt'] = sp_array_value( $post, 'description', $post_array['post_title'] );
|
||||||
|
|
||||||
|
return $post_array;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function insert_preset_post( $post, $index = 0 ) {
|
||||||
|
// Increment menu order by 10 and publish post
|
||||||
|
$post['menu_order'] = $index * 10 + 10;
|
||||||
|
$post['post_status'] = 'publish';
|
||||||
|
$id = wp_insert_post( $post );
|
||||||
|
|
||||||
|
// Flag as preset
|
||||||
|
update_post_meta( $id, '_sp_preset', 1 );
|
||||||
|
|
||||||
|
return $id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -195,8 +195,8 @@ class SP_Admin_Welcome {
|
|||||||
<?php
|
<?php
|
||||||
// Save settings
|
// Save settings
|
||||||
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) != $_POST['sportspress_sport'] ):
|
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) != $_POST['sportspress_sport'] ):
|
||||||
$sport = SP()->sports->$_POST['sportspress_sport'];
|
$sport = $_POST['sportspress_sport'];
|
||||||
SP_Admin_Settings::configure_sport( $sport );
|
SP_Admin_Sports::apply_preset( $sport );
|
||||||
update_option( 'sportspress_sport', $_POST['sportspress_sport'] );
|
update_option( 'sportspress_sport', $_POST['sportspress_sport'] );
|
||||||
endif;
|
endif;
|
||||||
if ( isset( $_POST['sportspress_default_country'] ) ):
|
if ( isset( $_POST['sportspress_default_country'] ) ):
|
||||||
@@ -222,7 +222,7 @@ class SP_Admin_Welcome {
|
|||||||
</p>
|
</p>
|
||||||
<h4><?php _e( 'Sport', 'sportspress' ); ?></h4>
|
<h4><?php _e( 'Sport', 'sportspress' ); ?></h4>
|
||||||
<?php
|
<?php
|
||||||
$sport_options = sp_get_sport_options();
|
$sport_options = SP_Admin_Sports::get_preset_options();
|
||||||
$class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
|
$class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
|
||||||
$settings = array( array(
|
$settings = array( array(
|
||||||
'id' => 'sportspress_sport',
|
'id' => 'sportspress_sport',
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* SportsPress Baseball Preset
|
|
||||||
*
|
|
||||||
* @author ThemeBoy
|
|
||||||
* @category Admin
|
|
||||||
* @package SportsPress/Admin
|
|
||||||
* @version 0.8
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Preset_Baseball' ) ) :
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SP_Preset_Baseball
|
|
||||||
*/
|
|
||||||
class SP_Preset_Baseball extends SP_Preset_Sport {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
$this->id = 'baseball';
|
|
||||||
$this->label = __( 'Baseball', 'sportspress' );
|
|
||||||
|
|
||||||
add_filter( 'sportspress_sport_presets_array', array( $this, 'add_sport_preset' ), 20 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
return new SP_Preset_Baseball();
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* SportsPress Soccer Preset
|
|
||||||
*
|
|
||||||
* @author ThemeBoy
|
|
||||||
* @category Admin
|
|
||||||
* @package SportsPress/Admin
|
|
||||||
* @version 0.8
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Preset_Soccer' ) ) :
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SP_Preset_Soccer
|
|
||||||
*/
|
|
||||||
class SP_Preset_Soccer extends SP_Preset_Sport {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
$this->id = 'soccer';
|
|
||||||
$this->label = __( 'Association Football (Soccer)', 'sportspress' );
|
|
||||||
|
|
||||||
add_filter( 'sportspress_sport_presets_array', array( $this, 'add_sport_preset' ), 20 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
endif;
|
|
||||||
|
|
||||||
return new SP_Preset_Soccer();
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* SportsPress Sport Preset
|
|
||||||
*
|
|
||||||
* @author ThemeBoy
|
|
||||||
* @category Admin
|
|
||||||
* @package SportsPress/Admin
|
|
||||||
* @version 0.8
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
||||||
|
|
||||||
if ( ! class_exists( 'SP_Preset_Sport' ) ) :
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SP_Preset_Sport
|
|
||||||
*/
|
|
||||||
class SP_Preset_Sport {
|
|
||||||
|
|
||||||
protected $id = '';
|
|
||||||
protected $label = '';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add this page to settings
|
|
||||||
*/
|
|
||||||
public function add_sport_preset( $presets ) {
|
|
||||||
$presets[ $this->id ] = $this->label;
|
|
||||||
|
|
||||||
return $presets;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
endif;
|
|
||||||
@@ -102,6 +102,7 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
<tr>
|
<tr>
|
||||||
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
||||||
<th scope="col"><?php _e( 'Variable', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Variable', 'sportspress' ); ?></th>
|
||||||
|
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
|
||||||
<th scope="col" class="edit"></th>
|
<th scope="col" class="edit"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -109,6 +110,7 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
||||||
<td class="row-title"><?php echo $row->post_title; ?></td>
|
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||||
<td><?php echo $row->post_name; ?></td>
|
<td><?php echo $row->post_name; ?></td>
|
||||||
|
<td><p class="description"><?php echo $row->post_excerpt; ?></p></td>
|
||||||
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php $i++; endforeach; ?>
|
<?php $i++; endforeach; ?>
|
||||||
@@ -149,50 +151,50 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
<p class="description"><?php _e( 'Used for events.' ); ?></p>
|
<p class="description"><?php _e( 'Used for events.' ); ?></p>
|
||||||
</th>
|
</th>
|
||||||
<td class="forminp">
|
<td class="forminp">
|
||||||
<fieldset>
|
<legend class="screen-reader-text"><span><?php _e( 'Team Results', 'sportspress' ) ?></span></legend>
|
||||||
<legend class="screen-reader-text"><span><?php _e( 'Team Results', 'sportspress' ) ?></span></legend>
|
<table class="widefat sp-admin-config-table">
|
||||||
<table class="widefat sp-admin-config-table">
|
<thead>
|
||||||
<thead>
|
<tr>
|
||||||
<tr>
|
<th scope="col"><?php _e( 'Primary', 'sportspress' ); ?></th>
|
||||||
<th scope="col"><?php _e( 'Primary', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
||||||
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Variables', 'sportspress' ); ?></th>
|
||||||
<th scope="col"><?php _e( 'Variables', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
|
||||||
<th scope="col" class="edit"></th>
|
<th scope="col" class="edit"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="radio"><input type="radio" id="sportspress_primary_result_0" name="sportspress_primary_result" value="0" <?php checked( $selection, 0 ); ?>></th>
|
<th class="radio"><input type="radio" id="sportspress_primary_result_0" name="sportspress_primary_result" value="0" <?php checked( $selection, 0 ); ?>></th>
|
||||||
<th colspan="3"><label for="sportspress_primary_result_0">
|
<th colspan="4"><label for="sportspress_primary_result_0">
|
||||||
<?php
|
<?php
|
||||||
if ( sizeof( $data ) > 0 ):
|
if ( sizeof( $data ) > 0 ):
|
||||||
$default = end( $data );
|
$default = end( $data );
|
||||||
reset( $data );
|
reset( $data );
|
||||||
printf( __( 'Default (%s)', 'sportspress' ), $default->post_title );
|
printf( __( 'Default (%s)', 'sportspress' ), $default->post_title );
|
||||||
else:
|
else:
|
||||||
_e( 'Default', 'sportspress' );
|
_e( 'Default', 'sportspress' );
|
||||||
endif;
|
endif;
|
||||||
?>
|
?>
|
||||||
</label></th>
|
</label></th>
|
||||||
</tr>
|
</tr>
|
||||||
</tfoot>
|
</tfoot>
|
||||||
<?php $i = 0; foreach ( $data as $row ): ?>
|
<?php $i = 0; foreach ( $data as $row ): ?>
|
||||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
||||||
<td class="radio"><input type="radio" id="sportspress_primary_result_<?php echo $row->post_name; ?>" name="sportspress_primary_result" value="<?php echo $row->post_name; ?>" <?php checked( $selection, $row->post_name ); ?>></td>
|
<td class="radio"><input type="radio" id="sportspress_primary_result_<?php echo $row->post_name; ?>" name="sportspress_primary_result" value="<?php echo $row->post_name; ?>" <?php checked( $selection, $row->post_name ); ?>></td>
|
||||||
<td class="row-title"><label for="sportspress_primary_result_<?php echo $row->post_name; ?>"><?php echo $row->post_title; ?></label></td>
|
<td class="row-title"><label for="sportspress_primary_result_<?php echo $row->post_name; ?>"><?php echo $row->post_title; ?></label></td>
|
||||||
<td><?php echo $row->post_name; ?>for, <?php echo $row->post_name; ?>against</td>
|
<td><?php echo $row->post_name; ?>for, <?php echo $row->post_name; ?>against</td>
|
||||||
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
<td><p class="description"><?php echo $row->post_excerpt; ?></p></td>
|
||||||
</tr>
|
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
||||||
<?php $i++; endforeach; ?>
|
</tr>
|
||||||
</table>
|
<?php $i++; endforeach; ?>
|
||||||
<div class="tablenav bottom">
|
</table>
|
||||||
<div class="alignleft actions">
|
<div class="tablenav bottom">
|
||||||
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_result' ); ?>"><?php _e( 'View All', 'sportspress' ); ?></a>
|
<div class="alignleft actions">
|
||||||
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_result' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
|
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_result' ); ?>"><?php _e( 'View All', 'sportspress' ); ?></a>
|
||||||
</div>
|
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_result' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
|
||||||
<br class="clear">
|
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
<br class="clear">
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
@@ -225,6 +227,7 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
<tr>
|
<tr>
|
||||||
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
||||||
<th scope="col"><?php _e( 'Variable', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Variable', 'sportspress' ); ?></th>
|
||||||
|
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
|
||||||
<th scope="col" class="edit"></th>
|
<th scope="col" class="edit"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -232,6 +235,7 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
||||||
<td class="row-title"><?php echo $row->post_title; ?></td>
|
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||||
<td><?php echo $row->post_name; ?></td>
|
<td><?php echo $row->post_name; ?></td>
|
||||||
|
<td><p class="description"><?php echo $row->post_excerpt; ?></p></td>
|
||||||
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php $i++; endforeach; ?>
|
<?php $i++; endforeach; ?>
|
||||||
@@ -278,6 +282,7 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
<th scope="col"><?php _e( 'Equation', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Equation', 'sportspress' ); ?></th>
|
||||||
<th scope="col"><?php _e( 'Rounding', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Rounding', 'sportspress' ); ?></th>
|
||||||
<th scope="col"><?php _e( 'Sort Order', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Sort Order', 'sportspress' ); ?></th>
|
||||||
|
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
|
||||||
<th scope="col" class="edit"></th>
|
<th scope="col" class="edit"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -288,6 +293,7 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
<td><?php echo sp_get_post_equation( $row->ID ); ?></td>
|
<td><?php echo sp_get_post_equation( $row->ID ); ?></td>
|
||||||
<td><?php echo sp_get_post_precision( $row->ID ); ?></td>
|
<td><?php echo sp_get_post_precision( $row->ID ); ?></td>
|
||||||
<td><?php echo sp_get_post_order( $row->ID ); ?></td>
|
<td><?php echo sp_get_post_order( $row->ID ); ?></td>
|
||||||
|
<td><p class="description"><?php echo $row->post_excerpt; ?></p></td>
|
||||||
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php $i++; endforeach; ?>
|
<?php $i++; endforeach; ?>
|
||||||
@@ -332,7 +338,7 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
<tr>
|
<tr>
|
||||||
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
|
||||||
<th scope="col"><?php _e( 'Variable', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Variable', 'sportspress' ); ?></th>
|
||||||
<th scope="col"> </th>
|
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
|
||||||
<th scope="col" class="edit"></th>
|
<th scope="col" class="edit"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -340,7 +346,7 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
|
||||||
<td class="row-title"><?php echo $row->post_title; ?></td>
|
<td class="row-title"><?php echo $row->post_title; ?></td>
|
||||||
<td><?php echo $row->post_name; ?></td>
|
<td><?php echo $row->post_name; ?></td>
|
||||||
<td> </td>
|
<td><p class="description"><?php echo $row->post_excerpt; ?></p></td>
|
||||||
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php $i++; endforeach; ?>
|
<?php $i++; endforeach; ?>
|
||||||
@@ -386,6 +392,7 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Key', 'sportspress' ); ?></th>
|
||||||
<th scope="col"><?php _e( 'Equation', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Equation', 'sportspress' ); ?></th>
|
||||||
<th scope="col"><?php _e( 'Rounding', 'sportspress' ); ?></th>
|
<th scope="col"><?php _e( 'Rounding', 'sportspress' ); ?></th>
|
||||||
|
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
|
||||||
<th scope="col" class="edit"></th>
|
<th scope="col" class="edit"></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -395,6 +402,7 @@ class SP_Settings_Config extends SP_Settings_Page {
|
|||||||
<td><?php echo $row->post_name; ?></td>
|
<td><?php echo $row->post_name; ?></td>
|
||||||
<td><?php echo sp_get_post_equation( $row->ID ); ?></td>
|
<td><?php echo sp_get_post_equation( $row->ID ); ?></td>
|
||||||
<td><?php echo sp_get_post_precision( $row->ID ); ?></td>
|
<td><?php echo sp_get_post_precision( $row->ID ); ?></td>
|
||||||
|
<td><p class="description"><?php echo $row->post_excerpt; ?></p></td>
|
||||||
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
<td class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php $i++; endforeach; ?>
|
<?php $i++; endforeach; ?>
|
||||||
|
|||||||
@@ -40,9 +40,7 @@ class SP_Settings_General extends SP_Settings_Page {
|
|||||||
*/
|
*/
|
||||||
public function get_settings() {
|
public function get_settings() {
|
||||||
|
|
||||||
$sports = new SP_Admin_Sports();
|
$presets = SP_Admin_Sports::get_preset_options();
|
||||||
|
|
||||||
$presets = $sports->get_preset_options();
|
|
||||||
|
|
||||||
return apply_filters( 'sportspress_general_settings', array(
|
return apply_filters( 'sportspress_general_settings', array(
|
||||||
|
|
||||||
@@ -109,8 +107,8 @@ class SP_Settings_General extends SP_Settings_Page {
|
|||||||
*/
|
*/
|
||||||
public function save() {
|
public function save() {
|
||||||
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) != $_POST['sportspress_sport'] ):
|
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) != $_POST['sportspress_sport'] ):
|
||||||
$sport = SP()->sports->$_POST['sportspress_sport'];
|
$sport = $_POST['sportspress_sport'];
|
||||||
SP_Admin_Settings::configure_sport( $sport );
|
SP_Admin_Sports::apply_preset( $sport );
|
||||||
update_option( '_sp_needs_welcome', 0 );
|
update_option( '_sp_needs_welcome', 0 );
|
||||||
endif;
|
endif;
|
||||||
|
|
||||||
|
|||||||
@@ -135,8 +135,7 @@ class SP_Install {
|
|||||||
if ( ! get_option( 'sportspress_installed' ) ) {
|
if ( ! get_option( 'sportspress_installed' ) ) {
|
||||||
// Configure default sport
|
// Configure default sport
|
||||||
$sport = 'soccer';
|
$sport = 'soccer';
|
||||||
$options = sp_get_sport_presets();
|
SP_Admin_Sports::apply_preset( $sport );
|
||||||
SP_Admin_Settings::configure_sport( $options[ $sport ] );
|
|
||||||
update_option( 'sportspress_sport', $sport );
|
update_option( 'sportspress_sport', $sport );
|
||||||
update_option( 'sportspress_installed', 1 );
|
update_option( 'sportspress_installed', 1 );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ class SP_Post_types {
|
|||||||
'publicly_queryable' => false,
|
'publicly_queryable' => false,
|
||||||
'exclude_from_search' => true,
|
'exclude_from_search' => true,
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'page-attributes' ),
|
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
|
||||||
'has_archive' => false,
|
'has_archive' => false,
|
||||||
'show_in_nav_menus' => false,
|
'show_in_nav_menus' => false,
|
||||||
'can_export' => false,
|
'can_export' => false,
|
||||||
@@ -205,7 +205,7 @@ class SP_Post_types {
|
|||||||
'publicly_queryable' => false,
|
'publicly_queryable' => false,
|
||||||
'exclude_from_search' => true,
|
'exclude_from_search' => true,
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'page-attributes' ),
|
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
|
||||||
'has_archive' => false,
|
'has_archive' => false,
|
||||||
'show_in_nav_menus' => false,
|
'show_in_nav_menus' => false,
|
||||||
'can_export' => false,
|
'can_export' => false,
|
||||||
@@ -235,7 +235,7 @@ class SP_Post_types {
|
|||||||
'publicly_queryable' => false,
|
'publicly_queryable' => false,
|
||||||
'exclude_from_search' => true,
|
'exclude_from_search' => true,
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'page-attributes' ),
|
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
|
||||||
'has_archive' => false,
|
'has_archive' => false,
|
||||||
'show_in_nav_menus' => false,
|
'show_in_nav_menus' => false,
|
||||||
'can_export' => false,
|
'can_export' => false,
|
||||||
@@ -265,7 +265,7 @@ class SP_Post_types {
|
|||||||
'publicly_queryable' => false,
|
'publicly_queryable' => false,
|
||||||
'exclude_from_search' => true,
|
'exclude_from_search' => true,
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'page-attributes' ),
|
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
|
||||||
'has_archive' => false,
|
'has_archive' => false,
|
||||||
'show_in_nav_menus' => false,
|
'show_in_nav_menus' => false,
|
||||||
'can_export' => false,
|
'can_export' => false,
|
||||||
@@ -295,7 +295,7 @@ class SP_Post_types {
|
|||||||
'publicly_queryable' => false,
|
'publicly_queryable' => false,
|
||||||
'exclude_from_search' => true,
|
'exclude_from_search' => true,
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'page-attributes' ),
|
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
|
||||||
'has_archive' => false,
|
'has_archive' => false,
|
||||||
'show_in_nav_menus' => false,
|
'show_in_nav_menus' => false,
|
||||||
'can_export' => false,
|
'can_export' => false,
|
||||||
@@ -325,7 +325,7 @@ class SP_Post_types {
|
|||||||
'publicly_queryable' => false,
|
'publicly_queryable' => false,
|
||||||
'exclude_from_search' => true,
|
'exclude_from_search' => true,
|
||||||
'hierarchical' => false,
|
'hierarchical' => false,
|
||||||
'supports' => array( 'title', 'page-attributes' ),
|
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
|
||||||
'has_archive' => false,
|
'has_archive' => false,
|
||||||
'show_in_nav_menus' => false,
|
'show_in_nav_menus' => false,
|
||||||
'can_export' => false,
|
'can_export' => false,
|
||||||
|
|||||||
@@ -1,52 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* SportsPress Admin Sports Class.
|
|
||||||
*
|
|
||||||
* The SportsPress admin sports class stores preset sport data.
|
|
||||||
*
|
|
||||||
* @class SP_Sports
|
|
||||||
* @version 0.8
|
|
||||||
* @package SportsPress/Admin
|
|
||||||
* @category Class
|
|
||||||
* @author ThemeBoy
|
|
||||||
*/
|
|
||||||
class SP_Sports {
|
|
||||||
private static $presets = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Include the preset classes
|
|
||||||
*/
|
|
||||||
public static function get_presets() {
|
|
||||||
if ( empty( self::$presets ) ) {
|
|
||||||
$presets = array();
|
|
||||||
|
|
||||||
include_once( 'preset/class-sp-preset-sport.php' );
|
|
||||||
|
|
||||||
$presets[] = include( 'preset/class-sp-preset-soccer.php' );
|
|
||||||
|
|
||||||
self::$presets = apply_filters( 'sportspress_get_presets', $presets );
|
|
||||||
}
|
|
||||||
return self::$presets;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var array Array of sports */
|
|
||||||
private $data;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor for the sports class - defines all preset sports.
|
|
||||||
*
|
|
||||||
* @access public
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function __construct() {
|
|
||||||
$this->data = sp_get_sport_presets();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __get( $key ) {
|
|
||||||
return ( array_key_exists( $key, $this->data ) ? $this->data[ $key ] : null );
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __set( $key, $value ){
|
|
||||||
$this->data[ $key ] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -2407,15 +2407,6 @@ function sp_get_sport_presets() {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
function sp_get_sport_options() {
|
|
||||||
$sports = sp_get_sport_presets();
|
|
||||||
$options = array();
|
|
||||||
foreach ( $sports as $slug => $data ):
|
|
||||||
$options[ $slug ] = $data['name'];
|
|
||||||
endforeach;
|
|
||||||
return $options;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an array of text options per context.
|
* Get an array of text options per context.
|
||||||
* @return array
|
* @return array
|
||||||
|
|||||||
@@ -110,6 +110,12 @@ function sportspress_gettext( $translated_text, $untranslated_text, $domain ) {
|
|||||||
if ( is_admin() ):
|
if ( is_admin() ):
|
||||||
if ( is_sp_config_type( $typenow ) ):
|
if ( is_sp_config_type( $typenow ) ):
|
||||||
switch ( $untranslated_text ):
|
switch ( $untranslated_text ):
|
||||||
|
case 'Excerpt':
|
||||||
|
$translated_text = __( 'Description', 'sportspress' );
|
||||||
|
break;
|
||||||
|
case 'Excerpts are optional hand-crafted summaries of your content that can be used in your theme. <a href="http://codex.wordpress.org/Excerpt" target="_blank">Learn more about manual excerpts.</a>':
|
||||||
|
$translated_text = __( 'The description is not prominent by default; however, some themes may show it.', 'sportspress' );
|
||||||
|
break;
|
||||||
case 'Slug':
|
case 'Slug':
|
||||||
$translated_text = ( in_array( $typenow, array( 'sp_column', 'sp_statistic' ) ) ) ? __( 'Key', 'sportspress' ) : __( 'Variable', 'sportspress' );
|
$translated_text = ( in_array( $typenow, array( 'sp_column', 'sp_statistic' ) ) ) ? __( 'Key', 'sportspress' ) : __( 'Variable', 'sportspress' );
|
||||||
break;
|
break;
|
||||||
|
|||||||
40
presets/baseball.json
Normal file
40
presets/baseball.json
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
{
|
||||||
|
"name": "Baseball - coming soon",
|
||||||
|
"outcomes": [
|
||||||
|
"Win",
|
||||||
|
"Loss"
|
||||||
|
],
|
||||||
|
"results": [
|
||||||
|
{ "name" : "1", "description" : "1st inning runs" },
|
||||||
|
{ "name" : "2", "description" : "2nd inning runs" },
|
||||||
|
{ "name" : "3", "description" : "3rd inning runs" },
|
||||||
|
{ "name" : "4", "description" : "4th inning runs" },
|
||||||
|
{ "name" : "5", "description" : "5th inning runs" },
|
||||||
|
{ "name" : "6", "description" : "6th inning runs" },
|
||||||
|
{ "name" : "7", "description" : "7th inning runs" },
|
||||||
|
{ "name" : "8", "description" : "8th inning runs" },
|
||||||
|
{ "name" : "9", "description" : "9th inning runs" },
|
||||||
|
{ "name" : "", "id" : "extra", "description" : "Extra inning runs" },
|
||||||
|
{ "name" : "R", "description" : "Total runs", "main" : 1 },
|
||||||
|
{ "name" : "H", "description" : "Hits" },
|
||||||
|
{ "name" : "E", "description" : "Errors" }
|
||||||
|
],
|
||||||
|
"performance": [
|
||||||
|
],
|
||||||
|
"columns": [
|
||||||
|
{ "name" : "W", "equation" : "$win", "description" : "Wins" },
|
||||||
|
{ "name" : "L", "equation" : "$loss", "description" : "Losses" },
|
||||||
|
{ "name" : "PCT", "equation" : "$win / $eventsplayed", "precision" : 3, "description" : "Win percentage" },
|
||||||
|
{ "name" : "RS", "equation" : "$rfor", "description" : "Runs scored" },
|
||||||
|
{ "name" : "RA", "equation" : "$ragainst", "description" : "Runs allowed" },
|
||||||
|
{ "name" : "DIFF", "equation" : "$rfor - $ragainst", "description" : "Run differential" },
|
||||||
|
{ "name" : "L10", "equation" : "$last10", "description" : "Last 10 games" },
|
||||||
|
{ "name" : "STRK", "equation" : "$streak", "description" : "Current streak" }
|
||||||
|
],
|
||||||
|
"metrics": [
|
||||||
|
"Height",
|
||||||
|
"Weight"
|
||||||
|
],
|
||||||
|
"statistics": [
|
||||||
|
]
|
||||||
|
}
|
||||||
61
presets/basketball.json
Normal file
61
presets/basketball.json
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
"name": "Basketball",
|
||||||
|
"outcomes": [
|
||||||
|
"Win",
|
||||||
|
"Loss"
|
||||||
|
],
|
||||||
|
"results": [
|
||||||
|
{ "name" : "1", "description" : "1st quarter points" },
|
||||||
|
{ "name" : "2", "description" : "2nd quarter points" },
|
||||||
|
{ "name" : "3", "description" : "3rd quarter points" },
|
||||||
|
{ "name" : "4", "description" : "4th quarter points" },
|
||||||
|
{ "name" : "", "id" : "ot", "description" : "Overtime points" },
|
||||||
|
{ "name" : "T", "description" : "Total points", "main" : 1 }
|
||||||
|
],
|
||||||
|
"performance": [
|
||||||
|
{ "name" : "MIN", "description" : "Minutes" },
|
||||||
|
{ "name" : "FGM", "description" : "Field goals made" },
|
||||||
|
{ "name" : "FGA", "description" : "Field goals attempted" },
|
||||||
|
{ "name" : "FTM", "description" : "Free throws made" },
|
||||||
|
{ "name" : "FTA", "description" : "Free throws attempted" },
|
||||||
|
{ "name" : "3PM", "description" : "3-pointers made" },
|
||||||
|
{ "name" : "3PA", "description" : "3-pointers attempted" },
|
||||||
|
{ "name" : "OFF REB", "description" : "Offensive rebounds" },
|
||||||
|
{ "name" : "DEF REB", "description" : "Defensive rebounds" },
|
||||||
|
{ "name" : "AST", "description" : "Assists" },
|
||||||
|
{ "name" : "PF", "description" : "Personal fouls" },
|
||||||
|
{ "name" : "TF", "description" : "Technical fouls" },
|
||||||
|
{ "name" : "STL", "description" : "Steals" },
|
||||||
|
{ "name" : "TO", "description" : "Turnovers" },
|
||||||
|
{ "name" : "BLK", "description" : "Blocks" },
|
||||||
|
{ "name" : "PTS", "description" : "Points" }
|
||||||
|
],
|
||||||
|
"columns": [
|
||||||
|
{ "name" : "W", "equation" : "$win", "description" : "Wins" },
|
||||||
|
{ "name" : "L", "equation" : "$loss", "description" : "Losses" },
|
||||||
|
{ "name" : "PCT", "equation" : "$win / $eventsplayed", "precision" : 3, "description" : "Win percentage" },
|
||||||
|
{ "name" : "PF", "equation" : "$tfor / $eventsplayed", "precision" : 1, "description" : "Average points for" },
|
||||||
|
{ "name" : "PA", "equation" : "$tagainst / $eventsplayed", "precision" : 1, "description" : "Average points against" },
|
||||||
|
{ "name" : "DIFF", "equation" : "( $tfor - $tagainst ) / $eventsplayed", "precision" : 1, "description" : "Average point differential" },
|
||||||
|
{ "name" : "L10", "equation" : "$last10", "description" : "Last 10 games" },
|
||||||
|
{ "name" : "STRK", "equation" : "$streak", "description" : "Current streak" }
|
||||||
|
],
|
||||||
|
"metrics": [
|
||||||
|
"Height",
|
||||||
|
"Weight"
|
||||||
|
],
|
||||||
|
"statistics": [
|
||||||
|
{ "name" : "G", "equation" : "$eventsplayed", "description" : "Games played" },
|
||||||
|
{ "name" : "GS", "equation" : "$eventsstarted", "description" : "Games started" },
|
||||||
|
{ "name" : "MPG", "equation" : "$min / $eventsplayed", "precision" : 1, "description" : "Minutes per game" },
|
||||||
|
{ "name" : "FG%", "equation" : "$fgm / $fga", "precision" : 3, "description" : "Field goal percentage" },
|
||||||
|
{ "name" : "FT%", "equation" : "$ftm / $fta", "precision" : 3, "description" : "Free throw percentage" },
|
||||||
|
{ "name" : "3P%", "equation" : "$threepm / $threepa", "precision" : 3, "description" : "3-pointer percentage" },
|
||||||
|
{ "name" : "RPG", "equation" : "( $offreb + $defreb ) / $eventsplayed", "precision" : 1, "description" : "Rebounds per game" },
|
||||||
|
{ "name" : "APG", "equation" : "$ast / $eventsplayed", "precision" : 1, "description" : "Assists per game" },
|
||||||
|
{ "name" : "SPG", "equation" : "$stl / $eventsplayed", "precision" : 1, "description" : "Steals per game" },
|
||||||
|
{ "name" : "BPG", "equation" : "$blk / $eventsplayed", "precision" : 1, "description" : "Blocks per game" },
|
||||||
|
{ "name" : "PPG", "equation" : "$pts / $eventsplayed", "precision" : 1, "description" : "Points per game" },
|
||||||
|
{ "name" : "EFF", "equation" : "$pts + $offreb + $defreb + $ast + $stl + $blk - $fga + $fgm - $fta + $ftm + $to", "description" : "Efficiency rating" }
|
||||||
|
]
|
||||||
|
}
|
||||||
21
presets/cricket.json
Normal file
21
presets/cricket.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"name": "Cricket - coming soon",
|
||||||
|
"outcomes": [
|
||||||
|
"Win",
|
||||||
|
"Loss",
|
||||||
|
"Tie",
|
||||||
|
"Draw"
|
||||||
|
],
|
||||||
|
"results": [
|
||||||
|
],
|
||||||
|
"performance": [
|
||||||
|
],
|
||||||
|
"columns": [
|
||||||
|
],
|
||||||
|
"metrics": [
|
||||||
|
"Height",
|
||||||
|
"Weight"
|
||||||
|
],
|
||||||
|
"statistics": [
|
||||||
|
]
|
||||||
|
}
|
||||||
20
presets/football.json
Normal file
20
presets/football.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "Football - coming soon",
|
||||||
|
"outcomes": [
|
||||||
|
"Win",
|
||||||
|
"Loss",
|
||||||
|
"Tie"
|
||||||
|
],
|
||||||
|
"results": [
|
||||||
|
],
|
||||||
|
"performance": [
|
||||||
|
],
|
||||||
|
"columns": [
|
||||||
|
],
|
||||||
|
"metrics": [
|
||||||
|
"Height",
|
||||||
|
"Weight"
|
||||||
|
],
|
||||||
|
"statistics": [
|
||||||
|
]
|
||||||
|
}
|
||||||
19
presets/footy.json
Normal file
19
presets/footy.json
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "Footy - coming soon",
|
||||||
|
"outcomes": [
|
||||||
|
"Win",
|
||||||
|
"Loss"
|
||||||
|
],
|
||||||
|
"results": [
|
||||||
|
],
|
||||||
|
"performance": [
|
||||||
|
],
|
||||||
|
"columns": [
|
||||||
|
],
|
||||||
|
"metrics": [
|
||||||
|
"Height",
|
||||||
|
"Weight"
|
||||||
|
],
|
||||||
|
"statistics": [
|
||||||
|
]
|
||||||
|
}
|
||||||
19
presets/racing.json
Normal file
19
presets/racing.json
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"name": "Racing - coming soon",
|
||||||
|
"outcomes": [
|
||||||
|
"Win",
|
||||||
|
"Loss"
|
||||||
|
],
|
||||||
|
"results": [
|
||||||
|
],
|
||||||
|
"performance": [
|
||||||
|
],
|
||||||
|
"columns": [
|
||||||
|
],
|
||||||
|
"metrics": [
|
||||||
|
"Height",
|
||||||
|
"Weight"
|
||||||
|
],
|
||||||
|
"statistics": [
|
||||||
|
]
|
||||||
|
}
|
||||||
20
presets/rugby.json
Normal file
20
presets/rugby.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"name": "Rugby - coming soon",
|
||||||
|
"outcomes": [
|
||||||
|
"Win",
|
||||||
|
"Draw",
|
||||||
|
"Loss"
|
||||||
|
],
|
||||||
|
"results": [
|
||||||
|
],
|
||||||
|
"performance": [
|
||||||
|
],
|
||||||
|
"columns": [
|
||||||
|
],
|
||||||
|
"metrics": [
|
||||||
|
"Height",
|
||||||
|
"Weight"
|
||||||
|
],
|
||||||
|
"statistics": [
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,46 +1,43 @@
|
|||||||
{
|
{
|
||||||
"sport": "soccer",
|
"name": "Soccer (Association Football)",
|
||||||
"id": "premier-league",
|
|
||||||
"name": "Premier League",
|
|
||||||
"outcomes": [
|
"outcomes": [
|
||||||
"W",
|
"Win",
|
||||||
"D",
|
"Draw",
|
||||||
"L"
|
"Loss"
|
||||||
],
|
],
|
||||||
"results": [
|
"results": [
|
||||||
"1st Half",
|
{ "name" : "1st Half", "description" : "1st half goals" },
|
||||||
"2nd Half",
|
{ "name" : "2nd Half", "description" : "2nd half goals" },
|
||||||
"Goals"
|
{ "name" : "Goals", "description" : "Total goals", "main" : 1 }
|
||||||
],
|
],
|
||||||
"performance": [
|
"performance": [
|
||||||
"Goals",
|
"Goals",
|
||||||
|
"Shots on Goal",
|
||||||
"Assists",
|
"Assists",
|
||||||
"Fouls",
|
"Fouls",
|
||||||
|
"Fouled",
|
||||||
"Yellow Cards",
|
"Yellow Cards",
|
||||||
"Red Cards"
|
"Red Cards"
|
||||||
],
|
],
|
||||||
"columns": [
|
"columns": [
|
||||||
{ "name" : "P", "equation" : "$events" },
|
{ "name" : "P", "equation" : "$eventsplayed", "description" : "Matches played" },
|
||||||
{ "name" : "W", "equation" : "$w" },
|
{ "name" : "W", "equation" : "$win", "description" : "Wins" },
|
||||||
{ "name" : "D", "equation" : "$d" },
|
{ "name" : "D", "equation" : "$draw", "description" : "Draws" },
|
||||||
{ "name" : "L", "equation" : "$l" },
|
{ "name" : "L", "equation" : "$loss", "description" : "Losses" },
|
||||||
{ "name" : "GF", "equation" : "$goalsfor" },
|
{ "name" : "F", "equation" : "$goalsfor", "priority" : 3, "description" : "Goals for" },
|
||||||
{ "name" : "GA", "equation" : "$goalsagainst" },
|
{ "name" : "A", "equation" : "$goalsagainst", "description" : "Goals against" },
|
||||||
{ "name" : "GD", "equation" : "$goalsfor - $goalsagainst" },
|
{ "name" : "GD", "equation" : "$goalsfor - $goalsagainst", "priority" : 2, "description" : "Goal difference" },
|
||||||
{ "name" : "Pts", "equation" : "$w * 3 + $d" }
|
{ "name" : "PTS", "equation" : "$win * 3 + $draw", "priority" : 1, "description" : "Team points" }
|
||||||
],
|
],
|
||||||
"metrics": [
|
"metrics": [
|
||||||
"Height",
|
"Height",
|
||||||
"Weight"
|
"Weight"
|
||||||
],
|
],
|
||||||
"statistics": [
|
"statistics": [
|
||||||
{ "name" : "Appearances", "equation" : "$events" }
|
{ "name" : "Appearances", "equation" : "$eventsplayed", "description" : "Matches played" },
|
||||||
{ "name" : "Average Goals per Match", "equation" : "$goals / $events" }
|
{ "name" : "Average Goals per Match", "id" : "averagegoals", "equation" : "$goals / $eventsplayed", "precision" : 2 },
|
||||||
{ "name" : "Win Ratio", "equation" : "$w / $events" }
|
{ "name" : "Win Ratio", "equation" : "$win / $eventsplayed * 100", "precision" : 2 },
|
||||||
{ "name" : "Played", "equation" : "$eventsplayed" }
|
{ "name" : "Draw Ratio", "equation" : "$draw / $eventsplayed * 100", "precision" : 2 },
|
||||||
{ "name" : "Played", "equation" : "$eventsplayed" }
|
{ "name" : "Loss Ratio", "equation" : "$loss / $eventsplayed * 100", "precision" : 2 }
|
||||||
{ "name" : "Played", "equation" : "$eventsplayed" }
|
|
||||||
{ "name" : "Played", "equation" : "$eventsplayed" }
|
|
||||||
{ "name" : "Played", "equation" : "$eventsplayed" }
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -46,11 +46,6 @@ final class SportsPress {
|
|||||||
*/
|
*/
|
||||||
public $countries = null;
|
public $countries = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var SP_Sports $sports
|
|
||||||
*/
|
|
||||||
public $sports = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var SP_Formats $formats
|
* @var SP_Formats $formats
|
||||||
*/
|
*/
|
||||||
@@ -214,7 +209,6 @@ final class SportsPress {
|
|||||||
// Classes (used on all pages)
|
// Classes (used on all pages)
|
||||||
include_once( 'includes/class-sp-countries.php' ); // Defines continents and countries
|
include_once( 'includes/class-sp-countries.php' ); // Defines continents and countries
|
||||||
include_once( 'includes/class-sp-formats.php' ); // Defines custom post type formats
|
include_once( 'includes/class-sp-formats.php' ); // Defines custom post type formats
|
||||||
include_once( 'includes/class-sp-sports.php' ); // Defines custom post type formats
|
|
||||||
include_once( 'includes/class-sp-text.php' ); // Defines editable strings
|
include_once( 'includes/class-sp-text.php' ); // Defines editable strings
|
||||||
|
|
||||||
// Include template hooks in time for themes to remove/modify them
|
// Include template hooks in time for themes to remove/modify them
|
||||||
@@ -263,7 +257,6 @@ final class SportsPress {
|
|||||||
// Load class instances
|
// Load class instances
|
||||||
$this->countries = new SP_Countries(); // Countries class
|
$this->countries = new SP_Countries(); // Countries class
|
||||||
$this->formats = new SP_Formats(); // Formats class
|
$this->formats = new SP_Formats(); // Formats class
|
||||||
$this->sports = new SP_Sports(); // Formats class
|
|
||||||
$this->text = new SP_Text(); // Text class
|
$this->text = new SP_Text(); // Text class
|
||||||
|
|
||||||
// Init action
|
// Init action
|
||||||
|
|||||||
Reference in New Issue
Block a user