equal
deleted
inserted
replaced
55 case 'attach': |
55 case 'attach': |
56 $parent_id = (int) $_REQUEST['found_post_id']; |
56 $parent_id = (int) $_REQUEST['found_post_id']; |
57 if ( !$parent_id ) |
57 if ( !$parent_id ) |
58 return; |
58 return; |
59 |
59 |
60 $parent = &get_post( $parent_id ); |
60 $parent = get_post( $parent_id ); |
61 if ( !current_user_can( 'edit_post', $parent_id ) ) |
61 if ( !current_user_can( 'edit_post', $parent_id ) ) |
62 wp_die( __( 'You are not allowed to edit this post.' ) ); |
62 wp_die( __( 'You are not allowed to edit this post.' ) ); |
63 |
63 |
64 $attach = array(); |
64 $attach = array(); |
65 foreach ( (array) $_REQUEST['media'] as $att_id ) { |
65 foreach ( (array) $_REQUEST['media'] as $att_id ) { |
67 |
67 |
68 if ( !current_user_can( 'edit_post', $att_id ) ) |
68 if ( !current_user_can( 'edit_post', $att_id ) ) |
69 continue; |
69 continue; |
70 |
70 |
71 $attach[] = $att_id; |
71 $attach[] = $att_id; |
72 clean_attachment_cache( $att_id ); |
|
73 } |
72 } |
74 |
73 |
75 if ( ! empty( $attach ) ) { |
74 if ( ! empty( $attach ) ) { |
76 $attach = implode( ',', $attach ); |
75 $attach_string = implode( ',', $attach ); |
77 $attached = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ( $attach )", $parent_id ) ); |
76 $attached = $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_parent = %d WHERE post_type = 'attachment' AND ID IN ( $attach_string )", $parent_id ) ); |
|
77 foreach ( $attach as $att_id ) { |
|
78 clean_attachment_cache( $att_id ); |
|
79 } |
78 } |
80 } |
79 |
81 |
80 if ( isset( $attached ) ) { |
82 if ( isset( $attached ) ) { |
81 $location = 'upload.php'; |
83 $location = 'upload.php'; |
82 if ( $referer = wp_get_referer() ) { |
84 if ( $referer = wp_get_referer() ) { |