Initialize settings classes
This commit is contained in:
94
includes/admin/settings/class-sp-settings-page.php
Normal file
94
includes/admin/settings/class-sp-settings-page.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* SportsPress Settings Page/Tab
|
||||
*
|
||||
* @author ThemeBoy
|
||||
* @category Admin
|
||||
* @package SportsPress/Admin
|
||||
* @version 0.7
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
||||
|
||||
if ( ! class_exists( 'SP_Settings_Page' ) ) :
|
||||
|
||||
/**
|
||||
* SP_Settings_Page
|
||||
*/
|
||||
class SP_Settings_Page {
|
||||
|
||||
protected $id = '';
|
||||
protected $label = '';
|
||||
|
||||
/**
|
||||
* Add this page to settings
|
||||
*/
|
||||
public function add_settings_page( $pages ) {
|
||||
$pages[ $this->id ] = $this->label;
|
||||
|
||||
return $pages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get settings array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_settings() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sections
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function get_sections() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Output sections
|
||||
*/
|
||||
public function output_sections() {
|
||||
global $current_section;
|
||||
|
||||
$sections = $this->get_sections();
|
||||
|
||||
if ( empty( $sections ) )
|
||||
return;
|
||||
|
||||
echo '<ul class="subsubsub">';
|
||||
|
||||
$array_keys = array_keys( $sections );
|
||||
|
||||
foreach ( $sections as $id => $label )
|
||||
echo '<li><a href="' . admin_url( 'admin.php?page=wc-settings&tab=' . $this->id . '§ion=' . sanitize_title( $id ) ) . '" class="' . ( $current_section == $id ? 'current' : '' ) . '">' . $label . '</a> ' . ( end( $array_keys ) == $id ? '' : '|' ) . ' </li>';
|
||||
|
||||
echo '</ul><br class="clear" />';
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the settings
|
||||
*/
|
||||
public function output() {
|
||||
$settings = $this->get_settings();
|
||||
|
||||
SP_Admin_Settings::output_fields( $settings );
|
||||
}
|
||||
|
||||
/**
|
||||
* Save settings
|
||||
*/
|
||||
public function save() {
|
||||
global $current_section;
|
||||
|
||||
$settings = $this->get_settings();
|
||||
SP_Admin_Settings::save_fields( $settings );
|
||||
|
||||
if ( $current_section )
|
||||
do_action( 'sportspress_update_options_' . $this->id . '_' . $current_section );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
Reference in New Issue
Block a user