• Resolved gama

    (@gamark)


    I am using your plugin and I realized it would be nice to have the option to add a gap between drafts publishing. For example, I use posts as draft (news posts) and instead of blasting say 10 posts at once, I was thinking a small gap between them would be nice so every x minutes, y number of drafts are publishes every z seconds

    For example:

    Default Interval (minutes) [ 3 ]

    Posts Per Run [ 2 ]

    Gap Between Posts (seconds) [ 10 ]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author techygeekshome

    (@techygeekshome)

    <span style=”font-size: inherit;”>Thanks for the suggestion, it was a fair gap. Until now Posts Per Run published the whole batch in the same tick, so ten posts went out in the same second.</span>

    Added in 1.7.6, which is live now. There is a new Gap Between Posts (seconds) setting. The first post of a run publishes straight away and the rest are spaced out by whatever you set. Leave it at 0 and nothing changes from before.


    Your example works as you wrote it: Default Interval 3, Posts Per Run 2, Gap 10.


    One thing worth knowing. WordPress cron only runs when someone visits the site, so the gap is a minimum rather than an exact spacing. On a quiet site a 10 second gap can stretch out. If you need it accurate, disable WP cron and set up a real server cron. There is a note about this on the setting itself.

    Thread Starter gama

    (@gamark)

    Good stuff (now I will get rid of the mod I already made to your plugin to this on my website), I will update. Thanks.

    As for the WP Cron can be helped by setting and automatic Cron job from the hosting platform like this:

    */5 * * * *
    wget -q -O - "https://{your_domain}/wp-cron.php?doing_wp_cron"

    This way your website is always publishing every 5 minutes and I set my interval for articles around that.

    A final thought, on my other comment I showed how a small mod to publish now the posts and not publish in the past is actually a very nice tweak for your plugin. I think you can give users an option to select (publish now or publish with post date).

    My use case: I write news in draft format and instead of posting all the news at once, I spread it out a bit, this way the website looks “alive”. I use your plugin to do that. So having draft posts showing every X minutes at Y seconds intervals, published now (instead of the moment the draft was created), combined with another custom plugin to notify people something new was just published, makes your plugin gold for a content website.

    • This reply was modified 5 days, 7 hours ago by gama.
    Thread Starter gama

    (@gamark)

    I am being pedantic now… In your controlled-draft-publisher.php lines 368–370 I replaced this line

    $result = wp_update_post( [ 'ID' => $id, 'post_status' => 'publish' ], true );

    with

    $current_time = current_time( 'mysql' );

    $result = wp_update_post(
    [
    'ID' => $id,
    'post_status' => 'publish',
    'post_date' => $current_time,
    'post_date_gmt' => get_gmt_from_date( $current_time ),
    ],
    true
    );
    Plugin Author techygeekshome

    (@techygeekshome)

    Good catch, and you are not being pedantic, it is a real bug.

    It is sneakier than it looks. WordPress does move a draft’s date to now when you publish it, but only if that draft has never had a date of its own, which it tracks with an empty post_date_gmt. So a draft you typed in the editor was always fine. A draft that was scheduled and then put back to draft, or reverted from published, or imported, keeps a real post_date_gmt, and those are the ones going live under the old date.

    I have taken your fix, with edit_date set to true as well, and put it behind a new Publish Date setting that is on by default. That also covers the option you asked for in your previous reply, so anyone drip publishing old archive content can keep the original dates if they want.

    Going out as 1.7.7. Thanks for the report and the patch, you are credited in the changelog.

    Thread Starter gama

    (@gamark)

    Great!

    This plugin is a very useful one. Thank you!

Viewing 5 replies - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.