Make WordPress Core

Ticket #25268: 25268-2.diff

File 25268-2.diff, 1.3 KB (added by jond3r, 11 years ago)

Whitelist publish-like statuses

  • wp-admin/includes/post.php

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