Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"wp-cli/entity-command": "^1.3 || ^2",
"wp-cli/export-command": "^1 || ^2",
"wp-cli/extension-command": "^1.2 || ^2",
"wp-cli/wp-cli-tests": "^3.1"
"wp-cli/wp-cli-tests": "^4"
},
"config": {
"process-timeout": 7200,
Expand Down
2 changes: 1 addition & 1 deletion import-command.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
return;
}

$wpcli_import_autoloader = dirname( __FILE__ ) . '/vendor/autoload.php';
$wpcli_import_autoloader = __DIR__ . '/vendor/autoload.php';
if ( file_exists( $wpcli_import_autoloader ) ) {
require_once $wpcli_import_autoloader;
}
Expand Down
20 changes: 8 additions & 12 deletions src/Import_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private function add_wxr_filters() {

add_filter(
'wp_import_posts',
function( $posts ) {
function ( $posts ) {
global $wpcli_import_counts;
$wpcli_import_counts['current_post'] = 0;
$wpcli_import_counts['total_posts'] = count( $posts );
Expand All @@ -221,7 +221,7 @@ function( $posts ) {

add_filter(
'wp_import_post_comments',
function( $comments, $post_id, $post ) {
function ( $comments, $post_id, $post ) {
global $wpcli_import_counts;
$wpcli_import_counts['current_comment'] = 0;
$wpcli_import_counts['total_comments'] = count( $comments );
Expand All @@ -233,7 +233,7 @@ function( $comments, $post_id, $post ) {

add_filter(
'wp_import_post_data_raw',
function( $post ) {
function ( $post ) {
global $wpcli_import_counts, $wpcli_import_current_file;

$wpcli_import_counts['current_post']++;
Expand All @@ -249,7 +249,7 @@ function( $post ) {

add_action(
'wp_import_insert_post',
function( $post_id, $original_post_id, $post, $postdata ) {
function ( $post_id, $original_post_id, $post, $postdata ) {
global $wpcli_import_counts;
if ( is_wp_error( $post_id ) ) {
WP_CLI::warning( '-- Error importing post: ' . $post_id->get_error_code() );
Expand All @@ -261,15 +261,14 @@ function( $post_id, $original_post_id, $post, $postdata ) {
WP_CLI\Utils\wp_clear_object_cache();
WP_CLI::log( '-- Cleared object cache.' );
}

},
10,
4
);

add_action(
'wp_import_insert_term',
function( $t, $import_term, $post_id, $post ) {
function ( $t, $import_term, $post_id, $post ) {
WP_CLI::log( "-- Created term \"{$import_term['name']}\"" );
},
10,
Expand All @@ -278,7 +277,7 @@ function( $t, $import_term, $post_id, $post ) {

add_action(
'wp_import_set_post_terms',
function( $tt_ids, $term_ids, $taxonomy, $post_id, $post ) {
function ( $tt_ids, $term_ids, $taxonomy, $post_id, $post ) {
WP_CLI::log( '-- Added terms (' . implode( ',', $term_ids ) . ") for taxonomy \"{$taxonomy}\"" );
},
10,
Expand All @@ -287,7 +286,7 @@ function( $tt_ids, $term_ids, $taxonomy, $post_id, $post ) {

add_action(
'wp_import_insert_comment',
function( $comment_id, $comment, $comment_post_id, $post ) {
function ( $comment_id, $comment, $comment_post_id, $post ) {
global $wpcli_import_counts;
$wpcli_import_counts['current_comment']++;
WP_CLI::log( sprintf( '-- Added comment #%d (%s of %s)', $comment_id, number_format( $wpcli_import_counts['current_comment'] ), number_format( $wpcli_import_counts['total_comments'] ) ) );
Expand All @@ -298,13 +297,12 @@ function( $comment_id, $comment, $comment_post_id, $post ) {

add_action(
'import_post_meta',
function( $post_id, $key, $value ) {
function ( $post_id, $key, $value ) {
WP_CLI::log( "-- Added post_meta $key" );
},
10,
3
);

}

/**
Expand Down Expand Up @@ -448,7 +446,6 @@ private function create_authors_for_mapping( $author_data ) {
);
}
return $author_mapping;

}

/**
Expand Down Expand Up @@ -499,5 +496,4 @@ private function suggest_user( $author_user_login, $author_user_email = '' ) {

return $closest;
}

}