WordPress.org

Make WordPress Core

Ticket #9393: 9393-media-fixes.2.diff

File 9393-media-fixes.2.diff, 4.1 KB (added by sivel, 9 years ago)

Update to 9393-media-fixes.diff. More notice fixes found through the media area.

  • wp-admin/media.php

     
    9494
    9595<p class="submit">
    9696<input type="submit" class="button-primary" name="save" value="<?php _e('Update Media'); ?>" />
    97 <input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" />
     97<input type="hidden" name="post_id" id="post_id" value="<?php echo isset($post_id) ? $post_id : ''; ?>" />
    9898<input type="hidden" name="attachment_id" id="attachment_id" value="<?php echo $att_id; ?>" />
    9999<input type="hidden" name="action" value="editattachment" />
    100100<?php wp_original_referer_field(true, 'previous'); ?>
  • wp-admin/includes/media.php

     
    397397                if ( isset($post['errors']) ) {
    398398                        $errors[$attachment_id] = $post['errors'];
    399399                        unset($post['errors']);
     400                } else {
     401                        $errors = array();
    400402                }
    401403
    402404                if ( $post != $_post )
     
    988990                        'label'      => __('File URL'),
    989991                        'input'      => 'html',
    990992                        'html'       => "<input type='text' class='urlfield' readonly='readonly' name='attachments[$post->ID][url]' value='" . attribute_escape($image_url) . "' /><br />",
    991                         'value'      => $edit_post->post_url,
     993                        'value'      => isset($edit_post->post_url) ? $edit_post->post_url : '',
    992994                        'helps'      => __('Location of the uploaded file.'),
    993995                )
    994996        );
     
    12231225        foreach ( $hidden_fields as $name => $value )
    12241226                $item .= "\t<input type='hidden' name='$name' id='$name' value='" . attribute_escape( $value ) . "' />\n";
    12251227
    1226         if ( $post->post_parent < 1 && (int) $_REQUEST['post_id'] ) {
     1228        if ( $post->post_parent < 1 &&  isset($_REQUEST['post_id']) ) {
    12271229                $parent = (int) $_REQUEST['post_id'];
    12281230                $parent_name = "attachments[$attachment_id][post_parent]";
    12291231
     
    17011703<input type="hidden" name="type" value="<?php echo attribute_escape( $type ); ?>" />
    17021704<input type="hidden" name="tab" value="<?php echo attribute_escape( $tab ); ?>" />
    17031705<input type="hidden" name="post_id" value="<?php echo (int) $post_id; ?>" />
    1704 <input type="hidden" name="post_mime_type" value="<?php echo attribute_escape( $_GET['post_mime_type'] ); ?>" />
     1706<input type="hidden" name="post_mime_type" value="<?php echo isset( $_GET['post_mime_type'] ) ? attribute_escape( $_GET['post_mime_type'] ) : ''; ?>" />
    17051707
    17061708<p id="media-search" class="search-box">
    17071709        <label class="hidden" for="media-search-input"><?php _e('Search Media');?>:</label>
     
    17161718$matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
    17171719foreach ( $matches as $_type => $reals )
    17181720        foreach ( $reals as $real )
    1719                 $num_posts[$_type] += $_num_posts[$real];
     1721                if ( isset($num_posts[$_type]) )
     1722                        $num_posts[$_type] += $_num_posts[$real];
     1723                else
     1724                        $num_posts[$_type] = $_num_posts[$real];
    17201725// If available type specified by media button clicked, filter by that type
    17211726if ( empty($_GET['post_mime_type']) && !empty($num_posts[$type]) ) {
    17221727        $_GET['post_mime_type'] = $type;
     
    17241729}
    17251730if ( empty($_GET['post_mime_type']) || $_GET['post_mime_type'] == 'all' )
    17261731        $class = ' class="current"';
     1732else
     1733        $class = '';
    17271734$type_links[] = "<li><a href='" . clean_url(add_query_arg(array('post_mime_type'=>'all', 'paged'=>false, 'm'=>false))) . "'$class>".__('All Types')."</a>";
    17281735foreach ( $post_mime_types as $mime_type => $label ) {
    17291736        $class = '';
     
    17311738        if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
    17321739                continue;
    17331740
    1734         if ( wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
     1741        if ( isset($_GET['post_mime_type']) && wp_match_mime_types($mime_type, $_GET['post_mime_type']) )
    17351742                $class = ' class="current"';
    17361743
    17371744        $type_links[] = "<li><a href='" . clean_url(add_query_arg(array('post_mime_type'=>$mime_type, 'paged'=>false))) . "'$class>" . sprintf(_n($label[2][0], $label[2][1], $num_posts[$mime_type]), "<span id='$mime_type-counter'>" . number_format_i18n( $num_posts[$mime_type] ) . '</span>') . '</a>';