nxs_do_post_from_query

The NextScripts: Social Networks Auto-Poster nxs do post from query function.

Description

nxs_do_post_from_query(); 

Usage

  1. if ( !function_exists( 'nxs_do_post_from_query' ) ) { 
  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_post_from_query(); 
  7.  

Defined (1)

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

/nxs_functions.php  
  1. function nxs_do_post_from_query() { nxs_cron_check(); // nxs_addToLogN('A', 'Debug info only. - Cron Time', 'X', '', $extInfo);  
  2. if (stripos($_SERVER["REQUEST_URI"], 'wp-cron.php')!==false) nxs_rePoster(); //## Run Reposter. 
  3. $options = get_option('NS_SNAutoPoster'); $quPosts = maybe_unserialize(get_option('NSX_PostsQuery')); if (!is_array($quPosts)) $quPosts = array(); 
  4. if ($options['quLimit'] != '1' || count($quPosts)<1) return; $currTime = time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); $hasChanged = false;  
  5. $postToPost = array_shift($quPosts);  
  6.  
  7. $pstEvrySec = $options['quDays']*86400+$options['quHrs']*3600+$options['quMins']*60; $rndSec = $options['quLimitRndMins']*60;  
  8. $nxTime = !empty($options['quNxTime'])?$options['quNxTime']:$currTime+$pstEvrySec;  
  9.  
  10. $extInfo = 'Query Time:'.date_i18n('Y-m-d H:i:s', $options['quNxTime'])."|Previous Time:".date_i18n('Y-m-d H:i:s', $options['quLastShTime']); 
  11.  
  12. if (empty($options['quNxTime']) || $nxTime < $currTime) $hasChanged = true; // Do Post  
  13.  
  14. if ($hasChanged) { //## Do Post  
  15. nxs_addToLogN('A', '**POST STARTED** NXSPoster - WP CRON - Post from Query - Post ID: '.$postToPost, '', 'Curr Time: '.date_i18n('Y-m-d H:i:s', $currTime).'~', $extInfo);  
  16. $options['quLastShTime'] = $currTime; $rndTime = rand(0-$rndSec, $rndSec); $options['quNxTime'] = $currTime + $pstEvrySec + $rndTime;  
  17. if ($options['nxsOverLimit']=='D') { $dateC = date("d"); $dayN = date("d", $nxTime); if ($dayN!=$dateC) $quPosts = array(); }  
  18. update_option('NSX_PostsQuery', $quPosts); update_option('NS_SNAutoPoster', $options);  
  19. nxs_snapPublishTo($postToPost, '', true);  
  20. nxs_addToLogN('A', '**POST FINISHED** NXSPoster - WP CRON - Post from Query - Post ID: '.$postToPost, '', '-=Time=- '.$currTime, $extInfo);