MailchimppopupMailmunchHelpers

The MailChimp Popup with Exit Support MailchimppopupMailmunchHelpers class.

Defined (1)

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

/inc/common.php  
  1. class MailchimppopupMailmunchHelpers { 
  2. function __construct() { 
  3.  
  4. function getEmailPassword() { 
  5. $mc_pop_mm_email = get_option("mc_pop_mm_user_email"); 
  6. $mc_pop_mm_password = get_option("mc_pop_mm_user_password"); 
  7.  
  8. if (empty($mc_pop_mm_email)) { 
  9. $current_user = wp_get_current_user(); 
  10. update_option("mc_pop_mm_user_email", $current_user->user_email); 
  11.  
  12. if (empty($mc_pop_mm_password)) { 
  13. update_option("mc_pop_mm_user_password", base64_encode(uniqid())); 
  14.  
  15. $mc_pop_mm_email = get_option("mc_pop_mm_user_email"); 
  16. $mc_pop_mm_password = get_option("mc_pop_mm_user_password"); 
  17.  
  18. return array('email' => $mc_pop_mm_email, 'password' => $mc_pop_mm_password); 
  19.  
  20. function getSite($sites, $site_id) { 
  21. foreach ($sites as $s) { 
  22. if ($s->id == intval($site_id)) { 
  23. $site = $s; 
  24. break; 
  25.  
  26. return (isset($site) ? $site : false); 
  27.  
  28. function createAndGetSites($mm) { 
  29. $site_url = home_url(); 
  30. $site_name = get_bloginfo(); 
  31.  
  32. if (!$mm->hasSite()) { 
  33. $mm->createSite($site_name, $site_url); 
  34. $request = $mm->sites(); 
  35. if ($request['response']['code'] == 200) { 
  36. $sites = $request['body']; 
  37.  
  38. return json_decode($sites); 
  39. else { 
  40. return array(); 
  41.  
  42. function createAndGetGuestSites($mm) { 
  43. // This is for GUEST users. Do NOT collect any user data. 
  44. $site_url = ""; 
  45. $site_name = "WordPress"; 
  46.  
  47. if (!$mm->hasSite()) { 
  48. $mm->createSite($site_name, $site_url); 
  49. $request = $mm->sites(); 
  50. if ($request['response']['code'] == 200) { 
  51. $sites = $request['body']; 
  52.  
  53. return json_decode($sites); 
  54. else { 
  55. return array();