nxs_do_this_hourly

The NextScripts: Social Networks Auto-Poster nxs do this hourly function.

Description

nxs_do_this_hourly(); 

Usage

  1. if ( !function_exists( 'nxs_do_this_hourly' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'nextscripts-social-networks-auto-poster/nxs_functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = nxs_do_this_hourly(); 
  7.  

Defined (1)

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

/nxs_functions.php  
  1. function nxs_do_this_hourly() { $options = get_option('NS_SNAutoPoster');  
  2. if (isset($options['errNotifEmailCB']) && (int)$options['errNotifEmailCB'] == 1 && isset($options['errNotifEmail']) && trim($options['errNotifEmail']) != '') { $logToSend = maybe_unserialize(get_option('NSX_LogToEmail')); // echo "SSS";  
  3. // prr($logToSend); 
  4. if (is_array($logToSend) && count($logToSend)>0) { $to = $options['errNotifEmail']; $subject = "SNAP Error Log for ".$_SERVER["SERVER_NAME"]; $message = print_r($logToSend, true); 
  5. $eml = get_bloginfo('admin_email'); if (trim($eml)=='') $eml = "snap-notify@".str_ireplace('www.', '', $_SERVER["SERVER_NAME"]);  
  6. $headers = "From: " . $eml . "\r\n"; $headers .= "Reply-To: ". $eml . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; 
  7. $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; $retval = wp_mail($to, $subject, $message, $headers); echo ($to ."|". $subject."|". $message."|". $headers); 
  8. if ($retval == true) nxs_addToLogN( 'S', 'Log sent to email '.$options['errNotifEmail'], 'ALL', count($logToSend).' records sent', '');  
  9. else nxs_addToLogN( 'ER', '[FALIED] Log sent to email '.$options['errNotifEmail'], 'ALL', count($logToSend).' records were NOT sent', '');  
  10. delete_option("NSX_LogToEmail");  
  11. }}  
  12. $riPosts = get_option('NS_SNriPosts'); if (!is_array($riPosts)) $riPosts = array(); //## Check for Incoming Comments if nessesary.  
  13. if ($options['riActive'] != 1 || count($riPosts)<1 ) return; 
  14. if (isset($options['extDebug']) && $options['extDebug']=='1') nxs_addToLogN( 'S', 'Comments Import', 'ALL', 'Checking for new comments now...', print_r($riPosts, true)); 
  15. //## Facebook 
  16. if (is_array($options['fb'])) foreach ($options['fb'] as $ii=>$fbo) if ($fbo['riComments']=='1') { $fbo['ii'] = $ii; $fbo['pType'] = 'aj'; 
  17. foreach ($riPosts as $postID) {  
  18. $fbpo = get_post_meta($postID, 'snapFB', true); $fbpo = maybe_unserialize($fbpo);  
  19. if (is_array($fbpo) && isset($fbpo[$ii]) && is_array($fbpo[$ii]) && isset($fbpo[$ii]['pgID']) && trim($fbpo[$ii]['pgID'])!='') {  
  20. $ntClInst = new nxs_snapClassFB(); $fbo = $ntClInst->adjMetaOpt($fbo, $fbpo[$ii]); nxs_getBackFBComments($postID, $fbo, $fbpo[$ii]); 
  21. }  
  22. }  
  23. //## Twitter 
  24. if (is_array($options['tw'])) foreach ($options['tw'] as $ii=>$fbo) if ($fbo['riComments']=='1') { $fbo['ii'] = $ii; $fbo['pType'] = 'aj'; $twList = nxs_getBackTWCommentsList($fbo);  
  25. foreach ($riPosts as $postID) {  
  26. $fbpo = get_post_meta($postID, 'snapTW', true); $fbpo = maybe_unserialize($fbpo);  
  27. if (is_array($fbpo) && isset($fbpo[$ii]) && is_array($fbpo[$ii]) && isset($fbpo[$ii]['pgID']) && trim($fbpo[$ii]['pgID'])!='') {  
  28. $ntClInst = new nxs_snapClassTW(); $fbo = $ntClInst->adjMetaOpt($fbo, $fbpo[$ii]); nxs_getBackTWComments($postID, $fbo, $fbpo[$ii], $twList); 
  29. }  
  30. }