WordPress.org

Make WordPress Core

Ticket #22400: 22400.media.php.diff

File 22400.media.php.diff, 5.0 KB (added by MikeHansenMe, 2 years ago)

media.php

  • wp-admin/includes/media.php

     
    10641064        $default_args = array( 'errors' => null, 'send' => $current_post_id ? post_type_supports( get_post_type( $current_post_id ), 'editor' ) : true, 'delete' => true, 'toggle' => true, 'show_title' => true ); 
    10651065        $args = wp_parse_args( $args, $default_args ); 
    10661066        $args = apply_filters( 'get_media_item_args', $args ); 
    1067         extract( $args, EXTR_SKIP ); 
    10681067 
    10691068        $toggle_on  = __( 'Show' ); 
    10701069        $toggle_off = __( 'Hide' ); 
     
    10831082        $type = array_shift( $keys ); 
    10841083        $type_html = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />"; 
    10851084 
    1086         $form_fields = get_attachment_fields_to_edit( $post, $errors ); 
     1085        $form_fields = get_attachment_fields_to_edit( $post, $args['errors'] ); 
    10871086 
    1088         if ( $toggle ) { 
    1089                 $class = empty( $errors ) ? 'startclosed' : 'startopen'; 
     1087        if ( $args['toggle'] ) { 
     1088                $class = empty( $args['errors'] ) ? 'startclosed' : 'startopen'; 
    10901089                $toggle_links = " 
    10911090        <a class='toggle describe-toggle-on' href='#'>$toggle_on</a> 
    10921091        <a class='toggle describe-toggle-off' href='#'>$toggle_off</a>"; 
     
    10961095        } 
    10971096 
    10981097        $display_title = ( !empty( $title ) ) ? $title : $filename; // $title shouldn't ever be empty, but just in case 
    1099         $display_title = $show_title ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60 ) . "</span></div>" : ''; 
     1098        $display_title = $args['show_title'] ? "<div class='filename new'><span class='title'>" . wp_html_excerpt( $display_title, 60 ) . "</span></div>" : ''; 
    11001099 
    11011100        $gallery = ( ( isset( $_REQUEST['tab'] ) && 'gallery' == $_REQUEST['tab'] ) || ( isset( $redir_tab ) && 'gallery' == $redir_tab ) ); 
    11021101        $order = ''; 
     
    11611160                'extra_rows' => array(), 
    11621161        ); 
    11631162 
    1164         if ( $send ) 
    1165                 $send = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); 
    1166         if ( $delete && current_user_can( 'delete_post', $attachment_id ) ) { 
     1163        if ( $args['send'] ) 
     1164                $args['send'] = get_submit_button( __( 'Insert into Post' ), 'button', "send[$attachment_id]", false ); 
     1165        if ( $args['delete'] && current_user_can( 'delete_post', $attachment_id ) ) { 
    11671166                if ( !EMPTY_TRASH_DAYS ) { 
    1168                         $delete = "<a href='" . wp_nonce_url( "post.php?action=delete&amp;post=$attachment_id", 'delete-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete-permanently'>" . __( 'Delete Permanently' ) . '</a>'; 
     1167                        $args['delete'] = "<a href='" . wp_nonce_url( "post.php?action=delete&amp;post=$attachment_id", 'delete-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete-permanently'>" . __( 'Delete Permanently' ) . '</a>'; 
    11691168                } elseif ( !MEDIA_TRASH ) { 
    1170                         $delete = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a> 
     1169                        $args['delete'] = "<a href='#' class='del-link' onclick=\"document.getElementById('del_attachment_$attachment_id').style.display='block';return false;\">" . __( 'Delete' ) . "</a> 
    11711170                         <div id='del_attachment_$attachment_id' class='del-attachment' style='display:none;'><p>" . sprintf( __( 'You are about to delete <strong>%s</strong>.' ), $filename ) . "</p> 
    11721171                         <a href='" . wp_nonce_url( "post.php?action=delete&amp;post=$attachment_id", 'delete-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='button'>" . __( 'Continue' ) . "</a> 
    11731172                         <a href='#' class='button' onclick=\"this.parentNode.style.display='none';return false;\">" . __( 'Cancel' ) . "</a> 
    11741173                         </div>"; 
    11751174                } else { 
    1176                         $delete = "<a href='" . wp_nonce_url( "post.php?action=trash&amp;post=$attachment_id", 'trash-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Move to Trash' ) . "</a> 
     1175                        $args['delete'] = "<a href='" . wp_nonce_url( "post.php?action=trash&amp;post=$attachment_id", 'trash-post_' . $attachment_id ) . "' id='del[$attachment_id]' class='delete'>" . __( 'Move to Trash' ) . "</a> 
    11771176                        <a href='" . wp_nonce_url( "post.php?action=untrash&amp;post=$attachment_id", 'untrash-post_' . $attachment_id ) . "' id='undo[$attachment_id]' class='undo hidden'>" . __( 'Undo' ) . "</a>"; 
    11781177                } 
    11791178        } else { 
    1180                 $delete = ''; 
     1179                $args['delete'] = ''; 
    11811180        } 
    11821181 
    11831182        $thumbnail = ''; 
     
    11921191                $thumbnail = "<a class='wp-post-thumbnail' id='wp-post-thumbnail-" . $attachment_id . "' href='#' onclick='WPSetAsThumbnail(\"$attachment_id\", \"$ajax_nonce\");return false;'>" . esc_html__( "Use as featured image" ) . "</a>"; 
    11931192        } 
    11941193 
    1195         if ( ( $send || $thumbnail || $delete ) && !isset( $form_fields['buttons'] ) ) 
    1196                 $form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>$send $thumbnail $delete</td></tr>\n" ); 
     1194        if ( ( $args['send'] || $thumbnail || $args['delete'] ) && !isset( $form_fields['buttons'] ) ) 
     1195                $form_fields['buttons'] = array( 'tr' => "\t\t<tr class='submit'><td></td><td class='savesend'>". $args['send'] . $thumbnail . $args['delete'] ."</td></tr>\n" ); 
    11971196 
    11981197        $hidden_fields = array(); 
    11991198