function nxs_snapLogPublishTo($new_status, $old_status, $post) { clean_post_cache($post->ID); if ($old_status != 'publish' && $old_status != 'trash' && $new_status == 'publish') { nxs_addToLogN('BG', "*** ID: {$post->ID}, Type: {$post->post_type}", '', ' Status Changed: ' . "{$old_status}_to_{$new_status}" . '. Autopost requested.'); nxs_snapPublishTo($post); } }
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); } }