fix PHP Fatal error:  Call to undefined function wp_generate_attachment_metadata() while running in wp-cron