Overview
  • Namespace
  • Class

Namespaces

  • None
  • WC_POS
    • Admin
      • Settings
        • Receipt
    • API
    • Gateways
    • Integrations
    • Products

Classes

  • WC_POS\Activator
  • WC_POS\Admin
  • WC_POS\Admin\Gateways
  • WC_POS\Admin\Menu
  • WC_POS\Admin\Notices
  • WC_POS\Admin\Orders
  • WC_POS\Admin\Page
  • WC_POS\Admin\Permalink
  • WC_POS\Admin\Plugins
  • WC_POS\Admin\Products
  • WC_POS\Admin\Settings
  • WC_POS\Admin\Settings\Access
  • WC_POS\Admin\Settings\Checkout
  • WC_POS\Admin\Settings\Customers
  • WC_POS\Admin\Settings\Gateways
  • WC_POS\Admin\Settings\General
  • WC_POS\Admin\Settings\HotKeys
  • WC_POS\Admin\Settings\Page
  • WC_POS\Admin\Settings\Receipt\Options
  • WC_POS\Admin\Settings\Receipt\Template
  • WC_POS\Admin\Settings\Receipts
  • WC_POS\Admin\Settings\Status
  • WC_POS\Admin\Settings\Tools
  • WC_POS\Admin\Status
  • WC_POS\Ajax
  • WC_POS\API
  • WC_POS\API\Coupons
  • WC_POS\API\Customers
  • WC_POS\API\Gateways
  • WC_POS\API\i18n
  • WC_POS\API\Orders
  • WC_POS\API\Params
  • WC_POS\API\Payload
  • WC_POS\API\Products
  • WC_POS\API\Settings
  • WC_POS\API\Support
  • WC_POS\API\Templates
  • WC_POS\Customers
  • WC_POS\Deactivator
  • WC_POS\Gateways
  • WC_POS\Gateways\Card
  • WC_POS\Gateways\Cash
  • WC_POS\i18n
  • WC_POS\Integrations\Bookings
  • WC_POS\Products
  • WC_POS\Products\Visibility
  • WC_POS\Setup
  • WC_POS\Status
  • WC_POS\Tax
  • WC_POS\Template

Functions

  • is_pos
  • is_pos_admin
  • wc_pos_get_option
  • wc_pos_json_encode
  • wc_pos_locate_template
  • wc_pos_trim_html_string
  • wc_pos_update_option
  • wc_pos_url
  1 <?php
  2 
  3 /**
  4  * POS Settings Class
  5  *
  6  * @class    WC_POS_Admin_Settings
  7  * @package  WooCommerce POS
  8  * @author   Paul Kilmurray <paul@kilbot.com.au>
  9  * @link     http://www.woopos.com.au
 10  */
 11 
 12 namespace WC_POS\Admin;
 13 
 14 use WC_POS\Template;
 15 
 16 class Settings extends Page {
 17 
 18   /* @var string JS var with page id, used for API requests */
 19   public $wc_pos_adminpage = 'admin_settings';
 20 
 21   /**
 22    * @var array settings handlers
 23    */
 24   static public $handlers = array(
 25     'general'   => '\WC_POS\Admin\Settings\General',
 26     'customers' => '\WC_POS\Admin\Settings\Customers',
 27     'checkout'  => '\WC_POS\Admin\Settings\Checkout',
 28     'receipts'  => '\WC_POS\Admin\Settings\Receipts',
 29     'hotkeys'   => '\WC_POS\Admin\Settings\HotKeys',
 30     'access'    => '\WC_POS\Admin\Settings\Access'
 31   );
 32 
 33   /**
 34    * Add Settings page to admin menu
 35    */
 36   public function admin_menu() {
 37     $this->screen_id = add_submenu_page(
 38       \WC_POS\PLUGIN_NAME,
 39       /* translators: wordpress */
 40       __( 'Settings' ),
 41       /* translators: wordpress */
 42       __( 'Settings' ),
 43       'manage_woocommerce_pos',
 44       'wc_pos_settings',
 45       array( $this, 'display_settings_page' )
 46     );
 47 
 48     parent::admin_menu();
 49   }
 50 
 51   /**
 52    * Output the settings pages
 53    */
 54   public function display_settings_page() {
 55     include 'views/settings.php';
 56   }
 57 
 58   /**
 59    * Returns array of settings classes
 60    * @return mixed|void
 61    */
 62   static public function handlers(){
 63     return apply_filters( 'woocommerce_pos_admin_settings_handlers', self::$handlers );
 64   }
 65 
 66   /**
 67    * Settings scripts
 68    */
 69   public function enqueue_admin_scripts() {
 70     global $wp_scripts;
 71     $wp_scripts->queue = array();
 72 
 73     // deregister scripts
 74     wp_deregister_script( 'jquery' );
 75     wp_deregister_script( 'underscore' );
 76     wp_deregister_script( 'select2' );
 77     wp_deregister_script( 'backbone' );
 78 
 79     // register
 80     $external_libs = Template::get_external_js_libraries();
 81     wp_register_script( 'jquery', $external_libs[ 'jquery' ], false, null, true );
 82     wp_register_script( 'lodash', $external_libs[ 'lodash' ], array( 'jquery' ), null, true );
 83     wp_register_script( 'backbone', $external_libs[ 'backbone' ], array( 'jquery', 'lodash' ), null, true );
 84     wp_register_script( 'backbone.radio', $external_libs[ 'radio' ], array( 'jquery', 'backbone', 'lodash' ), null, true );
 85     wp_register_script( 'marionette', $external_libs[ 'marionette' ], array( 'jquery', 'backbone', 'lodash' ), null, true );
 86     wp_register_script( 'handlebars', $external_libs[ 'handlebars' ], false, null, true );
 87     wp_register_script( 'moment', $external_libs[ 'moment' ], false, null, true );
 88     wp_register_script( 'accounting', $external_libs[ 'accounting' ], false, null, true );
 89     wp_register_script( 'select2', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.1/js/select2.min.js', array( 'jquery' ), null, true );
 90     wp_register_script( 'ace', 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.2/ace.js', false, null, true );
 91 
 92     $build = defined( '\SCRIPT_DEBUG' ) && \SCRIPT_DEBUG ? 'build' : 'min';
 93 
 94     wp_enqueue_script(
 95       \WC_POS\PLUGIN_NAME . '-admin-settings-app',
 96       \WC_POS\PLUGIN_URL . 'assets/js/admin-settings.' . $build . '.js',
 97       array( 'backbone', 'backbone.radio', 'marionette', 'handlebars', 'accounting', 'moment', 'select2', 'ace' ),
 98       \WC_POS\VERSION,
 99       true
100     );
101 
102     $scripts = apply_filters( 'woocommerce_pos_admin_enqueue_scripts', array() );
103     if ( isset( $scripts[ 'locale' ] ) ) {
104       wp_enqueue_script(
105         \WC_POS\PLUGIN_NAME . '-js-locale',
106         $scripts[ 'locale' ],
107         array( \WC_POS\PLUGIN_NAME . '-admin-settings-app' ),
108         \WC_POS\VERSION,
109         true
110       );
111     }
112   }
113 
114 }
API documentation generated by ApiGen