Make WordPress Core


Ignore:
Timestamp:
05/08/2012 05:01:50 PM (14 years ago)
Author:
ryan
Message:

Don't delete nav menu items when the user that owns them is deleted.

  • Introduce delete_with_user flag to register_post_type
  • Set delete_with_user to false for the nav_menu_item post type
  • Set it to true for all other core post types
  • If delete_with_user is not set, fallback to post_type_supports('author')

Props nacin
Fixes #16358

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/post.php

    r20734 r20739  
    3030                'rewrite' => false,
    3131                'query_var' => false,
     32                'delete_with_user' => true,
    3233                'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ),
    3334        ) );
    … …  
    4647                'rewrite' => false,
    4748                'query_var' => false,
     49                'delete_with_user' => true,
    4850                'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ),
    4951        ) );
    … …  
    6466                'query_var' => false,
    6567                'show_in_nav_menus' => false,
    66                 'supports' => array( 'comments' ),
     68                'delete_with_user' => true,
     69                'supports' => array( 'comments', 'author' ),
    6770        ) );
    6871
    … …  
    8184                'query_var' => false,
    8285                'can_export' => false,
     86                'delete_with_user' => true,
     87                'supports' => array( 'author' ),
    8388        ) );
    8489
    … …  
    9297                'hierarchical' => false,
    9398                'rewrite' => false,
     99                'delete_with_user' => false,
    94100                'query_var' => false,
    95101        ) );
    … …  
    934940 *     * If specified as a string, the query ?{query_var_string}={post_slug} will be valid.
    935941 * - can_export - Allows this post type to be exported. Defaults to true.
     942 * - delete_with_user - Whether to delete posts of this type when deleting a user.
     943 *     * If true, posts of this type belonging to the user will be moved to trash when then user is deleted.
     944 *     * If false, posts of this type belonging to the user will *not* be trashed or deleted.
     945 *     * If not set (the default), posts are trashed if post_type_supports('author'). Otherwise posts are not trashed or deleted.
    936946 * - _builtin - true if this post type is a native or "built-in" post_type. THIS IS FOR INTERNAL USE ONLY!
    937947 * - _edit_link - URL segement to use for edit link of this post type. THIS IS FOR INTERNAL USE ONLY!
    … …  
    960970                'can_export' => true,
    961971                'show_in_nav_menus' => null, 'show_in_menu' => null, 'show_in_admin_bar' => null,
     972                'delete_with_user' => null,
    962973        );
    963974        $args = wp_parse_args($args, $defaults);
Note: See TracChangeset for help on using the changeset viewer.