[Plugin: Drafts Scheduler] Bugfixes: Mass Publishing & Page Scheduling
-
I was one of those people running WP 3.1.1. and experiencing the Mass Publishing bug + Drafted Pages Scheduling / Publishing bug with this plugin. Since the author couldn’t reproduce the Mass Publishing bug and thus not fix it, I took the time (4+ hours) to fix it myself and fix the Page Publishing bug along the way. Since the plugin seemed too neat to just give up on it without a fight.
1st Step: open draft-scheduler.php
Fix #1: Page Publishing
We want this plugin to handle drafted posts only and no drafted pages. The following code keeps the plugin from touching your drafted pages:
Find:
$draftList = $wpdb->get_results(“SELECT * from $wpdb->posts WHERE status=’draft'”);
Replace with:
$draftList = $wpdb->get_results(“SELECT * from $wpdb->posts WHERE status = ‘draft’ AND post_type = ‘post'”);
Find:
$findDrafts = “SELECT ID FROM ” .$wpdb->prefix . “posts WHERE post_status = ‘draft’ ORDER BY rand()”;
Replace with:
$findDrafts = “SELECT ID FROM ” .$wpdb->prefix . “posts WHERE post_status = ‘draft’ AND post_type = ‘post’ ORDER BY rand()”;
Find:
$findDrafts = “SELECT * FROM ” .$wpdb->posts . ” WHERE post_status = ‘draft’ ORDER BY rand()”;
Replace with:
$findDrafts = “SELECT * FROM ” .$wpdb->posts . ” WHERE post_status = ‘draft’ AND post_type = ‘post’ ORDER BY rand()”;
Find:
$findDrafts = “SELECT ID FROM ” .$wpdb->posts . ” WHERE post_status = ‘draft’ ORDER BY id ASC”;
Replace with:
$findDrafts = “SELECT ID FROM ” .$wpdb->posts . ” WHERE post_status = ‘draft’ AND post_type = ‘post’ ORDER BY id ASC”;
Find:
$findDrafts = “SELECT COUNT(ID) FROM ” .$wpdb->prefix . “posts WHERE post_status = ‘draft'”;
Replace with:
$findDrafts = “SELECT COUNT(ID) FROM ” .$wpdb->prefix . “posts WHERE post_status = ‘draft’ AND post_type = ‘post'”;
Fix #2: Mass Publishing
I won’t bother you with the cause behind this bug, but this should fix it:
Find:
$update_date = array(
‘ID’ => $draftID,
‘post_date’ => date_i18n(‘Y-n-j G:i:s’, $ds_postDate),
‘post_date_gmt’ => $ds_gmt,
‘post_status’ => ‘future’
);Replace with:
$update_date = array(
‘ID’ => $draftID,
‘post_date’ => date_i18n(‘Y-n-j G:i:s’, $ds_postDate),
‘post_date_gmt’ => $ds_gmt,
‘post_status’ => ‘future’,
‘edit_date’ => true // Mass Publishing Bugfix for WP version 3.1.1.
);That’s all. I hope it helps!
This blogpost provided useful info re the 2nd bugfix: https://kovshenin.com/archives/wordpress-the-wp_update_post-dates-in-drafts/
- The topic ‘[Plugin: Drafts Scheduler] Bugfixes: Mass Publishing & Page Scheduling’ is closed to new replies.