以前,发表过《禁用wp文章自动保存功能并清空WordPress修订版本》,其中的代码,只有一部分还能用,下面是彻底禁用wordpress自动保存功能,只不过得需要修改源文件,如果你是完美控,那么就往下面看:
1、修改两个文件:wp-admin/post-new.php和wp-admin/post.php,注释掉代码即可:
wp-admin/post-new.php(约57行) //wp_enqueue_script('autosave'); wp-admin/post.php(约187行) /*if ( 'attachment' !== $post_type ) wp_enqueue_script('autosave');*/
2、还需要修改一个文件,打开wp-admin/includes/post.php,查找$create_in_db,如下:
$post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); $post = get_post( $post_id );
直接注释前2行,并加入以下代码,即可关闭WordPress4.1.1的自动草稿功能了,即:
/* $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); $post = get_post( $post_id ); */ /* starting... */ global $current_user,$wpdb; $post = $wpdb->get_row( "SELECT * FROM $wpdb->posts WHERE post_status = 'auto-draft' AND post_type = '$post_type' AND post_author = $current_user->ID ORDER BY ID ASC LIMIT 1" ); if (!($post) ) { $post_id = wp_insert_post( array( 'post_title' => __( 'Auto Draft' ), 'post_type' => $post_type, 'post_status' => 'auto-draft' ) ); $post = get_post( $post_id ); } /* End */
大功告成!
直接有插件可去掉该功能,改文件始终不是个办法
求插件的名称。。。