WordPress.org

Make WordPress Core

Ticket #36860: 36860.7.diff

File 36860.7.diff, 1.5 KB (added by garrett-eclipse, 9 months ago)

Patch to cleanup the code and remove need of extra variable, but kept the contextual filter name

  • src/wp-admin/users.php

     
    234234                        $userids = array_map( 'intval', (array) $_REQUEST['users'] );
    235235                }
    236236
    237                 $users_have_content = false;
    238                 if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
    239                         $users_have_content = true;
    240                 } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
    241                         $users_have_content = true;
     237                /**
     238                 * Filter to indicate whether the users have additional content attached to them outside of the post_author & link_owner relationships.
     239                 *
     240                 * @since 5.2.0
     241                 *
     242                 * @param boolean $users_have_additional_content The flag for users have additional content. Default is `false`.
     243                 * @param int[]   $userids                       Array of IDs for users being deleted.
     244                 */
     245                $users_have_content = (bool) apply_filters( 'users_have_additional_content', false, $userids );
     246
     247                if ( ! $users_have_content ) {
     248                        if ( $wpdb->get_var( "SELECT ID FROM {$wpdb->posts} WHERE post_author IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
     249                                $users_have_content = true;
     250                        } elseif ( $wpdb->get_var( "SELECT link_id FROM {$wpdb->links} WHERE link_owner IN( " . implode( ',', $userids ) . ' ) LIMIT 1' ) ) {
     251                                $users_have_content = true;
     252                        }
    242253                }
    243254
    244255                if ( $users_have_content ) {