Wordpress pre-scheduling problem

Discussion in 'WordPress' started by bob25, Apr 11, 2009.

  1. #1
    I've pre-scheduled some posts (about 8 pages worth), but I'm receiving a "Missed Scheduled" error message. Right now I'm going back and having to re-schedule them.

    Anybody know how to fix this?

    Thanks
     
    bob25, Apr 11, 2009 IP
  2. Big0ne

    Big0ne Well-Known Member

    Messages:
    2,615
    Likes Received:
    81
    Best Answers:
    0
    Trophy Points:
    165
  3. bob25

    bob25 Well-Known Member

    Messages:
    1,519
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #3
    bob25, Apr 11, 2009 IP
  4. Big0ne

    Big0ne Well-Known Member

    Messages:
    2,615
    Likes Received:
    81
    Best Answers:
    0
    Trophy Points:
    165
    #4
    Here you go:

    <?php
    /*
    Plugin Name: Scheduled M.I.A.s
    Plugin URI: http://blog.5ubliminal.com/topics/wordpress/plugins/
    Description: Bring the left-for-dead <code>Missed Schedule</code> posts back to life.
    Version: 5.U.B
    Author: 5ubliminal
    Author URI: http://blog.5ubliminal.com/
    Support URI: http://blog.5ubliminal.com/support/
    */
    // -----------------------------------------------------------------------------
    define('PLUGIN_SCHEDULEDMIAS_DELAY', 15); // Minutes .. change as you wish
    define('PLUGIN_SCHEDULEDMIAS_OPTION', '_5ub_scheduled_mias'); // Option name
    // -----------------------------------------------------------------------------
    function _5ubliminal_Replacements_Deactivate(){
    	// Drop last update time on deactivate
    	delete_option(PLUGIN_SCHEDULEDMIAS_OPTION);
    }
    register_deactivation_hook(__FILE__, '_5ubliminal_Replacements_Deactivate');
    // -----------------------------------------------------------------------------
    function _5ubliminal_ScheduledMIAs_Init(){
    	// I disable internal cron jobs for post publishing completely
    	// ... Comment the line below to let Wordpress try do its job before we kick in
    	remove_action('publish_future_post', 'check_and_publish_future_post');
    	// Let's see if enough time passed from last publish
    	$last = get_option(PLUGIN_SCHEDULEDMIAS_OPTION, false);
    	if(($last !== false) && ($last > (time() - (PLUGIN_SCHEDULEDMIAS_DELAY * 60))))
    		return; // Too little time passed, bail here
    	// Update to the current time
    	update_option(PLUGIN_SCHEDULEDMIAS_OPTION, time());
    	// Global $wpdb object
    	global $wpdb;
    	// Find MIA post_IDs, try both LOCAL datetime and GMT datetime
    	$scheduledIDs = $wpdb->get_col(
    		"SELECT `ID` FROM `{$wpdb->posts}` ".
    		"WHERE ( ".
    		"	((`post_date` > 0 )&& (`post_date` <= CURRENT_TIMESTAMP())) OR ".
    		"	((`post_date_gmt` > 0) && (`post_date_gmt` <= UTC_TIMESTAMP())) ".
    		") AND `post_status` = 'future'"
    	);
    	if(!count($scheduledIDs)) return; // None found ... bail
    	foreach($scheduledIDs as $scheduledID){
    		if(!$scheduledID) continue; // Just in case
    		// Publish each post_ID the Wordpress friendly way
    		wp_publish_post($scheduledID);
    	}
    }
    add_action('init', '_5ubliminal_ScheduledMIAs_Init', 0); // 0 Priority filter
    // -----------------------------------------------------------------------------
    ?>
    PHP:
     
    Big0ne, Apr 11, 2009 IP
  5. bob25

    bob25 Well-Known Member

    Messages:
    1,519
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #5
    Yes I got the code, but what am I supposed to do with it? :confused:

    Thanks
     
    bob25, Apr 11, 2009 IP
  6. Big0ne

    Big0ne Well-Known Member

    Messages:
    2,615
    Likes Received:
    81
    Best Answers:
    0
    Trophy Points:
    165
    #6
    Save it as fix.php and upload it in your wp-content/plugins folder. Later on you can activate it in your dashboard.
     
    Big0ne, Apr 12, 2009 IP
  7. bob25

    bob25 Well-Known Member

    Messages:
    1,519
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    128
    #7
    Got it :)

    Thanks
     
    bob25, Apr 12, 2009 IP