Changeset 20739
- Timestamp:
- 05/08/2012 05:01:50 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/user.php
r20581 r20739 244 244 245 245 if ( 'novalue' === $reassign || null === $reassign ) { 246 $post_ids = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id) ); 247 246 $post_types_to_delete = array(); 247 foreach ( get_post_types( array(), 'objects' ) as $post_type ) { 248 if ( $post_type->delete_with_user ) { 249 $post_types_to_delete[] = $post_type->name; 250 } elseif ( null === $post_type->delete_with_user && post_type_supports( $post_type->name, 'author' ) ) { 251 $post_types_to_delete[] = $post_type->name; 252 } 253 } 254 255 $post_types_to_delete = apply_filters( 'post_types_to_delete_with_user', $post_types_to_delete, $id ); 256 $post_types_to_delete = implode( "', '", $post_types_to_delete ); 257 $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d AND post_type IN ('$post_types_to_delete')", $id ) ); 248 258 if ( $post_ids ) { 249 259 foreach ( $post_ids as $post_id ) 250 wp_delete_post( $post_id);260 wp_delete_post( $post_id ); 251 261 } 252 262 -
trunk/wp-includes/post.php
r20734 r20739 30 30 'rewrite' => false, 31 31 'query_var' => false, 32 'delete_with_user' => true, 32 33 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'post-formats' ), 33 34 ) ); … … 46 47 'rewrite' => false, 47 48 'query_var' => false, 49 'delete_with_user' => true, 48 50 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ), 49 51 ) ); … … 64 66 'query_var' => false, 65 67 'show_in_nav_menus' => false, 66 'supports' => array( 'comments' ), 68 'delete_with_user' => true, 69 'supports' => array( 'comments', 'author' ), 67 70 ) ); 68 71 … … 81 84 'query_var' => false, 82 85 'can_export' => false, 86 'delete_with_user' => true, 87 'supports' => array( 'author' ), 83 88 ) ); 84 89 … … 92 97 'hierarchical' => false, 93 98 'rewrite' => false, 99 'delete_with_user' => false, 94 100 'query_var' => false, 95 101 ) ); … … 934 940 * * If specified as a string, the query ?{query_var_string}={post_slug} will be valid. 935 941 * - 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. 936 946 * - _builtin - true if this post type is a native or "built-in" post_type. THIS IS FOR INTERNAL USE ONLY! 937 947 * - _edit_link - URL segement to use for edit link of this post type. THIS IS FOR INTERNAL USE ONLY! … … 960 970 'can_export' => true, 961 971 'show_in_nav_menus' => null, 'show_in_menu' => null, 'show_in_admin_bar' => null, 972 'delete_with_user' => null, 962 973 ); 963 974 $args = wp_parse_args($args, $defaults);
Note: See TracChangeset
for help on using the changeset viewer.