Make WordPress Core

Ticket #31945: 31945-clean.diff

File 31945-clean.diff, 3.8 KB (added by Phyrax, 10 years ago)

Clean version of original diff, removed debug output, and empty lines.

  • wp-admin/includes/user.php

    diff --git wp-admin/includes/user.php wp-admin/includes/user.php
    index bcf1362..e63e696 100644
    function default_password_nag() { 
    440440        printf( '<a href="%s" id="default-password-nag-no">' . __('No thanks, do not remind me again') . '</a>', '?default_password_nag=0' );
    441441        echo '</p></div>';
    442442}
     443
     444/**
     445 * Gets the counts of content that will be affected by a user deletion.
     446 *
     447 * @param array $userids List of user ids being deleted.
     448 * @param int $blogid Blog id if using multi-site
     449 *
     450 * @return string HTML Content
     451 */
     452function wp_affected_delete_user_counts( $userids = array(), $blogid = 0 ) {
     453        if( is_multisite() && ! empty( $blogid ) ){
     454                switch_to_blog( intval( $blogid ) );
     455        }
     456
     457        if ( ! is_array( $userids ) ) {
     458                // Puts
     459                $userids = array( $userids );
     460        }
     461
     462        if ( ! is_array( $userids ) ) {
     463                return false;
     464        }
     465
     466        // Typecast all to integer.
     467        $userids = array_map( 'intval', $userids );
     468
     469        $affected_content = '';
     470        foreach( get_post_types( '', 'objects' ) as $post_type ) {
     471                $affected_count = 0;
     472                foreach ( $userids as $userid ) {
     473                        if ( empty( $userid ) ) {
     474                                continue;
     475                        }
     476                        $affected_count += count_user_posts( $userid, $post_type->name );
     477                }
     478
     479                if ( isset( $post_type->labels ) && isset( $post_type->labels->name ) ) {
     480                        $affected_content .= "<p>{$post_type->labels->name}: $affected_count</p>";
     481                }
     482        }
     483
     484        $output =  "<p><strong>";
     485        if ( '' != $affected_content ) {
     486                $output .= __( "Affected Content" );
     487        } else {
     488                $output .= __( "No content will be affected." );
     489        }
     490        $output .=  "</strong></p>";
     491        $output .=  $affected_content;
     492
     493        if ( is_multisite() && ! empty( $blogid ) ) {
     494                restore_current_blog();
     495        }
     496
     497        return $output;
     498
     499}
  • wp-admin/network/users.php

    diff --git wp-admin/network/users.php wp-admin/network/users.php
    index 86a4d74..3b07530 100644
    function confirm_delete_users( $users ) { 
    7070                                                        <?php echo __( 'Attribute all content to:' ) . '</label>' . $user_dropdown; ?></li>
    7171                                                </ul>
    7272                                                <?php
     73
     74                                                echo wp_affected_delete_user_counts( $user_id, $details->userblog_id );
    7375                                        }
    7476                                }
    7577                                echo "</fieldset>";
    function confirm_delete_users( $users ) { 
    7880        }
    7981
    8082        /** This action is documented in wp-admin/users.php */
    81         do_action( 'delete_user_form', $current_user );
     83        do_action( 'delete_user_form', $current_user, $allusers );
    8284
    8385        submit_button( __('Confirm Deletion'), 'delete' );
    8486        ?>
  • wp-admin/users.php

    diff --git wp-admin/users.php wp-admin/users.php
    index 64f029c..21862ab 100644
    case 'delete': 
    245245                wp_dropdown_users( array( 'name' => 'reassign_user', 'exclude' => array_diff( $userids, array($current_user->ID) ) ) ); ?></li>
    246246        </ul></fieldset>
    247247        <?php
     248
     249        echo wp_affected_delete_user_counts( $userids );
     250
    248251        /**
    249252         * Fires at the end of the delete users form prior to the confirm button.
    250253         *
    251254         * @since 4.0.0
    252255         *
    253          * @param WP_User $current_user WP_User object for the user being deleted.
     256         * @param WP_User $current_user WP_User object currently logged in user.
     257         * @param array $userids List of user ids currently being deleted.
    254258         */
    255         do_action( 'delete_user_form', $current_user );
     259        do_action( 'delete_user_form', $current_user, $userids );
    256260        ?>
    257261        <input type="hidden" name="action" value="dodelete" />
    258262        <?php submit_button( __('Confirm Deletion'), 'secondary' ); ?>
  • wp-includes/post.php

    diff --git wp-includes/post.php wp-includes/post.php
    index c8963e6..2f06551 100644
    function get_posts_by_author_sql( $post_type, $full = true, $post_author = null, 
    52975297                } // else none
    52985298        }
    52995299
     5300        if ( 'attachment' == $post_type ) {
     5301                $sql .= " OR post_status = 'inherit'";
     5302        }
     5303
    53005304        $sql .= ')';
    53015305
    53025306        return $sql;