WP_CLI\Utils
report_batch_operation_results()
Report the results of the same operation against multiple resources.
Хуков нет.
Возвращает
null
. Ничего (null).
Использование
report_batch_operation_results( $noun, $verb, $total, $successes, $failures, $skips );
- $noun(строка) (обязательный)
- Resource being affected (e.g. plugin).
- $verb(строка) (обязательный)
- Type of action happening to the noun (e.g. activate).
- $total(int) (обязательный)
- Total number of resource being affected.
- $successes(int) (обязательный)
- Number of successful operations.
- $failures(int) (обязательный)
- Number of failures.
- $skips(null|int)
- Number of skipped operations.
По умолчанию: null (don't show skips)
Код report_batch_operation_results() report batch operation results WP-CLI 2.8.0-alpha
function report_batch_operation_results( $noun, $verb, $total, $successes, $failures, $skips = null ) { $plural_noun = $noun . 's'; $past_tense_verb = past_tense_verb( $verb ); $past_tense_verb_upper = ucfirst( $past_tense_verb ); if ( $failures ) { $failed_skipped_message = null === $skips ? '' : " ({$failures} failed" . ( $skips ? ", {$skips} skipped" : '' ) . ')'; if ( $successes ) { WP_CLI::error( "Only {$past_tense_verb} {$successes} of {$total} {$plural_noun}{$failed_skipped_message}." ); } else { WP_CLI::error( "No {$plural_noun} {$past_tense_verb}{$failed_skipped_message}." ); } } else { $skipped_message = $skips ? " ({$skips} skipped)" : ''; if ( $successes || $skips ) { WP_CLI::success( "{$past_tense_verb_upper} {$successes} of {$total} {$plural_noun}{$skipped_message}." ); } else { $message = $total > 1 ? ucfirst( $plural_noun ) : ucfirst( $noun ); WP_CLI::success( "{$message} already {$past_tense_verb}." ); } } }