Make WordPress Core

Ticket #21092: 21092.2.diff

File 21092.2.diff, 3.6 KB (added by evansolomon, 13 years ago)

Introduces an optional post type label

  • 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                        if ( $parent_type->labels->insert_into_post )
     1166                                $parent_insert_into_post = $parent_type->labels->insert_into_post;
     1167                        else
     1168                                $parent_insert_into_post = sprintf( __( 'Insert Into %1$s' ), $parent_type->labels->singular_name );
     1169                }
     1170                else {
     1171                        $parent_insert_into_post = __( 'Insert Into Post' );
     1172                }
     1173
     1174                $send = get_submit_button( $parent_insert_into_post, 'button', "send[$attachment_id]", false );
     1175        }
    11571176        if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) {
    11581177                if ( !EMPTY_TRASH_DAYS ) {
    11591178                        $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>';
     
    19291948 * @return unknown
    19301949 */
    19311950function wp_media_insert_url_form( $default_view = 'image' ) {
     1951        if( isset( $_GET ) && isset( $_GET['post_id'] ) )
     1952                $parent_type = get_post_type_object( get_post_type( $_GET['post_id'] ) );
     1953
     1954
     1955        if ( isset( $parent_type ) ) {
     1956                if ( isset( $parent_type->labels->insert_into_post ) )
     1957                        $parent_insert_into_post = $parent_type->labels->insert_into_post;
     1958                else
     1959                        $parent_insert_into_post = sprintf( __( 'Insert Into %1$s' ), $parent_type->labels->singular_name );
     1960        }
     1961        else {
     1962                $parent_insert_into_post = __( 'Insert Into Post' );
     1963        }
     1964
     1965
     1966
    19321967        if ( !apply_filters( 'disable_captions', '' ) ) {
    19331968                $caption = '
    19341969                <tr class="image-only">
     
    20092044                <tr class="image-only">
    20102045                        <td></td>
    20112046                        <td>
    2012                                 <input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . esc_attr__('Insert into Post') . '" />
     2047                                <input type="button" class="button" id="go_button" style="color:#bbb;" onclick="addExtImage.insert()" value="' . esc_attr__( $parent_insert_into_post ) . '" />
    20132048                        </td>
    20142049                </tr>
    20152050                <tr class="not-image">
    20162051                        <td></td>
    20172052                        <td>
    2018                                 ' . get_submit_button( __( 'Insert into Post' ), 'button', 'insertonlybutton', false ) . '
     2053                                ' . get_submit_button( $parent_insert_into_post, 'button', 'insertonlybutton', false ) . '
    20192054                        </td>
    20202055                </tr>
    20212056        </tbody></table>
  • wp-includes/post.php

     
    12221222 * - parent_item_colon - This string isn't used on non-hierarchical types. In hierarchical ones the default is Parent Page:
    12231223 * - all_items - String for the submenu. Default is All Posts/All Pages
    12241224 * - menu_name - Default is the same as <code>name</code>
     1225 * - insert_into_post - Optional. String for the media uploader screen. Default is null, when it isn't explicitly set the media upload will use Insert Into $object->label->singular_name
    12251226 *
    12261227 * Above, the first default value is for non-hierarchical post types (like posts) and the second one is for hierarchical post types (like pages).
    12271228 *