GPAISRProfile

GPAISRProfile class.

Defined (1)

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

/class.profile.php  
  1. class GPAISRProfile { 
  2.  
  3.  
  4. /** 
  5. * __construct function. 
  6. * @access public 
  7. * @return \GPAISRProfile 
  8. * @since 0.6 
  9. */ 
  10. function __construct() { 
  11.  
  12. // new user contact field 
  13. add_filter( 'user_contactmethods', array( &$this, 'user_contactmethods' ) ); 
  14.  
  15. add_action( 'init', array( &$this, 'upgrade' ) ); 
  16.  
  17. /** 
  18. * @since 0.7.2 
  19. * @param array $contact_methods 
  20. * @return array 
  21. */ 
  22. function user_contactmethods( $contact_methods ) { 
  23. $contact_methods['googleplus'] = __( 'Google+', 'gpaisr' ); 
  24. return $contact_methods; 
  25.  
  26. /** 
  27. * Will upgrade the user meta data 
  28. * @since 0.7.2 
  29. */ 
  30. function upgrade() { 
  31. if ( false === (bool) get_option( 'gpaisr_gplus_link_move', false ) ) { 
  32.  
  33. $users = get_users(); 
  34. foreach ( $users as $user ) { 
  35. $old_gplus_link = get_user_meta( $user->ID, 'gplus_link', true ); 
  36.  
  37. // check if there is a old gplus link. if not, continue 
  38. if ( empty( $old_gplus_link ) ) { 
  39. continue; 
  40.  
  41. $new_gplus_link = get_user_meta( $user->ID, 'googleplus', true ); 
  42.  
  43. // check if there is already a gplus link in the users meta (maybe from Yoast SEO Plugin). If yes, continue 
  44. if ( ! empty( $new_gplus_link ) ) { 
  45. continue; 
  46.  
  47. // alright. there is no gplus link, so add the new one ... 
  48. update_user_meta( $user->ID, 'googleplus', $old_gplus_link ); 
  49.  
  50. // ... and delete the old one 
  51. delete_user_meta( $user->ID, 'gplus_link' ); 
  52.  
  53. update_option( 'gpaisr_gplus_link_move', true ); 
  54.  
  55.  
  56.