WPSEO_Config_Field_Mailchimp_Signup

Class WPSEO_Config_Field_Mailchimp_Signup.

Defined (1)

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

/admin/config-ui/fields/class-field-mailchimp-signup.php  
  1. class WPSEO_Config_Field_Mailchimp_Signup extends WPSEO_Config_Field { 
  2.  
  3. /** 
  4. * WPSEO_Config_Field_Mailchimp_Signup constructor. 
  5. */ 
  6. public function __construct() { 
  7. parent::__construct( 'mailchimpSignup', 'MailchimpSignup' ); 
  8.  
  9. $current_user = wp_get_current_user(); 
  10. $user_email = ( $current_user->ID > 0 ) ? $current_user->user_email : ''; 
  11.  
  12. $this->set_property( 'title' , __( 'Stay up-to-date', 'wordpress-seo' ) ); 
  13. $this->set_property( 
  14. 'label',  
  15. sprintf( 
  16. /** translators: %s expands to Yoast SEO. */ 
  17. __( 'Your %1$s plugin is now set up. SEO, however, is subject to constant change. Sign up for our newsletter if you would like to keep up-to-date regarding %1$s, other plugins by Yoast and important news in the world of SEO.', 'wordpress-seo' ),  
  18. 'Yoast SEO' 
  19. ); 
  20.  
  21. $this->set_property( 'decoration', plugin_dir_url( WPSEO_FILE ) . 'images/newsletter-collage.png' ); 
  22.  
  23. $this->set_property( 'mailchimpActionUrl', 'https://yoast.us1.list-manage.com/subscribe/post-json?u=ffa93edfe21752c921f860358&id=972f1c9122' ); 
  24. $this->set_property( 'currentUserEmail', $user_email ); 
  25. $this->set_property( 'userName', trim( $current_user->user_firstname . ' ' . $current_user->user_lastname ) ); 
  26.  
  27. /** 
  28. * Get the data 
  29. * @return array 
  30. */ 
  31. public function get_data() { 
  32. return array( 
  33. 'hasSignup' => $this->has_mailchimp_signup(),  
  34. ); 
  35.  
  36.  
  37. /** 
  38. * Checks if the user has entered his email for mailchimp already. 
  39. * @return bool 
  40. */ 
  41. protected function has_mailchimp_signup() { 
  42. $user_meta = get_user_meta( get_current_user_id(), WPSEO_Config_Component_Mailchimp_Signup::META_NAME, true ); 
  43. return ( ! empty( $user_meta ) );