When filtering doc permalinks, rebuild URL to cut off all parent slugs

The previous code for generating canonical Doc URLs attempted to slice off
the slug of $post->post_parent when it was found. But this did not work for
Docs that were nested more than one level deep.

The new code enforces a totally flat URL structure by rebuilding the URL based
on the Docs archive link.

Fixes #308