mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-21 22:15:28 +00:00
See #5911. Hat tip: andy.
git-svn-id: http://svn.automattic.com/wordpress/trunk@7228 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
602266439f
commit
13e2adae6b
@ -823,23 +823,22 @@ function media_upload_type_form($type = 'file', $errors = null, $id = null) {
|
||||
<h3><?php _e('From Computer'); ?></h3>
|
||||
<?php media_upload_form( $errors ); ?>
|
||||
|
||||
<?php if ( $id && !is_wp_error($id) ) : ?>
|
||||
<script type="text/javascript">
|
||||
<!--
|
||||
jQuery(function($){
|
||||
var preloaded = $(".media-item.preloaded");
|
||||
if ( preloaded.length > 0 ) {
|
||||
preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');});
|
||||
updateMediaForm();
|
||||
}
|
||||
updateMediaForm();
|
||||
});
|
||||
-->
|
||||
</script>
|
||||
<?php if ( $id && !is_wp_error($id) ) : ?>
|
||||
<div id="media-items">
|
||||
<input type="submit" class="button savebutton" name="save" value="<?php _e('Save'); ?>" />
|
||||
<?php echo get_media_items( $id, $errors ); ?>
|
||||
<input type="submit" class="button savebutton" name="save" value="<?php _e('Save'); ?>" />
|
||||
</div>
|
||||
<input type="submit" class="button savebutton" name="save" value="<?php _e('Save all changes'); ?>" />
|
||||
|
||||
<?php elseif ( is_callable($callback) ) : ?>
|
||||
|
||||
@ -853,6 +852,7 @@ jQuery(function($){
|
||||
<?php echo call_user_func($callback); ?>
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" class="button savebutton" name="save" value="<?php _e('Save all changes'); ?>" />
|
||||
<?php
|
||||
endif;
|
||||
}
|
||||
@ -862,7 +862,7 @@ function media_upload_gallery_form($errors) {
|
||||
|
||||
$post_id = intval($_REQUEST['post_id']);
|
||||
|
||||
$form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php?type=media&tab=gallery&post_id=$post_id";
|
||||
$form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php?type={$GLOBALS['type']}&tab=gallery&post_id=$post_id";
|
||||
|
||||
?>
|
||||
|
||||
@ -885,10 +885,11 @@ jQuery(function($){
|
||||
<div id="media-items">
|
||||
<?php echo get_media_items($post_id, $errors); ?>
|
||||
</div>
|
||||
<p class="submit">
|
||||
<input type="submit" class="submit insert-gallery" name="insert-gallery" value="<?php _e('Insert gallery into post'); ?>" />
|
||||
</p>
|
||||
<input type="submit" class="button savebutton" name="save" value="<?php _e('Save all changes'); ?>" />
|
||||
<input type="submit" class="button insert-gallery" name="insert-gallery" value="<?php _e('Insert gallery into post'); ?>" />
|
||||
<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" />
|
||||
<input type="hidden" name="type" value="<?php echo $GLOBALS['type']; ?>" />
|
||||
<input type="hidden" name="tab" value="<?php echo $GLOBALS['tab']; ?>" />
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
@ -900,7 +901,7 @@ function media_upload_library_form($errors) {
|
||||
|
||||
$post_id = intval($_REQUEST['post_id']);
|
||||
|
||||
$form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php";
|
||||
$form_action_url = get_option('siteurl') . "/wp-admin/media-upload.php?type={$GLOBALS['type']}&tab=library&post_id=$post_id";
|
||||
|
||||
$_GET['paged'] = intval($_GET['paged']);
|
||||
if ( $_GET['paged'] < 1 )
|
||||
@ -931,9 +932,9 @@ function media_upload_library_form($errors) {
|
||||
$type_links = array();
|
||||
$_num_posts = (array) wp_count_attachments();
|
||||
$matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
|
||||
foreach ( $matches as $type => $reals )
|
||||
foreach ( $matches as $_type => $reals )
|
||||
foreach ( $reals as $real )
|
||||
$num_posts[$type] += $_num_posts[$real];
|
||||
$num_posts[$_type] += $_num_posts[$real];
|
||||
$class = empty($_GET['post_mime_type']) ? ' class="current"' : '';
|
||||
$type_links[] = "<li><a href='" . remove_query_arg(array('post_mime_type', 'paged', 'm')) . "'$class>".__('All Types')."</a>";
|
||||
foreach ( $post_mime_types as $mime_type => $label ) {
|
||||
@ -1026,6 +1027,7 @@ jQuery(function($){
|
||||
<div id="media-items">
|
||||
<?php echo get_media_items(null, $errors); ?>
|
||||
</div>
|
||||
<input type="submit" class="button savebutton" name="save" value="<?php _e('Save all changes'); ?>" />
|
||||
<input type="hidden" name="post_id" id="post_id" value="<?php echo $post_id; ?>" />
|
||||
</form>
|
||||
<?php
|
||||
|
@ -86,6 +86,12 @@ function updateMediaForm() {
|
||||
jQuery('.type-form .slidetoggle').siblings().addClass('hidden');
|
||||
}
|
||||
|
||||
// Only show Save buttons when there is at least one file.
|
||||
if ( jQuery('#media-items>*').not('.media-blank').length > 0 )
|
||||
jQuery('.savebutton').show();
|
||||
else
|
||||
jQuery('.savebutton').hide();
|
||||
|
||||
// Only show Gallery button when there are at least two files.
|
||||
if ( jQuery('#media-items>*').length > 1 )
|
||||
jQuery('.insert-gallery').show();
|
||||
|
Loading…
x
Reference in New Issue
Block a user