Forums

how to disable autosave in WP3.3 ? (6 posts)

  1. aljuk
    Member
    Posted 5 months ago #

    I've always used this:

    function disableAutoSave(){
    wp_deregister_script('autosave');
    }
    add_action( 'wp_print_scripts', 'disableAutoSave' );

    but in WP 3.3 (Debug On) it throws:

    Notice: Undefined index: autosave in /{path}/wp-includes/class.wp-scripts.php on line 158

    Notice: Trying to get property of non-object in /{path}/wp-includes/class.wp-scripts.php on line 158

    What's the correct implementation?

  2. Dale Sattler
    Member
    Posted 5 months ago #

    Workaround it with?

    define('AUTOSAVE_INTERVAL', SOME_LONG_TIME_PERIOD);

  3. aljuk
    Member
    Posted 5 months ago #

    Thanks but no. I wish to disable it.

  4. Mark / t31os
    Moderator
    Posted 5 months ago #

    Not sure if this method still works, but it did last time i tried it.

    function hacky_autosave_disabler( $src, $handle ) {
        if( 'autosave' != $handle )
            return $src;
        return '';
    }
    add_filter( 'script_loader_src', 'hacky_autosave_disabler', 10, 2 );

    Simply wipes out the src value for the autosave script, which in essence stops the auto saves(or did last time i tested it in 3.0).

  5. aljuk
    Member
    Posted 4 months ago #

    Many thanks, I'll give it a go.

  6. Egill R. Erlendsson
    Member
    Posted 4 months ago #

    Throw this in your functions.php

    add_action( 'admin_init', 'disable_autosave' );
    function disable_autosave() {
            wp_deregister_script( 'autosave' );
    }

Reply

You must log in to post.

About this Topic