Make import_function() return the new post ID
Refactor import_function and import_class to remove code duplication