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

Built from https://develop.svn.wordpress.org/trunk@30629


git-svn-id: http://core.svn.wordpress.org/trunk@30619 1a063a9b-81f0-0310-95a4-ce76da25c4cd