Added pre-condition to make sure $post is set

Added a pre condition to the method to ensure that $post is actually set before attempting to access the ID value of it. If it's not set then false is returned.