WC_POS_Admin_Settings_HotKeys

Administrative Tools.

Defined (1)

The class is defined in the following location(s).

/includes/admin/settings/class-wc-pos-hotkeys.php  
  1. class WC_POS_Admin_Settings_HotKeys extends WC_POS_Admin_Settings_Abstract { 
  2.  
  3. protected static $instance; 
  4. private $labels; 
  5.  
  6. /** 
  7. * Each settings tab requires an id and label 
  8. */ 
  9. public function __construct() { 
  10. $this->id = 'hotkeys'; 
  11. $this->label = _x( 'HotKeys', 'keyboard shortcuts', 'woocommerce-pos' ); 
  12.  
  13. $this->defaults = array( 
  14. 'hotkeys' => array( 
  15. 'help' => array( 
  16. 'key' => '?' 
  17. ),  
  18. 'barcode' => array( 
  19. 'key' => 'B' 
  20. ),  
  21. 'search' => array( 
  22. 'key' => 'V' 
  23. ),  
  24. 'sync' => array( 
  25. 'key' => 'S' 
  26. ); 
  27.  
  28. $this->labels = array( 
  29. 'help' => __( 'Help screen', 'woocommerce-pos' ),  
  30. 'barcode' => __( 'Barcode search', 'woocommerce-pos' ),  
  31. 'search' => /** translators: woocommerce */__( 'Search', 'woocommerce' ),  
  32. 'new' => __( 'New order', 'woocommerce-pos' ),  
  33. 'sync' => __( 'Sync with server', 'woocommerce-pos' ) 
  34. ); 
  35.  
  36. public function get($key = false) { 
  37. $data = get_option( $this->option_name() ); 
  38. if(!$data) { $data = $this->defaults; } 
  39. $data['hotkeys'] = array_merge($this->defaults['hotkeys'], $data['hotkeys']); 
  40.  
  41. foreach($data['hotkeys'] as $slug => &$arr) { 
  42. $arr['label'] = $this->labels[$slug]; 
  43.  
  44. if($key && is_array($data)) { 
  45. $data = array_key_exists($key, $data) ? $data[$key] : false; 
  46.  
  47. return $data; 
  48.