Changeset 3693243
- Timestamp:
- 09/13/2026 01:50:14 AM (2 months ago)
- Location:
- controlled-draft-publisher
- Files:
-
- 6 added
- 2 edited
-
tags/1.7.7 (added)
-
tags/1.7.7/controlled-draft-publisher.php (added)
-
tags/1.7.7/languages (added)
-
tags/1.7.7/languages/controlled-draft-publisher.pot (added)
-
tags/1.7.7/readme.txt (added)
-
tags/1.7.7/uninstall.php (added)
-
trunk/controlled-draft-publisher.php (modified) (6 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
controlled-draft-publisher/trunk/controlled-draft-publisher.php
r3692231 r3693243 4 4 * Plugin Name: Controlled Draft Publisher 5 5 * Description: Publishes draft posts on a configurable interval per post type, with a "Next Up" dashboard preview, a per-post auto-publish exclude option, optional publishing-window/weekend restrictions, email alerts, and logging. 6 * Version: 1.7. 66 * Version: 1.7.7 7 7 * Requires at least: 5.0 8 8 * Tested up to: 7.0.2 … … 77 77 add_option( 'cdp_posts_per_run', 1 ); 78 78 add_option( 'cdp_gap_seconds', 0 ); 79 add_option( 'cdp_stamp_publish_date', true ); 79 80 add_option( 'cdp_categories', [] ); 80 81 add_option( 'cdp_post_type_intervals', [] ); … … 367 368 */ 368 369 function cdp_publish_one_post( $id ) { 369 $result = wp_update_post( [ 'ID' => $id, 'post_status' => 'publish' ], true ); 370 $postarr = [ 'ID' => $id, 'post_status' => 'publish' ]; 371 372 /* 373 * WordPress only moves a draft's date to now when that draft has never had a 374 * date of its own, which it signals with an empty post_date_gmt. See the 375 * $clear_date branch in wp_update_post(). 376 * 377 * Plenty of drafts fail that test and keep a real post_date_gmt: anything 378 * that was scheduled and then put back to draft, anything reverted from 379 * published, imported content, and posts created through the REST API or 380 * wp_insert_post with a date. Publishing one of those with nothing but a 381 * status change leaves it dated whenever that date was set, so it goes live 382 * part way down the blog instead of at the top. 383 * 384 * Stamping the date here makes every post this plugin publishes carry the 385 * time it actually went live, which is what a drip publisher should do. 386 */ 387 if ( get_option( 'cdp_stamp_publish_date', true ) ) { 388 $now = current_time( 'mysql' ); 389 $postarr['post_date'] = $now; 390 $postarr['post_date_gmt'] = get_gmt_from_date( $now ); 391 $postarr['edit_date'] = true; 392 } 393 394 $result = wp_update_post( $postarr, true ); 370 395 371 396 if ( is_wp_error( $result ) ) { … … 1158 1183 update_option( 'cdp_gap_seconds', $new_gap ); 1159 1184 1185 update_option( 'cdp_stamp_publish_date', isset( $_POST['cdp_stamp_publish_date'] ) ); 1186 1160 1187 $raw_categories = filter_input( INPUT_POST, 'cdp_categories', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY ); 1161 1188 if ( $raw_categories === null ) { … … 1214 1241 $posts_per_run = intval( get_option( 'cdp_posts_per_run', 1 ) ); 1215 1242 $gap_seconds = intval( get_option( 'cdp_gap_seconds', 0 ) ); 1243 $stamp_date = get_option( 'cdp_stamp_publish_date', true ); 1216 1244 $selected_categories = get_option( 'cdp_categories', [] ); 1217 1245 $categories = get_categories( [ 'hide_empty' => false ] ); … … 1231 1259 echo '<tr><th scope="row">' . esc_html__( 'Posts Per Run', 'controlled-draft-publisher' ) . '</th><td><input type="number" name="cdp_posts_per_run" value="' . esc_attr( $posts_per_run ) . '" min="1" /></td></tr>'; 1232 1260 echo '<tr><th scope="row">' . esc_html__( 'Gap Between Posts (seconds)', 'controlled-draft-publisher' ) . '</th><td><input type="number" name="cdp_gap_seconds" value="' . esc_attr( $gap_seconds ) . '" min="0" max="3600" /><p class="description">' . esc_html__( 'Only applies when Posts Per Run is more than 1. The first post of a run publishes straight away and the rest are spaced out by this many seconds. 0 publishes them all at once.', 'controlled-draft-publisher' ) . '</p><p class="description">' . esc_html__( 'WordPress cron only runs when someone visits the site, so the gap is a minimum rather than a guarantee. On a quiet site set up a real server cron for accurate spacing.', 'controlled-draft-publisher' ) . '</p></td></tr>'; 1261 echo '<tr><th scope="row">' . esc_html__( 'Publish Date', 'controlled-draft-publisher' ) . '</th><td><label><input type="checkbox" name="cdp_stamp_publish_date" ' . checked( $stamp_date, true, false ) . '> ' . esc_html__( 'Date each post when it is published', 'controlled-draft-publisher' ) . '</label><p class="description">' . esc_html__( 'Recommended. WordPress keeps the old date on any draft that already has one, which includes drafts that were once scheduled, reverted from published, or imported. Those posts go live part way down the blog. Untick this only if you want the date already on the draft to be kept.', 'controlled-draft-publisher' ) . '</p></td></tr>'; 1233 1262 echo '<tr><th scope="row">' . esc_html__( 'Post Types', 'controlled-draft-publisher' ) . '</th><td>'; 1234 1263 foreach ( $post_types as $type ) { -
controlled-draft-publisher/trunk/readme.txt
r3692231 r3693243 6 6 Tested up to: 7.0.2 7 7 Requires PHP: 8.0 8 Stable tag: 1.7. 68 Stable tag: 1.7.7 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 72 72 73 73 == Changelog == 74 75 = 1.7.7 = 76 * Fixed: posts published by the plugin could go live carrying an old date instead of the date they were published, so they appeared part way down the blog. WordPress only moves a draft's date forward when that draft has never had a date of its own, which leaves out anything that was scheduled and then put back to draft, reverted from published, or imported. The plugin now stamps the publish date itself. 77 * New setting: Publish Date. On by default. Untick it if you would rather keep whatever date is already on the draft. 78 * Thanks to @gamark on the support forum for spotting it and for the patch. 74 79 75 80 = 1.7.6 =
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)