WCHAU_Admin_Column

The WooCommerce Hear About Us WCHAU Admin Column class.

Defined (1)

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

/includes/admin/wchau-admin-column.php  
  1. class WCHAU_Admin_Column { 
  2. /** 
  3. * Add filter 
  4. */ 
  5. public function __construct() { 
  6.  
  7. // Add to user listing 
  8. add_filter( 'manage_users_columns', array( $this, 'addUserColumn' ) ); 
  9. add_filter( 'manage_users_sortable_columns', array( $this, 'addUserSortableColumn' ) ); 
  10. add_filter( 'manage_users_custom_column', array( $this, 'userColumnValue' ), 10, 3 ); 
  11.  
  12. // Add to order listing 
  13. add_filter( 'manage_edit-shop_order_columns', array( $this, 'addOrderColumn' ) ); 
  14. add_filter( 'manage_edit-shop_order_sortable_columns', array( $this, 'addOrderSortableColumn' ) ); 
  15. add_action( 'manage_shop_order_posts_custom_column', array( $this, 'orderColumnValue' ), 10, 2 ); 
  16.  
  17. public function addUserColumn( $columns ) { 
  18. $columns['source'] = __( 'Source', 'woocommerce-hear-about-us' ); 
  19.  
  20. return $columns; 
  21.  
  22. public function addUserSortableColumn( $columns ) { 
  23. $columns['source'] = 'source'; 
  24.  
  25. return $columns; 
  26.  
  27. public function userColumnValue( $value, $column_name, $user_id ) { 
  28. if ( 'source' === $column_name ) { 
  29. return wchau_get_option_value( get_user_meta( $user_id, '_wchau_source', true ), '' ); 
  30.  
  31. return $value; 
  32.  
  33. public function addOrderColumn( $columns ) { 
  34. $columns['source'] = __( 'Source', 'woocommerce-hear-about-us' ); 
  35.  
  36. return $columns; 
  37.  
  38. public function addOrderSortableColumn( $columns ) { 
  39. $columns['source'] = 'source'; 
  40.  
  41. return $columns; 
  42.  
  43. public function orderColumnValue( $column_name, $order_id ) { 
  44. if ( 'source' === $column_name ) { 
  45. echo wchau_get_option_value( get_post_meta( $order_id, 'source', true ), '' );