nxs_do_post_from_query
The NextScripts: Social Networks Auto-Poster nxs do post from query function.
Description
nxs_do_post_from_query();
Usage
if ( !function_exists( 'nxs_do_post_from_query' ) ) { require_once ABSPATH . PLUGINDIR . 'nextscripts-social-networks-auto-poster/nxs_functions.php'; } // NOTICE! Understand what this does before running. $result = nxs_do_post_from_query();
Defined (1)
The function is defined in the following location(s).
- /nxs_functions.php
- function nxs_do_post_from_query() { nxs_cron_check(); // nxs_addToLogN('A', 'Debug info only. - Cron Time', 'X', '', $extInfo);
- if (stripos($_SERVER["REQUEST_URI"], 'wp-cron.php')!==false) nxs_rePoster(); //## Run Reposter.
- $options = get_option('NS_SNAutoPoster'); $quPosts = maybe_unserialize(get_option('NSX_PostsQuery')); if (!is_array($quPosts)) $quPosts = array();
- if ($options['quLimit'] != '1' || count($quPosts)<1) return; $currTime = time() + ( get_option( 'gmt_offset' ) * HOUR_IN_SECONDS ); $hasChanged = false;
- $postToPost = array_shift($quPosts);
- $pstEvrySec = $options['quDays']*86400+$options['quHrs']*3600+$options['quMins']*60; $rndSec = $options['quLimitRndMins']*60;
- $nxTime = !empty($options['quNxTime'])?$options['quNxTime']:$currTime+$pstEvrySec;
- $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']);
- if (empty($options['quNxTime']) || $nxTime < $currTime) $hasChanged = true; // Do Post
- if ($hasChanged) { //## Do Post
- 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);
- $options['quLastShTime'] = $currTime; $rndTime = rand(0-$rndSec, $rndSec); $options['quNxTime'] = $currTime + $pstEvrySec + $rndTime;
- if ($options['nxsOverLimit']=='D') { $dateC = date("d"); $dayN = date("d", $nxTime); if ($dayN!=$dateC) $quPosts = array(); }
- update_option('NSX_PostsQuery', $quPosts); update_option('NS_SNAutoPoster', $options);
- nxs_snapPublishTo($postToPost, '', true);
- nxs_addToLogN('A', '**POST FINISHED** NXSPoster - WP CRON - Post from Query - Post ID: '.$postToPost, '', '-=Time=- '.$currTime, $extInfo);
- }
- }