diff --git a/includes/admin/settings/class-sp-settings-events.php b/includes/admin/settings/class-sp-settings-events.php index f9401839..e167d27e 100644 --- a/includes/admin/settings/class-sp-settings-events.php +++ b/includes/admin/settings/class-sp-settings-events.php @@ -23,9 +23,7 @@ class SP_Settings_Events extends SP_Settings_Page { public function __construct() { $this->id = 'events'; $this->label = __( 'Events', 'sportspress' ); - $this->template = 'event'; - $this->templates = SP()->templates->event; add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) ); diff --git a/includes/admin/settings/class-sp-settings-page.php b/includes/admin/settings/class-sp-settings-page.php index 1be2b050..091a160d 100644 --- a/includes/admin/settings/class-sp-settings-page.php +++ b/includes/admin/settings/class-sp-settings-page.php @@ -20,7 +20,6 @@ class SP_Settings_Page { protected $id = ''; protected $label = ''; protected $template = ''; - public $templates = array(); /** * Add this page to settings */ @@ -39,6 +38,17 @@ class SP_Settings_Page { return array(); } + /** + * Templates + * + * @return array + */ + public function templates() { + if ( ! isset( $this->template ) ) return array(); + $template = $this->template; + return SP()->templates->$template; + } + /** * Output the settings */ @@ -60,7 +70,7 @@ class SP_Settings_Page { if ( $current_section ) do_action( 'sportspress_update_options_' . $this->template . '_' . $current_section ); - if ( ! empty( $this->templates ) ) + if ( ! empty( $this->templates() ) ) update_option( 'sportspress_' . $this->template . '_template_order', sp_array_value( $_POST, 'sportspress_' . $this->template . '_template_order', false ) ); if ( isset( $_POST['sportspress_template_visibility'] ) && is_array( $_POST['sportspress_template_visibility'] ) ) { @@ -82,7 +92,7 @@ class SP_Settings_Page { * @return void */ public function layout_setting() { - $templates = apply_filters( 'sportspress_' . $this->template . '_templates', $this->templates ); + $templates = apply_filters( 'sportspress_' . $this->template . '_templates', $this->templates() ); $layout = get_option( 'sportspress_' . $this->template . '_template_order' ); if ( false === $layout ) { @@ -135,7 +145,7 @@ class SP_Settings_Page { * @return void */ public function tabs_setting() { - $templates = apply_filters( 'sportspress_' . $this->template . '_templates', $this->templates ); + $templates = apply_filters( 'sportspress_' . $this->template . '_templates', $this->templates() ); $layout = get_option( 'sportspress_' . $this->template . '_template_order' ); if ( false === $layout ) { diff --git a/includes/admin/settings/class-sp-settings-players.php b/includes/admin/settings/class-sp-settings-players.php index 23cebfaf..847faaee 100644 --- a/includes/admin/settings/class-sp-settings-players.php +++ b/includes/admin/settings/class-sp-settings-players.php @@ -23,9 +23,7 @@ class SP_Settings_Players extends SP_Settings_Page { public function __construct() { $this->id = 'players'; $this->label = __( 'Players', 'sportspress' ); - $this->template = 'player'; - $this->templates = SP()->templates->player; add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) ); diff --git a/includes/admin/settings/class-sp-settings-staff.php b/includes/admin/settings/class-sp-settings-staff.php index e1fb95dc..2c13a371 100644 --- a/includes/admin/settings/class-sp-settings-staff.php +++ b/includes/admin/settings/class-sp-settings-staff.php @@ -23,9 +23,7 @@ class SP_Settings_Staff extends SP_Settings_Page { public function __construct() { $this->id = 'staff'; $this->label = __( 'Staff', 'sportspress' ); - $this->template = 'staff'; - $this->templates = SP()->templates->staff; add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) ); diff --git a/includes/admin/settings/class-sp-settings-teams.php b/includes/admin/settings/class-sp-settings-teams.php index 6d26c523..ae4a48a6 100644 --- a/includes/admin/settings/class-sp-settings-teams.php +++ b/includes/admin/settings/class-sp-settings-teams.php @@ -23,9 +23,7 @@ class SP_Settings_Teams extends SP_Settings_Page { public function __construct() { $this->id = 'teams'; $this->label = __( 'Teams', 'sportspress' ); - $this->template = 'team'; - $this->templates = SP()->templates->team; add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );