Make WordPress Core


Ignore:
Timestamp:
09/29/2015 09:41:14 AM (9 years ago)
Author:
pento
Message:

Permalinks: Add pretty permalinks for unattached attachments.

Previously, unattached attachments would have unsightly /?attachment_id=1 URLs. As we've moved away from attachments being specifically attached to posts, instead being Media items, this has made the unattached URLs a more common occurrence.

We can breath easy once more, knowing that the world is a little bit safer from the horror of unnecessarily ugly URLs.

Props SergeyBiryukov, wonderboymusic, pento.

Fixes #1914.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/post.php

    r34670 r34690  
    12971297            $preview_target = " target='wp-preview-{$post->ID}'";
    12981298        } else {
    1299             if ( 'publish' === $post->post_status ) {
     1299            if ( 'publish' === $post->post_status || 'attachment' === $post->post_type ) {
    13001300                $view_link = get_permalink( $post );
    13011301            } else {
     
    13111311
    13121312        if ( false !== $view_link ) {
    1313             $return .= '<a id="sample-permalink" href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $permalink . "</a>\n";
     1313            $return .= '<a id="sample-permalink" href="' . esc_url( $view_link ) . '"' . $preview_target . '>' . $view_link . "</a>\n";
    13141314        } else {
    13151315            $return .= '<span id="sample-permalink">' . $permalink . "</span>\n";
Note: See TracChangeset for help on using the changeset viewer.