public function __invoke($args, $assoc_args) { $batch_size = isset($assoc_args['batch']) ? (int)$assoc_args['batch'] : 25; $page = isset($assoc_args['page']) ? (int)$assoc_args['page'] : 0; $max_image_size = 10 * 1024 * 1024; // 10MB $min_width = 300; $min_height = 300; require_once ABSPATH . 'wp-admin/includes/image.php'; require_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH . 'wp-admin/includes/media.php'; $posts = get_posts([ 'post_type' => 'post', 'post_status' => 'publish', 'numberposts' => $batch_size, 'offset' => $page * $batch_size, 'meta_query' => [ [ 'key' => '_featured_image_checked', 'compare' => 'NOT EXISTS', ], ], ]); if (empty($posts)) { WP_CLI::success("✅ All posts processed."); return; } foreach ($posts as $post) { // (Your image checking and downloading code here, no change) } WP_CLI::log("✅ Batch $page completed. Next batch: " . ($page + 1)); }