pmpro_notifications

This code calls the server at www.paidmembershipspro.com to see if there are any notifications to display to the user.

Description

pmpro_notifications(); 

Notifications are shown on the PMPro settings pages in the dashboard.


Usage

  1. if ( !function_exists( 'pmpro_notifications' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'paid-memberships-pro/includes/notifications.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = pmpro_notifications(); 
  7.  

Defined (1)

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

/includes/notifications.php  
  1. function pmpro_notifications() 
  2. if(current_user_can("manage_options")) 
  3. {  
  4. $pmpro_notification = get_transient("pmpro_notification_" . PMPRO_VERSION); 
  5. if(empty($pmpro_notification)) 
  6. //set to NULL in case the below times out or fails, this way we only check once a day 
  7. set_transient("pmpro_notification_" . PMPRO_VERSION, 'NULL', 86400); 
  8.  
  9. //figure out which server to get from 
  10. if(is_ssl()) 
  11. $remote_notification = wp_remote_get("https://notifications.paidmembershipspro.com/?v=" . PMPRO_VERSION); 
  12. else 
  13. $remote_notification = wp_remote_get("http://notifications.paidmembershipspro.com/?v=" . PMPRO_VERSION); 
  14. }  
  15.  
  16. //get notification 
  17. $pmpro_notification = wp_remote_retrieve_body($remote_notification); 
  18.  
  19. //update transient if we got something 
  20. if(!empty($pmpro_notification)) 
  21. set_transient("pmpro_notification_" . PMPRO_VERSION, $pmpro_notification, 86400); 
  22.  
  23. if($pmpro_notification && $pmpro_notification != "NULL") 
  24. ?> 
  25. <div id="pmpro_notifications"> 
  26. <?php echo $pmpro_notification; ?> 
  27. </div> 
  28. <?php 
  29.  
  30. //exit so we just show this content 
  31. exit;