diff --git a/includes/admin/class-sp-admin-settings.php b/includes/admin/class-sp-admin-settings.php index 9b304c66..c525f946 100644 --- a/includes/admin/class-sp-admin-settings.php +++ b/includes/admin/class-sp-admin-settings.php @@ -28,6 +28,7 @@ class SP_Admin_Settings { if ( empty( self::$settings ) ) { $settings = array(); + include_once( 'class-sp-admin-sports.php' ); include_once( 'settings/class-sp-settings-page.php' ); $settings[] = include( 'settings/class-sp-settings-general.php' ); diff --git a/includes/admin/class-sp-admin-sports.php b/includes/admin/class-sp-admin-sports.php new file mode 100644 index 00000000..2393f3c9 --- /dev/null +++ b/includes/admin/class-sp-admin-sports.php @@ -0,0 +1,74 @@ +plugin_path() . '/presets' ); + $files = array(); + if ( $dir ) { + foreach ( $dir as $key => $value ) { + if ( ! in_array( $value, array( ".",".." ) ) ) { + $files[] = $value; + } + } + } + foreach( $files as $file ) { + $json_data = file_get_contents( SP()->plugin_path() . '/presets/' . $file ); + $data = json_decode( $json_data, true ); + pr( $data ); + } + + //$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 ); + } + return self::$presets; + } + + public static function get_preset_options() { + $presets = self::get_presets(); + $options = apply_filters( 'sportspress_sport_presets_array', array() ); + return $options; + } + + /** @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; + } +} diff --git a/includes/admin/presets/class-sp-preset-baseball.php b/includes/admin/presets/class-sp-preset-baseball.php new file mode 100644 index 00000000..a475e501 --- /dev/null +++ b/includes/admin/presets/class-sp-preset-baseball.php @@ -0,0 +1,33 @@ +id = 'baseball'; + $this->label = __( 'Baseball', 'sportspress' ); + + add_filter( 'sportspress_sport_presets_array', array( $this, 'add_sport_preset' ), 20 ); + } +} + +endif; + +return new SP_Preset_Baseball(); diff --git a/includes/admin/presets/class-sp-preset-soccer.php b/includes/admin/presets/class-sp-preset-soccer.php new file mode 100644 index 00000000..6d041d5d --- /dev/null +++ b/includes/admin/presets/class-sp-preset-soccer.php @@ -0,0 +1,33 @@ +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(); diff --git a/includes/admin/presets/class-sp-preset-sport.php b/includes/admin/presets/class-sp-preset-sport.php new file mode 100644 index 00000000..99d43803 --- /dev/null +++ b/includes/admin/presets/class-sp-preset-sport.php @@ -0,0 +1,33 @@ +id ] = $this->label; + + return $presets; + } +} + +endif; diff --git a/includes/admin/settings/class-sp-settings-general.php b/includes/admin/settings/class-sp-settings-general.php index 961eb62d..1f0ff559 100644 --- a/includes/admin/settings/class-sp-settings-general.php +++ b/includes/admin/settings/class-sp-settings-general.php @@ -39,7 +39,10 @@ class SP_Settings_General extends SP_Settings_Page { * @return array */ public function get_settings() { - $sports = sp_get_sport_options(); + + $sports = new SP_Admin_Sports(); + + $presets = $sports->get_preset_options(); return apply_filters( 'sportspress_general_settings', array( @@ -52,7 +55,7 @@ class SP_Settings_General extends SP_Settings_Page { 'id' => 'sportspress_sport', 'default' => 'soccer', 'type' => 'select', - 'options' => $sports, + 'options' => $presets, ), array( 'type' => 'sectionend', 'id' => 'general_options' ), diff --git a/includes/class-sp-sports.php b/includes/class-sp-sports.php index 13774bd0..50697814 100644 --- a/includes/class-sp-sports.php +++ b/includes/class-sp-sports.php @@ -1,16 +1,33 @@ Import and choose == Changelog == += 0.8.2 = +* Fix - Add content in main loop only. + = 0.8.1 = * Tweak - Output player statistics in system status. * Tweak - Prepend templates to content instead of outputting directly. -* Fix - Add content in main loop only. * Fix - Enable metrics usage in individual player statistics. = 0.8 = diff --git a/sportspress.php b/sportspress.php index 5711ac58..3f0393f7 100644 --- a/sportspress.php +++ b/sportspress.php @@ -3,7 +3,7 @@ * Plugin Name: SportsPress * Plugin URI: http://wordpress.org/plugins/sportspress * Description: Manage your club and its players, staff, events, league tables, and player lists. - * Version: 0.8.1 + * Version: 0.8.3 * Author: ThemeBoy * Author URI: http://themeboy.com * Requires at least: 3.8 @@ -26,14 +26,14 @@ if ( ! class_exists( 'SportsPress' ) ) : * Main SportsPress Class * * @class SportsPress - * @version 0.8.1 + * @version 0.8.3 */ final class SportsPress { /** * @var string */ - public $version = '0.8.1'; + public $version = '0.8.3'; /** * @var SporsPress The single instance of the class