Move presets to json objects

This commit is contained in:
Brian Miyaji
2014-05-02 17:27:18 +10:00
parent 6ce1953dc2
commit 388817111a
22 changed files with 438 additions and 365 deletions

View File

@@ -599,95 +599,6 @@ class SP_Admin_Settings {
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;

View File

@@ -11,7 +11,9 @@
* @author ThemeBoy
*/
class SP_Admin_Sports {
private static $presets = array();
public static $presets = array();
public static $options = array();
/**
* Include the preset classes
@@ -19,14 +21,11 @@ class SP_Admin_Sports {
public static function get_presets() {
if ( empty( self::$presets ) ) {
$presets = array();
include( 'presets/class-sp-preset-sport.php' );
$dir = scandir( SP()->plugin_path() . '/presets' );
$files = array();
if ( $dir ) {
foreach ( $dir as $key => $value ) {
if ( ! in_array( $value, array( ".",".." ) ) ) {
if ( substr( $value, 0, 1 ) !== '.' ) {
$files[] = $value;
}
}
@@ -34,41 +33,163 @@ class SP_Admin_Sports {
foreach( $files as $file ) {
$json_data = file_get_contents( SP()->plugin_path() . '/presets/' . $file );
$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;
}
//$presets[] = include( 'presets/class-sp-preset-soccer.php' );
//$presets[] = include( 'presets/class-sp-preset-baseball.php' );SP_TEMPLATE_PATH
self::$options[ 'custom' ] = __( 'Custom', 'sportspress' );
self::$presets = apply_filters( 'sportspress_get_presets', $presets );
}
return self::$presets;
}
public static function get_preset_options() {
$presets = self::get_presets();
$options = apply_filters( 'sportspress_sport_presets_array', array() );
return $options;
public static function get_preset( $id ) {
$json_data = file_get_contents( SP()->plugin_path() . '/presets/' . $id . '.json' );
return json_decode( $json_data, true );
}
/** @var array Array of sports */
private $data;
public static function get_preset_options() {
$presets = self::get_presets();
return self::$options;
}
/**
* Constructor for the sports class - defines all preset sports.
* Apply preset
*
* @access public
* @return void
*/
public function __construct() {
$this->data = sp_get_sport_presets();
public static function apply_preset( $id ) {
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 ) {
return ( array_key_exists( $key, $this->data ) ? $this->data[ $key ] : null );
public static function delete_preset_posts( $post_type = 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 ){
$this->data[ $key ] = $value;
public static function get_post_array( $post = array(), $post_type = null ) {
$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;
}
}

View File

@@ -195,8 +195,8 @@ class SP_Admin_Welcome {
<?php
// Save settings
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) != $_POST['sportspress_sport'] ):
$sport = SP()->sports->$_POST['sportspress_sport'];
SP_Admin_Settings::configure_sport( $sport );
$sport = $_POST['sportspress_sport'];
SP_Admin_Sports::apply_preset( $sport );
update_option( 'sportspress_sport', $_POST['sportspress_sport'] );
endif;
if ( isset( $_POST['sportspress_default_country'] ) ):
@@ -222,7 +222,7 @@ class SP_Admin_Welcome {
</p>
<h4><?php _e( 'Sport', 'sportspress' ); ?></h4>
<?php
$sport_options = sp_get_sport_options();
$sport_options = SP_Admin_Sports::get_preset_options();
$class = 'chosen-select' . ( is_rtl() ? ' chosen-rtl' : '' );
$settings = array( array(
'id' => 'sportspress_sport',

View File

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

View File

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

View File

@@ -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;

View File

@@ -102,6 +102,7 @@ class SP_Settings_Config extends SP_Settings_Page {
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Variable', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
<th scope="col" class="edit"></th>
</tr>
</thead>
@@ -109,6 +110,7 @@ class SP_Settings_Config extends SP_Settings_Page {
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="row-title"><?php echo $row->post_title; ?></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>
</tr>
<?php $i++; endforeach; ?>
@@ -149,50 +151,50 @@ class SP_Settings_Config extends SP_Settings_Page {
<p class="description"><?php _e( 'Used for events.' ); ?></p>
</th>
<td class="forminp">
<fieldset>
<legend class="screen-reader-text"><span><?php _e( 'Team Results', 'sportspress' ) ?></span></legend>
<table class="widefat sp-admin-config-table">
<thead>
<tr>
<th scope="col"><?php _e( 'Primary', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Variables', 'sportspress' ); ?></th>
<th scope="col" class="edit"></th>
</tr>
</thead>
<tfoot>
<tr>
<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">
<?php
if ( sizeof( $data ) > 0 ):
$default = end( $data );
reset( $data );
printf( __( 'Default (%s)', 'sportspress' ), $default->post_title );
else:
_e( 'Default', 'sportspress' );
endif;
?>
</label></th>
</tr>
</tfoot>
<?php $i = 0; foreach ( $data as $row ): ?>
<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="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 class="edit"><a class="button" href="<?php echo get_edit_post_link( $row->ID ); ?>"><?php _e( 'Edit', 'sportspress' ); ?></s></td>
</tr>
<?php $i++; endforeach; ?>
</table>
<div class="tablenav bottom">
<div class="alignleft actions">
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_result' ); ?>"><?php _e( 'View All', 'sportspress' ); ?></a>
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_result' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
</div>
<br class="clear">
<legend class="screen-reader-text"><span><?php _e( 'Team Results', 'sportspress' ) ?></span></legend>
<table class="widefat sp-admin-config-table">
<thead>
<tr>
<th scope="col"><?php _e( 'Primary', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Variables', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
<th scope="col" class="edit"></th>
</tr>
</thead>
<tfoot>
<tr>
<th class="radio"><input type="radio" id="sportspress_primary_result_0" name="sportspress_primary_result" value="0" <?php checked( $selection, 0 ); ?>></th>
<th colspan="4"><label for="sportspress_primary_result_0">
<?php
if ( sizeof( $data ) > 0 ):
$default = end( $data );
reset( $data );
printf( __( 'Default (%s)', 'sportspress' ), $default->post_title );
else:
_e( 'Default', 'sportspress' );
endif;
?>
</label></th>
</tr>
</tfoot>
<?php $i = 0; foreach ( $data as $row ): ?>
<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="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><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>
</tr>
<?php $i++; endforeach; ?>
</table>
<div class="tablenav bottom">
<div class="alignleft actions">
<a class="button" id="doaction" href="<?php echo admin_url( 'edit.php?post_type=sp_result' ); ?>"><?php _e( 'View All', 'sportspress' ); ?></a>
<a class="button" id="doaction2" href="<?php echo admin_url( 'post-new.php?post_type=sp_result' ); ?>"><?php _e( 'Add New', 'sportspress' ); ?></a>
</div>
</fieldset>
<br class="clear">
</div>
</td>
</tr>
<?php
@@ -225,6 +227,7 @@ class SP_Settings_Config extends SP_Settings_Page {
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Variable', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
<th scope="col" class="edit"></th>
</tr>
</thead>
@@ -232,6 +235,7 @@ class SP_Settings_Config extends SP_Settings_Page {
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="row-title"><?php echo $row->post_title; ?></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>
</tr>
<?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( 'Rounding', '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>
</tr>
</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_precision( $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>
</tr>
<?php $i++; endforeach; ?>
@@ -332,7 +338,7 @@ class SP_Settings_Config extends SP_Settings_Page {
<tr>
<th scope="col"><?php _e( 'Label', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Variable', 'sportspress' ); ?></th>
<th scope="col">&nbsp;</th>
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
<th scope="col" class="edit"></th>
</tr>
</thead>
@@ -340,7 +346,7 @@ class SP_Settings_Config extends SP_Settings_Page {
<tr<?php if ( $i % 2 == 0 ) echo ' class="alternate"'; ?>>
<td class="row-title"><?php echo $row->post_title; ?></td>
<td><?php echo $row->post_name; ?></td>
<td>&nbsp;</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>
</tr>
<?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( 'Equation', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Rounding', 'sportspress' ); ?></th>
<th scope="col"><?php _e( 'Description', 'sportspress' ); ?></th>
<th scope="col" class="edit"></th>
</tr>
</thead>
@@ -395,6 +402,7 @@ class SP_Settings_Config extends SP_Settings_Page {
<td><?php echo $row->post_name; ?></td>
<td><?php echo sp_get_post_equation( $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>
</tr>
<?php $i++; endforeach; ?>

View File

@@ -40,9 +40,7 @@ class SP_Settings_General extends SP_Settings_Page {
*/
public function get_settings() {
$sports = new SP_Admin_Sports();
$presets = $sports->get_preset_options();
$presets = SP_Admin_Sports::get_preset_options();
return apply_filters( 'sportspress_general_settings', array(
@@ -109,8 +107,8 @@ class SP_Settings_General extends SP_Settings_Page {
*/
public function save() {
if ( isset( $_POST['sportspress_sport'] ) && ! empty( $_POST['sportspress_sport'] ) && get_option( 'sportspress_sport', null ) != $_POST['sportspress_sport'] ):
$sport = SP()->sports->$_POST['sportspress_sport'];
SP_Admin_Settings::configure_sport( $sport );
$sport = $_POST['sportspress_sport'];
SP_Admin_Sports::apply_preset( $sport );
update_option( '_sp_needs_welcome', 0 );
endif;

View File

@@ -135,8 +135,7 @@ class SP_Install {
if ( ! get_option( 'sportspress_installed' ) ) {
// Configure default sport
$sport = 'soccer';
$options = sp_get_sport_presets();
SP_Admin_Settings::configure_sport( $options[ $sport ] );
SP_Admin_Sports::apply_preset( $sport );
update_option( 'sportspress_sport', $sport );
update_option( 'sportspress_installed', 1 );
}

View File

@@ -175,7 +175,7 @@ class SP_Post_types {
'publicly_queryable' => false,
'exclude_from_search' => true,
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes' ),
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
'has_archive' => false,
'show_in_nav_menus' => false,
'can_export' => false,
@@ -205,7 +205,7 @@ class SP_Post_types {
'publicly_queryable' => false,
'exclude_from_search' => true,
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes' ),
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
'has_archive' => false,
'show_in_nav_menus' => false,
'can_export' => false,
@@ -235,7 +235,7 @@ class SP_Post_types {
'publicly_queryable' => false,
'exclude_from_search' => true,
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes' ),
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
'has_archive' => false,
'show_in_nav_menus' => false,
'can_export' => false,
@@ -265,7 +265,7 @@ class SP_Post_types {
'publicly_queryable' => false,
'exclude_from_search' => true,
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes' ),
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
'has_archive' => false,
'show_in_nav_menus' => false,
'can_export' => false,
@@ -295,7 +295,7 @@ class SP_Post_types {
'publicly_queryable' => false,
'exclude_from_search' => true,
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes' ),
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
'has_archive' => false,
'show_in_nav_menus' => false,
'can_export' => false,
@@ -325,7 +325,7 @@ class SP_Post_types {
'publicly_queryable' => false,
'exclude_from_search' => true,
'hierarchical' => false,
'supports' => array( 'title', 'page-attributes' ),
'supports' => array( 'title', 'page-attributes', 'excerpt' ),
'has_archive' => false,
'show_in_nav_menus' => false,
'can_export' => false,

View File

@@ -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;
}
}

View File

@@ -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.
* @return array

View File

@@ -110,6 +110,12 @@ function sportspress_gettext( $translated_text, $untranslated_text, $domain ) {
if ( is_admin() ):
if ( is_sp_config_type( $typenow ) ):
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':
$translated_text = ( in_array( $typenow, array( 'sp_column', 'sp_statistic' ) ) ) ? __( 'Key', 'sportspress' ) : __( 'Variable', 'sportspress' );
break;