elenka
elenka
Reputation Top 5%
Elena ZH
1 Snippet  (677th place)
Published
1 Channel
Created
1 Channel
Following
54 points  (491st place)
Reputation
Junior Code Generator
Junior Publisher
Junior Popular Coder
Junior Autobiographer
Serious Autobiographer
Master Autobiographer
Junior Wise Coder

Recent Snippets See all snippets by elenka

public by elenka  237506  4  7  0

add WooCommerce settins tab

<?php

if ( !class_exists('Woo_Settings ') ):

/**
 * 
 * @version 1.0
 * @access public
 */
class Woo_Settings {

  public static function init() {
    add_filter( 'woocommerce_settings_tabs_array', __CLASS__ . '::add_settings_tab', 70);
    add_action( 'woocommerce_settings_tabs_settings_orders_page', __CLASS__ . '::settings_tab' );
  }

  /**
  * Add a new settings tab to the WooCommerce settings tabs array.
  */
  public static function add_settings_tab( $settings_tabs ) {
    $settings_tabs['settings_orders_page'] = __( 'Orders Page', 'linen' );
    return $settings_tabs;
  }
  /**
  * Uses the WooCommerce admin fields API to output settings via the @see woocommerce_admin_fields() function.
  *
  * @uses woocommerce_admin_fields()
  * @uses self::get_settings()
  */
  public static function settings_tab() {
    woocommerce_admin_fields( self::get_settings() );
  }

  /**
  * Get all the settings for this plugin for @see woocommerce_admin_fields() function.
  *
  * @return array Array of settings for @see woocommerce_admin_fields() function.
  */
  public static function get_settings() {

    $settings[] = array( 'title' => __( 'Orders Page', 'linen' ), 'type' => 'title', 'desc' => '', 'id' => 'wc_order_customiser_orders_page' );
    $settings[] = array(
      'title'    => __( 'Table Type', 'linen' ),
      'id'       => 'wc_order_customiser_table_type',
      'default'  => 'static',
      'type'     => 'radio',
      'options'  => array(
        'static'  => __( 'Static', 'linen' ),
        'dynamic' => __( 'Dynamic', 'linen' ),
      ),
      'autoload' => true
    );
    $settings[] = array( 'type' => 'sectionend', 'id' => 'wc_order_customiser_orders_page' );

    $settings[] = array( 'title' => __( 'Position & Size', 'linen' ), 'type' => 'title', 'desc' => '', 'id' => 'wc_order_customiser_position_n_size' );
    $settings[] = array(
      'title'    => __( 'Table Type', 'linen' ),
      'id'       => 'wc_order_customiser_table_type',
      'default'  => 'static',
      'type'     => 'radio',
      'options'  => array(
        'static'  => __( 'Static', 'linen' ),
        'dynamic' => __( 'Dynamic', 'linen' ),
      ),
      'autoload' => true
    );
    $settings[] = array( 'type' => 'sectionend', 'id' => 'wc_order_customiser_position_n_size' );

    return apply_filters( 'wc_settings_tab_orders_page', $settings );
  }

  /**
  * Uses the WooCommerce options API to save settings via the @see woocommerce_update_options() function.
  *
  * @uses woocommerce_update_options()
  * @uses self::get_settings()
  */
  public static function update_settings() {
    woocommerce_update_options( self::get_settings() );
  }

	
}
Woo_Settings::init();
endif;
?>                        
;