Support » Plugin: Content Aware Sidebars - Unlimited Widget Areas » Autosave creating bogus sidebars

  • Resolved marfarma


    Autosave is enabled on my site, and so, even though sidebars don’t support revisions, revisions are being saved, and bogus sidebars are the result.

    I’m about to test this code as a fix:

    public function __construct() {
    [ ... ]
        add_action('admin_enqueue_scripts', array(&$this,'admin_disable_autosave') );
    [ ... ]
    function admin_disable_autosave( $pagehook ) {
        global $post_type, $current_screen;
        if($post_type == 'wp_announcements')
          wp_deregister_script( 'autosave' );

    I’ll report back if I find it’s not correct. After I figure out how to get rid of the existing bogus revisions/sidebars!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Of course that should read

    if($post_type == 'sidebars')
          wp_deregister_script( 'autosave' );

    Well that doesn’t work.

    I’ll have to disable auto-save for the moment – I can live without it better than I can with Auto Draft sidebars being created at random.

    Any suggestion to prevent sidebars from being created as Auto Draft?

    Plugin Author Joachim Jensen


    I have not seen any revisions of sidebars in my database. Are you experiencing them or is it just Auto Draft?

    You can try to insert the following in wp-config:

    define('AUTOSAVE_INTERVAL', 60);
    define('WP_POST_REVISIONS', false );

    This will affect all post types though. I’m not even sure this would make the Auto Drafts not to show up anymore, but I know that there are some plugins out there that can help you optimize and maintain your database tables.

    However, the Auto Drafts should not cause any problems in the plugin itself as they are never pulled from the database.

    Auto Drafts are pulled from the database in my case: Screen Shot

    Additional discussion here:

    The following code change fixed it.

    	 * Create sidebars from content types
    	public function create_sidebars() {
    		$posts = get_posts(array(
    			'numberposts'	=> 0,
    			'post_type'	=> 'sidebar',
    			'post_status'	=> array('publish','private','future')
    		foreach($posts as $post)
    		  if ('Auto Draft' != $post->post_title)
      			register_sidebar( array(
      				'name'		=> $post->post_title,
      				'description'	=> $post->post_excerpt,
      				'id'		=> 'ca-sidebar-'.$post->ID,
      				'before_widget'	=> '<li id="%1$s" class="widget-container %2$s">',
      				'after_widget'	=> '</li>',
      				'before_title'	=> '<h3 class="widget-title">',
      				'after_title'	=> '</h3>',
    Plugin Author Joachim Jensen


    Now look at that. Have you had a look in the database? As you can see on the code, only published, private and scheduled sidebars should be pulled out. So my guess is that your Auto Draft somehow is in one of those states.

    What version of WordPress are you using? And is it possible for you to remove these custom sidebars in the administration?

    I’ts a dirty little fix you’ve made, and I’m not sure that it will make it to a release, but if it works for you then it wouldn’t be any harm either.

    What’s really weird is that the post_status is ‘auto-draft’

    I’m on 3.1.4 — I guess there’s a bug there for custom post types.

    No can’t delete them from the admin – only via direct mysql access.

    Plugin Author Joachim Jensen


    Maybe WP 3.1 does not support arrays as post_status for get_posts. Would be odd though… Try changing it to ‘publish’ and see if that solves the problem.

    I deleted them already.

    I’m happy enough with my hack for now. I’ll upgrade to 3.2.1 as soon as I can confirm that all my plugins are supported. That’s what’s held me back so far.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Autosave creating bogus sidebars’ is closed to new replies.