Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/post.php

    r12110 r12298  
    714714 */
    715715function _fix_attachment_links( $post_ID ) {
     716    global $_fix_attachment_link_id;
    716717
    717718    $post = & get_post( $post_ID, ARRAY_A );
     
    741742
    742743        $post_search[$i] = $anchor;
    743         $post_replace[$i] = preg_replace( "#href=(\"|')[^'\"]*\\1#e", "stripslashes( 'href=\\1' ).get_attachment_link( $id ).stripslashes( '\\1' )", $anchor );
     744         $_fix_attachment_link_id = $id;
     745        $post_replace[$i] = preg_replace_callback( "#href=(\"|')[^'\"]*\\1#", '_fix_attachment_links_replace_cb', $anchor );
    744746        ++$i;
    745747    }
     
    751753
    752754    return wp_update_post( $post);
     755}
     756
     757function _fix_attachment_links_replace_cb($match) {
     758        global $_fix_attachment_link_id;
     759        return stripslashes( 'href='.$match[1] ).get_attachment_link( $_fix_attachment_link_id ).stripslashes( $match[1] );
    753760}
    754761
     
    767774    $old_ID = (int) $old_ID;
    768775    $new_ID = (int) $new_ID;
    769     return $wpdb->update($wpdb->posts, array('post_parent' => $new_ID), array('post_parent' => $old_ID) );
     776
     777    $children = $wpdb->get_col( $wpdb->prepare("
     778        SELECT post_id
     779        FROM $wpdb->postmeta
     780        WHERE meta_key = '_wp_attachment_temp_parent'
     781        AND meta_value = %d", $old_ID) );
     782
     783    foreach ( $children as $child_id ) {
     784        $wpdb->update($wpdb->posts, array('post_parent' => $new_ID), array('ID' => $child_id) );
     785        delete_post_meta($child_id, '_wp_attachment_temp_parent');
     786    }
    770787}
    771788
     
    927944 * @since unknown
    928945 *
    929  * @param unknown_type $id
    930  * @param unknown_type $title
    931  * @param unknown_type $name
    932  * @return unknown
     946 * @param int|object $id    Post ID or post object.
     947 * @param string $title (optional) Title
     948 * @param string $name (optional) Name
     949 * @return array With two entries of type string
    933950 */
    934951function get_sample_permalink($id, $title = null, $name = null) {
     
    945962    if (in_array($post->post_status, array('draft', 'pending'))) {
    946963        $post->post_status = 'publish';
    947         $post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID);
     964        $post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID);
    948965    }
    949966
     
    953970    // Note: if empty name is supplied -- use the title instead, see #6072
    954971    if (!is_null($name)) {
    955         $post->post_name = sanitize_title($name? $name : $title, $post->ID);
     972        $post->post_name = sanitize_title($name ? $name : $title, $post->ID);
    956973    }
    957974
     
    981998
    982999/**
    983  * {@internal Missing Short Description}}
    984  *
    985  * @since unknown
    986  *
    987  * @param unknown_type $id
    988  * @param unknown_type $new_title
    989  * @param unknown_type $new_slug
    990  * @return unknown
     1000 * sample permalink html
     1001 *
     1002 * intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
     1003 *
     1004 * @since unknown
     1005 *
     1006 * @param int|object $id Post ID or post object.
     1007 * @param string $new_title (optional) New title 
     1008 * @param string $new_slug (optional) New slug
     1009 * @return string intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
    9911010 */
    9921011function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
Note: See TracChangeset for help on using the changeset viewer.