WordPress.org

Ready to get started?Download WordPress

Forums

Drafts Scheduler
[resolved] Bugfixes: Mass Publishing & Page Scheduling (3 posts)

  1. Ralph83
    Member
    Posted 3 years ago #

    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: http://kovshenin.com/archives/wordpress-the-wp_update_post-dates-in-drafts/

    http://wordpress.org/extend/plugins/drafts-scheduler/

  2. Jeff Rose
    Member
    Plugin Author

    Posted 3 years ago #

    I'm ponder if this is the "best" fix for the "Don't update pages" as it will also prevent the plugin from working for custom post types.

    I'll implement this for now, with a caveat in the readme file about it, and may extend a "Post type picking" function where the user can decide to only post POSTS or include one or more CPT.

    Ralph, I just want to send a public Thank You! to you for the time you've put not only into solving the problem, but also in sharing what you've learned so we can all benefit.

  3. Ralph83
    Member
    Posted 3 years ago #

    Hi Jeff, just emailed you back. You're welcome and glad I could help! And Thank You! for creating the plugin!

    I like the idea of a Post type picking function!

    Perhaps, for now, it's an idea to change the MySQL from AND post_type = 'post' to AND post_type != 'page'? That way pages will be ignored, yet all post types will be included.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic