add_action('after_setup_theme', function() { $file = get_stylesheet_directory() . '/my-file.php'; touch($file); });
add_action('after_setup_theme', function() { $file = get_stylesheet_directory() . '/my-file.php'; if(!file_exists($file)) { include_once ABSPATH . 'wp-admin/includes/file.php'; \WP_Filesystem(); global $wp_filesystem; $wp_filesystem->put_contents($file, '', FS_CHMOD_FILE); } });