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