WordPress.org

Ready to get started?Download WordPress

Forums

Auto-Schedule Posts
Have some bugs! (3 posts)

3 stars
  1. Vahan4033
    Member
    Posted 1 year ago #

    Hi it is nice plugin and thanks for done work. This Latest 3.6 version have some bugs.

    1. When adding custom menus items from admin dashboard it takes added menu items under schedule and as a result menu items don't show up in a custom menu until your plugin publishes it according schedule.

    I corrected that issue myself by removing post actions (auto_schedule) when menu is updated. below is snipped of code that I used

    add_action('wp_update_nav_menu', 'remove_schedule');
    //add_action('auto-schedule_to_publish','auto_schedule',1);
    
    function remove_schedule() {
    
    	 remove_action('pending_to_publish','auto_schedule',1);
    	 remove_action('draft_to_publish','auto_schedule',1);
    	 remove_action('private_to_publish','auto_schedule',1);
    	 remove_action('future_to_publish','future_schedule',1);
    	 remove_action('new_to_publish','auto_schedule',1);
    }

    2. When pressing publish button just after add new button without waiting an Ajax auto draft of WordPress it doesn't take post under schedule it seems action hooks doesn't work properly.

    this one I couldn't correct.

  2. thedavis
    Member
    Posted 1 year ago #

    Hi, I have another solution for all the situations.

    Plugins tries to schedule all the "posts", but, in WordPress we have several types of posts, looking at database, in wp_posts table:

    SELECT DISTINCT (
    post_type
    )
    FROM  wp_posts
    WHERE 1
    LIMIT 0 , 30

    Example output:
    attachment
    nav_menu_item
    page
    post
    revision
    wpcf7_contact_form

    So, we only want to affect "post_type" = "post". For get this I edited "auto-schedule-posts.php" file this way (function auto_schedule):

    function auto_schedule($post) {
    	global $wpdb;
    
    	if(isset($post->post_type) && $post->post_type == "post") { //We only want affect POST type elements.
    		/* captured a publish_post event - set publish_time_gmt to '9999-12-31 09:59:59' and publish_time to the gmt offset of that */
    		$gmtoffset = (int) (3600 * ((double) get_option('gmt_offset')));
    		$asp_post = array();
    			$asp_post['ID'] = $post->ID;
    			$asp_post['post_date_gmt'] = gmdate('Y-m-d H:i:s', time());
    			$asp_post['post_date'] = gmdate('Y-m-d H:i:s', time() + $gmtoffset);
    			$asp_post['post_status'] = 'auto-schedule';
    		wp_update_post($asp_post);
    		drip_publish();
    	}
    }

    Vahan4033 by your way, if someone uses for example the Contact Form 7 plugin, will have problems to. By my modification, seems works great.

    Hope this helps :D

  3. thedavis
    Member
    Posted 1 year ago #

    For the issue 2 that Vahan4033 explains I can't reproduce in WordPress 3.5.2 for now...

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.