Log file cleared\n\t─────\n"); @fclose($fh); echo "

Log file cleared!

"; } ?>

Scheduled Post Shift v

For information and updates, please visit:
/articles/scheduled-post-shift-plugin-for-wordpress/

">

Current Status:

Options

Shift Delay
The number of hours between post shifts
Only Shift After X hours
Only shift a post if it has been X hours since the last new post was added (0 = disable)
Category ID(s)
If left blank, the plugin will use posts from all categories
If you enter one or more category IDs, it will only update posts from those categories
Separate multiple category IDs with commas
Log File
You can leave this specific to this blog, or set up a global log for multiple blogs.

Scheduled Draft Publish log

0) && ($hours_passed <= $onlyafter)) { return; } global $wpdb; $tp = $wpdb->prefix; // Currently using a work-around for the version system // determines if pre or post 2.3 from wp_term_taxonomy $ver = 2.2; $wpv = $wpdb->get_results("show tables like '{$tp}term_taxonomy'"); if (count($wpv) > 0) { $ver = 2.3; } $the_cat = '(' . trim(get_option('ddps_cat'), ',') . ')'; if ($the_cat == "()") { $oldest_post = $wpdb->get_var(" SELECT ID FROM {$tp}posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY post_date asc "); } else { if ($ver < 2.3) { $oldest_post = $wpdb->get_var(" SELECT ID FROM {$tp}posts, {$tp}post2cat WHERE {$tp}post2cat.category_id IN " . $the_cat . " AND post_type = 'post' AND {$tp}posts.post_status = 'publish' AND {$tp}post2cat.post_id = {$tp}posts.ID GROUP BY post_date asc "); } else { // post 2.3+ $oldest_post = $wpdb->get_var(" SELECT ID FROM {$tp}posts, {$tp}term_relationships, {$tp}term_taxonomy WHERE {$tp}term_taxonomy.term_id IN " . $the_cat . " AND {$tp}term_taxonomy.term_taxonomy_id = {$tp}term_relationships.term_taxonomy_id AND {$tp}term_relationships.object_id = {$tp}posts.ID AND {$tp}posts.post_type = 'post' AND {$tp}posts.post_status = 'publish' GROUP BY post_date asc "); } } if ($oldest_post > 0) { # we have a post to shift # what wordpress func to call for setting post_name instead? $post_title = $wpdb->get_var(" SELECT post_title FROM {$tp}posts WHERE ID = '$oldest_post' "); # what wordpress func to call for setting post_name instead? $new_time = date('Y-m-d H:i:s'); $wpdb->query("UPDATE $wpdb->posts SET post_date = '$new_time' WHERE ID = '$oldest_post'"); wp_publish_post($oldest_post); SDP_log(strftime("%D %T") . "\t" . $tp . "\tPOST id " . $selected_draft . " SHIFTED '" . $post_title . "'\n"); } else { PS_log(strftime("%D %T") . "\t\t" . $tp . "\tUnable to find a post to shift.\n"); } } function more_reccurences() { return array( 'ddps_schedule' => array('interval' => ((int)get_option('ddps_delay') * 3600), 'display' => 'Post Shift Schedule') ); } function PS_log($PS_log_output) { $logfile=get_option('ddps_logfile'); $fh = @fopen($logfile, "a"); @fwrite($fh, $PS_log_output); @fclose($fh); } function PS_get_last_log_entries() { $logfile=get_option('ddps_logfile'); $lines = @file($logfile); if($lines === false){ echo "Error reading log file (".$logfile."). Most likely you have manually removed the log file, or alternatively this could mean that the logfile is read-protected (change the rights of this file to 777)')"; }else{ $msg = ""; foreach($lines as $line){ $msg.=trim($line)."
"; } echo $msg; } } add_filter('cron_schedules', 'more_reccurences'); ?>