WC_POS_Admin_Gateways

WC POS Admin Gateways Class.

Defined (1)

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

/includes/admin/class-wc-pos-gateways.php  
  1. class WC_POS_Admin_Gateways extends WC_POS_Gateways { 
  2.  
  3. public function __construct() { 
  4. add_filter( 'woocommerce_payment_gateways_setting_columns', array( $this, 'woocommerce_payment_gateways_setting_columns' ), 10, 1 ); 
  5. add_action( 'woocommerce_payment_gateways_setting_column_pos_status', array( $this, 'pos_status' ), 10, 1 ); 
  6. add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_admin_styles' ) ); 
  7.  
  8. /** 
  9. * Add POS Status column 
  10. * @param array $columns 
  11. * @return array $new_columns 
  12. */ 
  13. public function woocommerce_payment_gateways_setting_columns( $columns ) { 
  14. $new_columns = array(); 
  15. foreach ( $columns as $key => $column ) { 
  16. $new_columns[$key] = $column; 
  17. if( $key == 'status' ) { 
  18. $new_columns['status'] = __( 'Online Store', 'woocommerce-pos' ); 
  19. $new_columns['pos_status'] = __( 'POS', 'woocommerce-pos' ); 
  20. return $new_columns; 
  21.  
  22. /** 
  23. * POS Status for each gateway 
  24. * @param object $gateway 
  25. */ 
  26. public function pos_status( $gateway ) { 
  27. $settings = wc_pos_get_option( 'checkout', 'enabled' ); 
  28. $enabled = is_array($settings) ? array_keys($settings, true) : array(); 
  29.  
  30. echo '<td class="pos_status">'; 
  31. if ( in_array( $gateway->id, $enabled ) ) 
  32. echo '<span class="status-enabled tips" data-tip="' . /** translators: woocommerce */ __( 'Enabled', 'woocommerce' ) . '">' . /** translators: woocommerce */ __( 'Enabled', 'woocommerce' ) . '</span>'; 
  33. else 
  34. echo '-'; 
  35. echo '</td>'; 
  36.  
  37. /** 
  38. * CSS 
  39. */ 
  40. public function enqueue_admin_styles() { 
  41. $screen = get_current_screen(); 
  42.  
  43. if ( $screen->id == 'woocommerce_page_wc-settings' ) { 
  44. $css = ' 
  45. table.wc_gateways .pos_status, table.wc_gateways .pos_enabled { text-align: center; } 
  46. table.wc_gateways .pos_status .tips, table.wc_gateways .pos_enabled .tips { margin: 0 auto; } 
  47. .status-disabled:before { font-family:WooCommerce; speak:none; font-weight:400; font-variant:normal; text-transform:none; line-height:1; -webkit-font-smoothing:antialiased; margin:0; text-indent:0; position:absolute; top:0;left:0; width:100%; height:100%; text-align:center; content: "\e602"; color:#E0E0E0; } 
  48. '; 
  49. wp_add_inline_style( 'wp-admin', $css ); 
  50.  
  51.