Add translator Xyteton & Esports presets close #37

This commit is contained in:
Brian Miyaji
2014-08-25 00:15:32 +10:00
parent 5a4fb57776
commit dd48de0fc3
5 changed files with 104 additions and 11 deletions

View File

@@ -5,7 +5,7 @@
* The SportsPress admin sports class stores preset sport data.
*
* @class SP_Admin_Sports
* @version 0.8
* @version 1.3
* @package SportsPress/Admin
* @category Class
* @author ThemeBoy
@@ -21,11 +21,17 @@ class SP_Admin_Sports {
public static function get_presets() {
if ( empty( self::$presets ) ) {
$presets = array();
self::$options = array(
__( 'Traditional Sports', 'sportspress' ) => array(),
__( 'Esports', 'sportspress' ) => array(),
__( 'Other', 'sportspress' ) => array( 'custom' => __( 'Custom', 'sportspress' ) ),
);
$dir = scandir( SP()->plugin_path() . '/presets' );
$files = array();
if ( $dir ) {
foreach ( $dir as $key => $value ) {
if ( substr( $value, 0, 1 ) !== '.' ) {
if ( substr( $value, 0, 1 ) !== '.' && strpos( $value, '.' ) !== false ) {
$files[] = $value;
}
}
@@ -37,18 +43,49 @@ class SP_Admin_Sports {
$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[ __( 'Traditional Sports', 'sportspress' ) ][ $id ] = $name;
}
self::$options[ 'custom' ] = __( 'Custom', 'sportspress' );
asort( self::$options[ __( 'Traditional Sports', 'sportspress' ) ] );
$dir = scandir( SP()->plugin_path() . '/presets/esports' );
$files = array();
if ( $dir ) {
foreach ( $dir as $key => $value ) {
if ( substr( $value, 0, 1 ) !== '.' && strpos( $value, '.' ) !== false ) {
$files[] = $value;
}
}
}
foreach( $files as $file ) {
$json_data = file_get_contents( SP()->plugin_path() . '/presets/esports/' . $file );
$data = json_decode( $json_data, true );
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[ __( 'Esports', 'sportspress' ) ][ $id ] = $name;
}
asort( self::$options[ __( 'Esports', 'sportspress' ) ] );
self::$presets = apply_filters( 'sportspress_get_presets', $presets );
asort( self::$options );
}
return self::$presets;
}
public static function get_preset( $id ) {
$json_data = file_get_contents( SP()->plugin_path() . '/presets/' . $id . '.json' );
return json_decode( $json_data, true );
$json_data = @file_get_contents( SP()->plugin_path() . '/presets/' . $id . '.json', true );
if ( $json_data ) return json_decode( $json_data, true );
$dir = scandir( SP()->plugin_path() . '/presets' );
if ( $dir ) {
foreach ( $dir as $key => $value ) {
if ( substr( $value, 0, 1 ) !== '.' && strpos( $value, '.' ) === false ) {
$json_data = @file_get_contents( SP()->plugin_path() . '/presets/' . $value . '/' . $id . '.json', true );
if ( $json_data ) return json_decode( $json_data, true );
}
}
}
}
public static function get_preset_options() {
@@ -89,7 +126,7 @@ class SP_Admin_Sports {
$post = self::get_post_array( $result, $post_type );
if ( empty( $post ) ) continue;
$id = self::insert_preset_post( $post, $index );
if ( array_key_exists( 'primary', $result ) ) $primary_result = $post['post_name'];
if ( is_array( $result ) && array_key_exists( 'primary', $result ) ) $primary_result = $post['post_name'];
}
// Performance

View File

@@ -225,7 +225,7 @@ class SP_Admin_Welcome {
$settings = array( array(
'id' => 'sportspress_sport',
'default' => 'soccer',
'type' => 'select',
'type' => 'groupselect',
'class' => $class,
'options' => $sport_options,
));
@@ -240,6 +240,7 @@ class SP_Admin_Welcome {
</div>
<div>
<h4><?php _e( 'Next Steps', 'sportspress' ); ?></h4>
<p><?php _e( 'We&#8217;ve assembled some links to get you started:', 'sportspress' ); ?></p>
<ul class="sportspress-steps">
<li><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => 'sp_team' ), 'post-new.php' ) ) ); ?>" class="welcome-icon welcome-add-team"><?php _e( 'Add New Team', 'sportspress' ); ?></a></li>
<li><a href="<?php echo esc_url( admin_url( add_query_arg( array( 'post_type' => 'sp_player' ), 'post-new.php' ) ) ); ?>" class="welcome-icon welcome-add-player"><?php _e( 'Add New Player', 'sportspress' ); ?></a></li>
@@ -250,7 +251,7 @@ class SP_Admin_Welcome {
<h4><?php _e( 'Translators', 'sportspress' ); ?></h4>
<p><?php _e( 'SportsPress has been kindly translated into several other languages thanks to our translation team. Want to see your name? <a href="https://www.transifex.com/projects/p/sportspress/">Translate SportsPress</a>.', 'sportspress' ); ?></p>
<?php
$translator_handles = array( 'Abdulelah', 'albertone', 'Andrew_Melim', 'ArtakEVN', 'aylaview', 'Bhelpful2', 'bizover', 'BOCo', 'den_zlateva', 'dic_2008', 'doncer', 'Ferenan', 'fredodq', 'hanro', 'hushiea', 'i__k', 'JensZ', 'joegalaxy66', 'JuKi', 'karimjarro', 'King3R', 'krisop', 'latixns', 'massimo.marra', 'MohamedZ', 'poelie', 'rochester', 'Selskei', 'sijo', 'SilverXp', 'Spirossmil', 'Taurus', 'ThemeBoy', 'tyby94', 'valentijnreza' );
$translator_handles = array( 'Abdulelah', 'albertone', 'Andrew_Melim', 'ArtakEVN', 'aylaview', 'Bhelpful2', 'bizover', 'BOCo', 'den_zlateva', 'dic_2008', 'doncer', 'Ferenan', 'fredodq', 'hanro', 'hushiea', 'i__k', 'JensZ', 'joegalaxy66', 'JuKi', 'karimjarro', 'King3R', 'krisop', 'latixns', 'massimo.marra', 'MohamedZ', 'poelie', 'rochester', 'Selskei', 'sijo', 'SilverXp', 'Spirossmil', 'Taurus', 'ThemeBoy', 'tyby94', 'valentijnreza', 'Xyteton' );
$translator_links = array();
foreach ( $translator_handles as $handle ):
$translator_links[] = '<a href="https://www.transifex.com/accounts/profile/' . $handle . '">' . $handle . '</a>';

View File

@@ -49,7 +49,7 @@ class SP_Settings_General extends SP_Settings_Page {
'title' => __( 'Sport', 'sportspress' ),
'id' => 'sportspress_sport',
'default' => 'soccer',
'type' => 'select',
'type' => 'groupselect',
'options' => $presets,
),

View File

@@ -0,0 +1,25 @@
{
"name": "DotA 2",
"outcomes": [
"Win",
"Loss"
],
"results": [
{ "name" : "Rating", "description" : "Rating adjustment", "primary" : 1 }
],
"performance": [
{ "name" : "Rating", "description" : "Rating adjustment" }
],
"columns": [
{ "name" : "W", "equation" : "$win", "priority" : 2, "description" : "Wins" },
{ "name" : "L", "equation" : "$loss", "description" : "Losses" },
{ "name" : "Rating", "equation" : "$rating", "priority" : 1 }
],
"metrics": [
],
"statistics": [
{ "name" : "Wins", "equation" : "$win" },
{ "name" : "Losses", "equation" : "$loss" },
{ "name" : "Winrate", "equation" : "$win / $eventsplayed * 1 0 0" }
]
}

30
presets/esports/lol.json Normal file
View File

@@ -0,0 +1,30 @@
{
"name": "League of Legends",
"outcomes": [
"Win",
"Loss"
],
"results": [
"Kills",
"Deaths",
"Assists",
{ "name" : "Gold", "primary" : 1 }
],
"performance": [
"Kills",
"Deaths",
"Assists",
"Gold"
],
"columns": [
{ "name" : "Wins", "equation" : "$win", "priority" : 1, "description" : "Wins" },
{ "name" : "Losses", "equation" : "$loss", "priority" : 2, "order" : "ASC", "description" : "Losses" }
],
"metrics": [
],
"statistics": [
{ "name" : "Avg. KDA Ratio", "equation" : "( $kills + $assists ) / $deaths", "precision" : 1, "description" : "Average kills/deaths/assists ratio" },
{ "name" : "Avg. Gold per Min", "equation" : "$gold / $eventminutes", "description" : "Average gold per minute" },
{ "name" : "Avg. Total Gold", "equation" : "$gold / $eventsplayed", "description" : "Average total gold" }
]
}