Make WordPress Core

Ticket #48227: preselect_existing_users_or_prepare_for_create_on_import.patch

File preselect_existing_users_or_prepare_for_create_on_import.patch, 2.2 KB (added by mgleich, 5 years ago)

preselect existing users or pre-fill for create on import

  • wp-content/plugins/wordpress-importer/wordpress-importer.php

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    174174                wp_defer_comment_counting( false );
    175175
    176176                echo '<p>' . __( 'All done.', 'wordpress-importer' ) . ' <a href="' . admin_url() . '">' . __( 'Have fun!', 'wordpress-importer' ) . '</a>' . '</p>';
    177                 echo '<p>' . __( 'Remember to update the passwords and roles of imported users.', 'wordpress-importer' ) . '</p>';
     177        if( ! empty($_POST['user_new'] ) ) {
     178            echo '<p>' . __('Remember to update the passwords and roles of imported users.', 'wordpress-importer') . '</p>';
     179        }
    178180
    179181                do_action( 'import_end' );
    180182        }
     
    302304                if ( $this->version != '1.0' )
    303305                        echo '<div style="margin-left:18px">';
    304306
     307        $user_id = username_exists($author['author_login']);
    305308                $create_users = $this->allow_create_users();
    306309                if ( $create_users ) {
    307310                        if ( $this->version != '1.0' ) {
    308311                                _e( 'or create new user with login name:', 'wordpress-importer' );
    309                                 $value = '';
     312                                $value = $user_id === false ? esc_attr( sanitize_user( $author['author_login'], true ) ) : '';
    310313                        } else {
    311314                                _e( 'as a new user:', 'wordpress-importer' );
    312315                                $value = esc_attr( sanitize_user( $author['author_login'], true ) );
     
    319322                        _e( 'assign posts to an existing user:', 'wordpress-importer' );
    320323                else
    321324                        _e( 'or assign posts to an existing user:', 'wordpress-importer' );
    322                 wp_dropdown_users( array( 'name' => "user_map[$n]", 'multi' => true, 'show_option_all' => __( '- Select -', 'wordpress-importer' ) ) );
     325                wp_dropdown_users( array( 'selected' => $user_id === false ? 0 : $user_id, 'name' => "user_map[$n]", 'multi' => true, 'show_option_all' => __( '- Select -', 'wordpress-importer' ) ) );
    323326                echo '<input type="hidden" name="imported_authors['.$n.']" value="' . esc_attr( $author['author_login'] ) . '" />';
    324327
    325328                if ( $this->version != '1.0' )