WordPress / wordpress-importer

The WordPress Importer
https://wordpress.org/plugins/wordpress-importer/
GNU General Public License v2.0
78 stars 76 forks source link

WP_CLI - Question #141

Open ghost opened 1 year ago

ghost commented 1 year ago

Is it possible to wrap the following echo when the import is completed from

echo '<p>' . __( 'All done.', 'wordpress-importer' ) . ' <a href="' . admin_url() . '">' . __( 'Have fun!', 'wordpress-importer' ) . '</a>' . '</p>';
echo '<p>' . __( 'Remember to update the passwords and roles of imported users.', 'wordpress-importer' ) . '</p>';

to

if ( ! defined( 'WP_CLI' ) ) {
    echo '<p>' . __( 'All done.', 'wordpress-importer' ) . ' <a href="' . admin_url() . '">' . __( 'Have fun!', 'wordpress-importer' ) . '</a>' . '</p>';
    echo '<p>' . __( 'Remember to update the passwords and roles of imported users.', 'wordpress-importer' ) . '</p>';
}

I found that having to use WP CLI to import data and each time when it completes it displays that even if you set import process with --quiet

the echo should still remain on output if you are importing from the dashboard.

What you guys think!

jrfnl commented 1 year ago

Not a guy here, but here's my opinion:

  1. I think the "Remember to update the passwords..." text is still pretty valuable when importing via WP-CLI, but it shouldn't display as HTML in that case, so a toggle to display (some of) the text depending on the context in which the command was run may be appropriate.
  2. I imagine it should be doable to figure out if WP-CLI is run in quiet mode ? And possibly not display the message in that case ?
ghost commented 1 year ago

Right, I agree with what you said with number 1, it shouldn't display as HTML and for Number 2, having to use --quiet should also prevent from displaying. So this is what it looks like when using WP CLI to import data

benlumia007@arcturus:~/.dev$ sturdydocker up
benlumia007@arcturus:~/.dev$ sturdydocker provision
<p>All done. <a href="https://dev.wordpress.test/wp-admin/">Have fun!</a></p><p>Remember to update the passwords and roles of imported users.</p>
benlumia007@arcturus:~/.dev$ 

this is with using wp import something.xml --authors=create --quiet so we should see if we can find way to not display the html tag when using the --quiet tag.

other than that without the --quiet tag, then it should display the messages when import is completed.

pattonwebz commented 1 year ago

What about a WP_CLI::log() message to inform about the password changes and any other relevant info? So it's not piping echo commands out but is still informing the useful information in a way expected by WP_CLI?