Check attachments as well as the current post type when checking for duplicate post slugs. This avoids creating a page with a slug which conflicts with an existing attachment (the inverse is already handled).

Updates the existing test for pages which should take priority over attachments in cases where an existing clash exists.

Fixes #18962
Props boonebgorges


git-svn-id: https://develop.svn.wordpress.org/trunk@30629 602fd350-edb4-49c9-b593-d223f7449a82