Make WordPress Core

Ticket #21092: 21092.diff

File 21092.diff, 2.5 KB (added by evansolomon, 13 years ago)
  • wp-admin/includes/media.php

     
    11521152                'extra_rows' => array(),
    11531153        );
    11541154
    1155         if ( $send )
    1156                 $send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false );
     1155        if ( $send ) {
     1156                if ( isset( $_POST ) && isset( $_POST['attachment_id'] ) ) {
     1157                        $attachment_parent_id = wp_get_post_parent_id( $_POST['attachment_id'] );
     1158                        $parent_type = get_post_type_object( get_post_type( $attachment_parent_id ) );
     1159                }
     1160                elseif( isset( $_GET ) && isset( $_GET['post_id'] ) ) {
     1161                        $parent_type = get_post_type_object( get_post_type( $_GET['post_id'] ) );
     1162                }
     1163
     1164                if( isset( $parent_type ) )
     1165                        $parent_type_singular = $parent_type->labels->singular_name;
     1166                else
     1167                        $parent_type_singular = 'Post';
     1168
     1169                $send = get_submit_button( sprintf( __( 'Insert into %1$s' ), $parent_type_singular ), 'button', "send[$attachment_id]", false );
     1170        }
    11571171        if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) {
    11581172                if ( !EMPTY_TRASH_DAYS ) {
    11591173                        $delete = "<a href='" . wp_nonce_url( "post.php?action=delete&amp;post=$attachment_id", 'delete-attachment_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Delete Permanently' ) . '</a>';
     
    19291943 * @return unknown
    19301944 */
    19311945function wp_media_insert_url_form( $default_view = 'image' ) {
     1946        if( isset( $_GET ) && isset( $_GET['post_id'] ) )
     1947                $parent_type = get_post_type_object( get_post_type( $_GET['post_id'] ) );
     1948
     1949        if( isset( $parent_type ) )
     1950                $parent_type_singular = $parent_type->labels->singular_name;
     1951        else
     1952                $parent_type_singular = 'Post';
     1953
    19321954        if ( !apply_filters( 'disable_captions', '' ) ) {
    19331955                $caption = '
    19341956                <tr class="image-only">
     
    20092031                <tr class="image-only">
    20102032                        <td></td>
    20112033                        <td>
    2012                                 <input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . esc_attr__('Insert into Post') . '" />
     2034                                <input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . esc_attr__( sprintf( 'Insert into %1$s', $parent_type_singular ) ) . '" />
    20132035                        </td>
    20142036                </tr>
    20152037                <tr class="not-image">
    20162038                        <td></td>
    20172039                        <td>
    2018                                 ' . get_submit_button( __( 'Insert into Post' ), 'button', 'insertonlybutton', false ) . '
     2040                                ' . get_submit_button( sprintf( __( 'Insert into %1$s' ), $parent_type_singular ), 'button', 'insertonlybutton', false ) . '
    20192041                        </td>
    20202042                </tr>
    20212043        </tbody></table>