[wp-trac] [WordPress Trac] #41172: Allow autosaving to be disabled on a per post type basis

WordPress Trac noreply at wordpress.org
Sat May 25 02:23:33 UTC 2024


#41172: Allow autosaving to be disabled on a per post type basis
---------------------------------------------+-----------------------------
 Reporter:  Frank Klein                      |       Owner:  (none)
     Type:  enhancement                      |      Status:  new
 Priority:  normal                           |   Milestone:  6.6
Component:  Autosave                         |     Version:
 Severity:  normal                           |  Resolution:
 Keywords:  has-patch has-unit-tests commit  |     Focuses:  administration
---------------------------------------------+-----------------------------
Changes (by rajinsharwar):

 * keywords:  has-patch has-unit-tests needs-testing commit => has-patch
     has-unit-tests commit


Comment:

 I have tested the patch with the below code.

 {{{#!php
 <?php
 /**
  * Register a custom post type called "book".
  *
  * @see get_post_type_labels() for label keys.
  */
 function wpdocs_codex_book_init() {
         $labels = array(
                 'name'                  => _x( 'Books', 'Post type general
 name', 'textdomain' ),
                 'singular_name'         => _x( 'Book', 'Post type singular
 name', 'textdomain' ),
                 'menu_name'             => _x( 'Books', 'Admin Menu text',
 'textdomain' ),
                 'name_admin_bar'        => _x( 'Book', 'Add New on
 Toolbar', 'textdomain' ),
                 'add_new'               => __( 'Add New', 'textdomain' ),
                 'add_new_item'          => __( 'Add New Book',
 'textdomain' ),
                 'new_item'              => __( 'New Book', 'textdomain' ),
                 'edit_item'             => __( 'Edit Book', 'textdomain'
 ),
                 'view_item'             => __( 'View Book', 'textdomain'
 ),
                 'all_items'             => __( 'All Books', 'textdomain'
 ),
                 'search_items'          => __( 'Search Books',
 'textdomain' ),
                 'parent_item_colon'     => __( 'Parent Books:',
 'textdomain' ),
                 'not_found'             => __( 'No books found.',
 'textdomain' ),
                 'not_found_in_trash'    => __( 'No books found in Trash.',
 'textdomain' ),
         );

         $args = array(
                 'labels'             => $labels,
                 'public'             => true,
                 'publicly_queryable' => true,
                 'show_ui'            => true,
                 'show_in_menu'       => true,
                 'query_var'          => true,
                 'rewrite'            => array( 'slug' => 'book' ),
                 'capability_type'    => 'post',
                 'has_archive'        => true,
                 'hierarchical'       => false,
                 'menu_position'      => null,
                 'show_in_rest'       => true,
                 'supports'           => array( 'title' ),
         );

         register_post_type( 'book', $args );
 }

 add_action( 'init', 'wpdocs_codex_book_init' );
 }}}


 ✅ With Editor Support, AutoSave is turned on by default.

 [[Image(https://img001.prntscr.com/file/img001/KeYnXtDdT8241snG5RD2LA.png)]]

 ✅ With NO Editor Support, AutoSave is turned NOT turned on by default.

 [[Image(https://img001.prntscr.com/file/img001/4mdp87VoQDe6QtOI58QNrg.png)]]

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/41172#comment:25>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list