Add WP CLI Command
if (class_exists('WP_CLI')) {
WP_CLI::add_command('wpm_pipm_import', 'wpm_pipm_import', $args = array());
}
/**
* @param $message
*/
function wpm_log($message)
{
if (class_exists('WP_CLI')) {
WP_CLI::log(date('H:i:s') . ' ' . $message);
} else {
echo date('H:i:s') . ' ' . $message . PHP_EOL;
}
}
wpm_log('Getting catalog');
// ...
wpm_log('Catalog grabbed');
$progress = WP_CLI\Utils\make_progress_bar('Creating top categories', $categories_count);
foreach (...) {
$progress->tick();
}