2013-07-26 14:36:28 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* WooCommerce Settings Page/Tab
|
|
|
|
*
|
2014-08-31 08:22:03 +00:00
|
|
|
* @author WooThemes
|
|
|
|
* @category Admin
|
|
|
|
* @package WooCommerce/Admin
|
2013-07-26 14:36:28 +00:00
|
|
|
* @version 2.1.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
|
|
|
|
|
|
if ( ! class_exists( 'WC_Settings_Page' ) ) :
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WC_Settings_Page
|
|
|
|
*/
|
|
|
|
class WC_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() {
|
2014-02-17 14:30:37 +00:00
|
|
|
return apply_filters( 'woocommerce_get_sections_' . $this->id, array() );
|
2013-07-26 14:36:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Output sections
|
|
|
|
*/
|
|
|
|
public function output_sections() {
|
|
|
|
global $current_section;
|
|
|
|
|
|
|
|
$sections = $this->get_sections();
|
|
|
|
|
2014-08-31 08:22:03 +00:00
|
|
|
if ( empty( $sections ) ) {
|
2013-07-26 14:36:28 +00:00
|
|
|
return;
|
2014-08-31 08:22:03 +00:00
|
|
|
}
|
2013-07-26 14:36:28 +00:00
|
|
|
|
|
|
|
echo '<ul class="subsubsub">';
|
|
|
|
|
2013-08-07 14:15:53 +00:00
|
|
|
$array_keys = array_keys( $sections );
|
|
|
|
|
2014-08-31 08:22:03 +00:00
|
|
|
foreach ( $sections as $id => $label ) {
|
2013-10-22 16:26:18 +00:00
|
|
|
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>';
|
2014-08-31 08:22:03 +00:00
|
|
|
}
|
2013-07-26 14:36:28 +00:00
|
|
|
|
|
|
|
echo '</ul><br class="clear" />';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Output the settings
|
|
|
|
*/
|
|
|
|
public function output() {
|
|
|
|
$settings = $this->get_settings();
|
|
|
|
|
|
|
|
WC_Admin_Settings::output_fields( $settings );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Save settings
|
|
|
|
*/
|
|
|
|
public function save() {
|
|
|
|
global $current_section;
|
|
|
|
|
|
|
|
$settings = $this->get_settings();
|
|
|
|
WC_Admin_Settings::save_fields( $settings );
|
|
|
|
|
2014-08-31 08:22:03 +00:00
|
|
|
if ( $current_section ) {
|
|
|
|
do_action( 'woocommerce_update_options_' . $this->id . '_' . $current_section );
|
|
|
|
}
|
2013-07-26 14:36:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-31 08:22:03 +00:00
|
|
|
endif;
|