Make WordPress Core

Ticket #25268: 25268.diff

File 25268.diff, 1.4 KB (added by jond3r, 11 years ago)
  • wp-admin/includes/post.php

     
    739739/**
    740740 * Replace hrefs of attachment anchors with up-to-date permalinks.
    741741 *
    742  * @since 2.3.0
     742 * @since 2.0.0
    743743 * @access private
    744744 *
    745  * @param unknown_type $post_ID
    746  * @return unknown
     745 * @param int|object $post_ID Post ID or post object.
     746 * @return void|int|WP_Error Void if nothing fixed. 0 or WP_Error on update failure. The post ID on update success.
    747747 */
    748748function _fix_attachment_links( $post_ID ) {
    749749        $post = get_post( $post_ID, ARRAY_A );
    750750        $content = $post['post_content'];
    751751
    752         // quick sanity check, don't run if no pretty permalinks or post is not published
    753         if ( !get_option('permalink_structure') || $post['post_status'] != 'publish' )
     752        // quick sanity check, don't run if no pretty permalinks, it's an attachment or post is a draft or pending
     753        if ( ! get_option( 'permalink_structure' ) || 'attachment' == $post['post_type'] || in_array( $post['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) )
    754754                return;
    755 
     755       
    756756        // Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero)
    757757        if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) )
    758758                return;