Fix activation errors

This commit is contained in:
Brian Miyaji
2016-11-03 13:16:35 +11:00
parent 4f42e34426
commit cd7d0c609a
5 changed files with 14 additions and 12 deletions

View File

@@ -23,9 +23,7 @@ class SP_Settings_Events extends SP_Settings_Page {
public function __construct() { public function __construct() {
$this->id = 'events'; $this->id = 'events';
$this->label = __( 'Events', 'sportspress' ); $this->label = __( 'Events', 'sportspress' );
$this->template = 'event'; $this->template = 'event';
$this->templates = SP()->templates->event;
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) ); add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );

View File

@@ -20,7 +20,6 @@ class SP_Settings_Page {
protected $id = ''; protected $id = '';
protected $label = ''; protected $label = '';
protected $template = ''; protected $template = '';
public $templates = array();
/** /**
* Add this page to settings * Add this page to settings
*/ */
@@ -39,6 +38,17 @@ class SP_Settings_Page {
return array(); return array();
} }
/**
* Templates
*
* @return array
*/
public function templates() {
if ( ! isset( $this->template ) ) return array();
$template = $this->template;
return SP()->templates->$template;
}
/** /**
* Output the settings * Output the settings
*/ */
@@ -60,7 +70,7 @@ class SP_Settings_Page {
if ( $current_section ) if ( $current_section )
do_action( 'sportspress_update_options_' . $this->template . '_' . $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 ) ); 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'] ) ) { if ( isset( $_POST['sportspress_template_visibility'] ) && is_array( $_POST['sportspress_template_visibility'] ) ) {
@@ -82,7 +92,7 @@ class SP_Settings_Page {
* @return void * @return void
*/ */
public function layout_setting() { 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' ); $layout = get_option( 'sportspress_' . $this->template . '_template_order' );
if ( false === $layout ) { if ( false === $layout ) {
@@ -135,7 +145,7 @@ class SP_Settings_Page {
* @return void * @return void
*/ */
public function tabs_setting() { 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' ); $layout = get_option( 'sportspress_' . $this->template . '_template_order' );
if ( false === $layout ) { if ( false === $layout ) {

View File

@@ -23,9 +23,7 @@ class SP_Settings_Players extends SP_Settings_Page {
public function __construct() { public function __construct() {
$this->id = 'players'; $this->id = 'players';
$this->label = __( 'Players', 'sportspress' ); $this->label = __( 'Players', 'sportspress' );
$this->template = 'player'; $this->template = 'player';
$this->templates = SP()->templates->player;
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) ); add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );

View File

@@ -23,9 +23,7 @@ class SP_Settings_Staff extends SP_Settings_Page {
public function __construct() { public function __construct() {
$this->id = 'staff'; $this->id = 'staff';
$this->label = __( 'Staff', 'sportspress' ); $this->label = __( 'Staff', 'sportspress' );
$this->template = 'staff'; $this->template = 'staff';
$this->templates = SP()->templates->staff;
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) ); add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );

View File

@@ -23,9 +23,7 @@ class SP_Settings_Teams extends SP_Settings_Page {
public function __construct() { public function __construct() {
$this->id = 'teams'; $this->id = 'teams';
$this->label = __( 'Teams', 'sportspress' ); $this->label = __( 'Teams', 'sportspress' );
$this->template = 'team'; $this->template = 'team';
$this->templates = SP()->templates->team;
add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 ); add_filter( 'sportspress_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) ); add_action( 'sportspress_settings_' . $this->id, array( $this, 'output' ) );