WordPress.org

Make WordPress Core

Ticket #5911: 5911-26.diff

File 5911-26.diff, 4.2 KB (added by andy, 7 years ago)

add Save button and fix tab+type breakage

  • wp-includes/js/swfupload/handlers.js

     
    8686                jQuery('.type-form .slidetoggle').siblings().addClass('hidden'); 
    8787        } 
    8888 
     89        // Only show Save buttons when there is at least one file. 
     90        if ( jQuery('#media-items>*').not('.media-blank').length > 0 ) 
     91                jQuery('.savebutton').show(); 
     92        else 
     93                jQuery('.savebutton').hide(); 
     94 
    8995        // Only show Gallery button when there are at least two files. 
    9096        if ( jQuery('#media-items>*').length > 1 ) 
    9197                jQuery('.insert-gallery').show(); 
  • wp-admin/includes/media.php

     
    823823<h3><?php _e('From Computer'); ?></h3> 
    824824<?php media_upload_form( $errors ); ?> 
    825825 
    826 <?php if ( $id && !is_wp_error($id) ) : ?> 
    827826<script type="text/javascript"> 
    828827<!-- 
    829828jQuery(function($){ 
    830829        var preloaded = $(".media-item.preloaded"); 
    831830        if ( preloaded.length > 0 ) { 
    832831                preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); 
    833                 updateMediaForm(); 
    834832        } 
     833        updateMediaForm(); 
    835834}); 
    836835--> 
    837836</script> 
     837<?php if ( $id && !is_wp_error($id) ) : ?> 
    838838<div id="media-items"> 
    839 <input type="submit" class="button savebutton" name="save" value="<?php _e('Save'); ?>" /> 
    840839<?php echo get_media_items( $id, $errors ); ?> 
    841 <input type="submit" class="button savebutton" name="save" value="<?php _e('Save'); ?>" /> 
    842840</div> 
     841<input type="submit" class="button savebutton" name="save" value="<?php _e('Save all changes'); ?>" /> 
    843842 
    844843<?php elseif ( is_callable($callback) ) : ?> 
    845844 
     
    853852<?php echo call_user_func($callback); ?> 
    854853</div> 
    855854</div> 
     855<input type="submit" class="button savebutton" name="save" value="<?php _e('Save all changes'); ?>" /> 
    856856<?php 
    857857        endif; 
    858858} 
     
    862862 
    863863        $post_id = intval($_REQUEST['post_id']); 
    864864 
    865         $form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php?type=media&tab=gallery&post_id=$post_id"; 
     865        $form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php?type={$GLOBALS['type']}&tab=gallery&post_id=$post_id"; 
    866866 
    867867?> 
    868868 
     
    885885<div id="media-items"> 
    886886<?php echo get_media_items($post_id, $errors); ?> 
    887887</div> 
    888 <p class="submit"> 
    889         <input type="submit" class="submit insert-gallery" name="insert-gallery" value="<?php _e('Insert gallery into post'); ?>" /> 
    890 </p> 
     888<input type="submit" class="button savebutton" name="save" value="<?php _e('Save all changes'); ?>" /> 
     889<input type="submit" class="button insert-gallery" name="insert-gallery" value="<?php _e('Insert gallery into post'); ?>" /> 
    891890<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" /> 
     891<input type="hidden" name="type" value="<?php echo $GLOBALS['type']; ?>" /> 
     892<input type="hidden" name="tab" value="<?php echo $GLOBALS['tab']; ?>" /> 
    892893</form> 
    893894<?php 
    894895} 
     
    900901 
    901902        $post_id = intval($_REQUEST['post_id']); 
    902903 
    903         $form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php"; 
     904        $form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php?type={$GLOBALS['type']}&tab=library&post_id=$post_id"; 
    904905 
    905906        $_GET['paged'] = intval($_GET['paged']); 
    906907        if ( $_GET['paged'] < 1 ) 
     
    931932$type_links = array(); 
    932933$_num_posts = (array) wp_count_attachments(); 
    933934$matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts)); 
    934 foreach ( $matches as $type => $reals ) 
     935foreach ( $matches as $_type => $reals ) 
    935936        foreach ( $reals as $real ) 
    936                 $num_posts[$type] += $_num_posts[$real]; 
     937                $num_posts[$_type] += $_num_posts[$real]; 
    937938$class = empty($_GET['post_mime_type']) ? ' class="current"' : ''; 
    938939$type_links[] = "<li><a href='" . remove_query_arg(array('post_mime_type', 'paged', 'm')) . "'$class>".__('All Types')."</a>"; 
    939940foreach ( $post_mime_types as $mime_type => $label ) { 
     
    10261027<div id="media-items"> 
    10271028<?php echo get_media_items(null, $errors); ?> 
    10281029</div> 
     1030<input type="submit" class="button savebutton" name="save" value="<?php _e('Save all changes'); ?>" /> 
    10291031<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" /> 
    10301032</form> 
    10311033<?php