WC_GZD_Admin_Customer

The WooCommerce Germanized WC GZD Admin Customer class.

Defined (1)

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

/includes/admin/class-wc-gzd-admin-customer.php  
  1. class WC_GZD_Admin_Customer { 
  2.  
  3. protected static $_instance = null; 
  4.  
  5. public static function instance() { 
  6. if ( is_null( self::$_instance ) ) 
  7. self::$_instance = new self(); 
  8. return self::$_instance; 
  9.  
  10. public function __construct() { 
  11. // Admin profile 
  12. add_action( 'show_user_profile', array( $this, 'profile_add_activation_field' ) ); 
  13. add_action( 'edit_user_profile', array( $this, 'profile_add_activation_field' ) ); 
  14. add_action( 'personal_options_update', array( $this, 'profile_save_activation_field' ) ); 
  15. add_action( 'edit_user_profile_update', array( $this, 'profile_save_activation_field' ) ); 
  16.  
  17. /** 
  18. * Adds customer activation option to profile 
  19. *  
  20. * @param object $user  
  21. */ 
  22. public function profile_add_activation_field( $user ) { 
  23. if ( ! current_user_can( 'manage_woocommerce' ) || ! in_array( 'customer', $user->roles ) || get_option( 'woocommerce_gzd_customer_activation' ) != 'yes' ) 
  24. return; 
  25.  
  26. if ( current_user_can( 'edit_user', $user->ID ) ) { 
  27. ?> 
  28. <table class="form-table"> 
  29. <tbody> 
  30. <tr> 
  31. <th><label for="woocommerce_activation"><?php _e( 'Double opt in', 'woocommerce-germanized' ); ?></label></th> 
  32. <td> 
  33. <label for="woocommerce_activation"> 
  34. <input name="_woocommerce_activation" type="checkbox" id="_woocommerce_activation" value="1" <?php checked( wc_gzd_is_customer_activated( $user->ID ), 1 ); ?> /> 
  35. <?php _e( 'Yes, customer opted in', 'woocommerce-germanized' ); ?> 
  36. </label> 
  37. </td> 
  38. </tr> 
  39. </tbody> 
  40. </table> 
  41. <?php 
  42.  
  43. /** 
  44. * Delete activation key if user has been marked as opted in 
  45. *  
  46. * @param int $user_id  
  47. */ 
  48. public function profile_save_activation_field( $user_id ) { 
  49. if ( current_user_can( 'edit_user', $user_id ) ) { 
  50. $user = get_userdata( $user_id ); 
  51. if ( isset( $_POST[ '_woocommerce_activation' ] ) ) 
  52. delete_user_meta( $user_id, '_woocommerce_activation' ); 
  53.