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  * Add a POS settings on the permalink admin page
 5  *
 6  * @class    WC_POS_Admin_Permlink
 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 class Permalink {
15 
16   const DB_KEY = 'woocommerce_pos_settings_permalink';
17 
18   /**
19    * Constructor
20    */
21   public function __construct() {
22     $this->init();
23     $this->save();
24   }
25 
26   /**
27    * Hook into the permalinks setting api
28    */
29   private function init() {
30     add_settings_field(
31       'woocommerce-pos-permalink',
32       _x( 'POS base', 'Permalink setting, eg: /pos', 'woocommerce-pos' ),
33       array( $this, 'pos_slug_input' ),
34       'permalink',
35       'optional'
36     );
37   }
38 
39   /**
40    * Output the POS field
41    */
42   public function pos_slug_input() {
43     $slug = self::get_slug();
44     if( $slug === 'pos' ) $slug = ''; // use placeholder
45     echo '<input name="woocommerce_pos_permalink" type="text" class="regular-text code" value="'. esc_attr( $slug ) .'" placeholder="pos" />';
46   }
47 
48   /**
49    * Watch for $_POST and save POS setting
50    * - sanitize field and remove slash from start and end
51    */
52   public function save() {
53     if( isset( $_POST['woocommerce_pos_permalink'] ) ) {
54       $permalink = trim( sanitize_text_field( $_POST['woocommerce_pos_permalink'] ), '/\\' );
55       update_option( self::DB_KEY, $permalink );
56     }
57   }
58 
59   /**
60    * Return the custom slug, defaults to 'pos'
61    * @return string
62    */
63   static public function get_slug(){
64     $slug = get_option( self::DB_KEY );
65     return empty( $slug ) ? 'pos' : sanitize_text_field( $slug );
66   }
67 
68 }
API documentation generated by ApiGen