Make WordPress Core

Ticket #13429: 13429-3.patch

File 13429-3.patch, 3.4 KB (added by azaozz, 13 years ago)
  • wp-admin/includes/deprecated.php

     
    936936        _deprecated_function( __FUNCTION__, '3.4', 'wp_get_theme()' );
    937937
    938938        return wp_get_theme();
    939 }
    940  No newline at end of file
     939}
     940
     941/**
     942 * Replace hrefs of attachment anchors with up-to-date permalinks.
     943 *
     944 * @since 2.3.0
     945 * @deprecated 3.4.0
     946 * @access private
     947 *
     948 * @param unknown_type $post_ID
     949 * @return unknown
     950 */
     951function _fix_attachment_links( $post_ID ) {
     952        _deprecated_function( __FUNCTION__, '3.4' );
     953       
     954        return $post_ID;
     955}
     956
     957/**
     958 * Callback for _fix_attachment_links()
     959 *
     960 * @deprecated 3.4.0
     961 * @access private
     962 */
     963function _fix_attachment_links_replace_cb() {
     964    _deprecated_function( __FUNCTION__, '3.4' );
     965}
     966
  • wp-admin/includes/post.php

     
    229229
    230230        wp_update_post( $post_data );
    231231
    232         // Now that we have an ID we can fix any attachment anchor hrefs
    233         _fix_attachment_links( $post_ID );
    234 
    235232        wp_set_post_lock( $post_ID );
    236233
    237234        if ( current_user_can( $ptype->cap->edit_others_posts ) ) {
     
    588585
    589586        add_post_meta( $post_ID, '_edit_last', $GLOBALS['current_user']->ID );
    590587
    591         // Now that we have an ID we can fix any attachment anchor hrefs
    592         _fix_attachment_links( $post_ID );
    593 
    594588        wp_set_post_lock( $post_ID );
    595589
    596590        return $post_ID;
     
    740734//
    741735
    742736/**
    743  * Replace hrefs of attachment anchors with up-to-date permalinks.
    744  *
    745  * @since 2.3.0
    746  * @access private
    747  *
    748  * @param unknown_type $post_ID
    749  * @return unknown
    750  */
    751 function _fix_attachment_links( $post_ID ) {
    752         global $_fix_attachment_link_id;
    753 
    754         $post = & get_post( $post_ID, ARRAY_A );
    755 
    756         $search = "#<a[^>]+rel=('|\")[^'\"]*attachment[^>]*>#ie";
    757 
    758         // See if we have any rel="attachment" links
    759         if ( 0 == preg_match_all( $search, $post['post_content'], $anchor_matches, PREG_PATTERN_ORDER ) )
    760                 return;
    761 
    762         $i = 0;
    763         $search = "#[\s]+rel=(\"|')(.*?)wp-att-(\d+)\\1#i";
    764         foreach ( $anchor_matches[0] as $anchor ) {
    765                 if ( 0 == preg_match( $search, $anchor, $id_matches ) )
    766                         continue;
    767 
    768                 $id = (int) $id_matches[3];
    769 
    770                 // While we have the attachment ID, let's adopt any orphans.
    771                 $attachment = & get_post( $id, ARRAY_A );
    772                 if ( ! empty( $attachment) && ! is_object( get_post( $attachment['post_parent'] ) ) ) {
    773                         $attachment['post_parent'] = $post_ID;
    774                         // Escape data pulled from DB.
    775                         $attachment = add_magic_quotes( $attachment );
    776                         wp_update_post( $attachment );
    777                 }
    778 
    779                 $post_search[$i] = $anchor;
    780                  $_fix_attachment_link_id = $id;
    781                 $post_replace[$i] = preg_replace_callback( "#href=(\"|')[^'\"]*\\1#", '_fix_attachment_links_replace_cb', $anchor );
    782                 ++$i;
    783         }
    784 
    785         $post['post_content'] = str_replace( $post_search, $post_replace, $post['post_content'] );
    786 
    787         // Escape data pulled from DB.
    788         $post = add_magic_quotes( $post);
    789 
    790         return wp_update_post( $post);
    791 }
    792 
    793 function _fix_attachment_links_replace_cb($match) {
    794         global $_fix_attachment_link_id;
    795         return stripslashes( 'href='.$match[1] ).get_attachment_link( $_fix_attachment_link_id ).stripslashes( $match[1] );
    796 }
    797 
    798 /**
    799737 * Move child posts to a new parent.
    800738 *
    801739 * @since 2.3.0