From 1fc763e85ee706c0a8fc7d6bfff584f843c0efc9 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Thu, 21 Mar 2019 20:12:50 +0000 Subject: [PATCH] Users: Introduce `users_have_additional_content` filter to indicate whether the users being deleted have additional content associated with them outside of the `post_author` and `link_owner` relationships. Props garrett-eclipse, xkon, birgire. Fixes #36860. Built from https://develop.svn.wordpress.org/trunk@44967 git-svn-id: http://core.svn.wordpress.org/trunk@44798 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/users.php | 22 +++++++++++++++++----- wp-includes/version.php | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/wp-admin/users.php b/wp-admin/users.php index b79e5a8672..7ba4aed006 100644 --- a/wp-admin/users.php +++ b/wp-admin/users.php @@ -234,11 +234,23 @@ switch ( $wp_list_table->current_action() ) { $userids = array_map( 'intval', (array) $_REQUEST['users'] ); } - $users_have_content = false; - if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) { - $users_have_content = true; - } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) { - $users_have_content = true; + /** + * Filters whether the users being deleted have additional content + * associated with them outside of the `post_author` and `link_owner` relationships. + * + * @since 5.2.0 + * + * @param boolean $users_have_additional_content Whether the users have additional content. Default false. + * @param int[] $userids Array of IDs for users being deleted. + */ + $users_have_content = (bool) apply_filters( 'users_have_additional_content', false, $userids ); + + if ( ! $users_have_content ) { + if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) { + $users_have_content = true; + } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) { + $users_have_content = true; + } } if ( $users_have_content ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index fa861b66b8..3981199b4a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.2-alpha-44966'; +$wp_version = '5.2-alpha-44967'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.