Ticket #25268: 25268.diff
File 25268.diff, 1.4 KB (added by , 11 years ago) |
---|
-
wp-admin/includes/post.php
739 739 /** 740 740 * Replace hrefs of attachment anchors with up-to-date permalinks. 741 741 * 742 * @since 2. 3.0742 * @since 2.0.0 743 743 * @access private 744 744 * 745 * @param unknown_type $post_ID746 * @return unknown745 * @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. 747 747 */ 748 748 function _fix_attachment_links( $post_ID ) { 749 749 $post = get_post( $post_ID, ARRAY_A ); 750 750 $content = $post['post_content']; 751 751 752 // quick sanity check, don't run if no pretty permalinks or post is not published753 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' ) ) ) 754 754 return; 755 755 756 756 // Short if there aren't any links or no '?attachment_id=' strings (strpos cannot be zero) 757 757 if ( !strpos($content, '?attachment_id=') || !preg_match_all( '/<a ([^>]+)>[\s\S]+?<\/a>/', $content, $link_matches ) ) 758 758 return;