Perfect method for prohibiting article revision and automatic saving in wordpress

  • 2021-07-24 10:21:23
  • OfStack

Using Wordpress for so long, I hate wordpress's article revision and automatic saving function, and I have also used super switch plug-in to prohibit wordpress's article revision and automatic saving function, but there are enough plug-ins in my blog, so I have to modify wordpress main program to realize the function of prohibiting article revision and automatic saving. But this method has a bad place is, every time wordpress upgrade, you have to change the source code of wordpress once again, which is really very troublesome. Today, I accidentally bumped into ZWW blog and found that this non-plug-in modification-free source code realizes wordpress's method of prohibiting article revision and automatic saving, and share it with everyone!

It's easy to use, just add the corresponding code in functions. php in the topic directory, and the code is as follows:


/* Remove AutoSave and Revise Versions */ 
remove_action('pre_post_update', 'wp_save_post_revision' );  
add_action( 'wp_print_scripts', 'disable_autosave' );  
function disable_autosave(){  
    wp_deregister_script('autosave');  

Test environment: WordPress 3.1. 2, which is supported above 3.0 in principle.


Related articles: