Make WordPress Core

Changeset 22459


Ignore:
Timestamp:
11/07/2012 11:54:03 PM (12 years ago)
Author:
nacin
Message:

Forms with the class .wp-upload-form will now have their submit button disabled until a file is selected. props kovshenin, helenyhou, lessbloat, SergeyBiryukov, tommcfarlin. fixes #20855.

Location:
trunk/wp-admin
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/custom-background.php

    r22030 r22459  
    255255<tr valign="top">
    256256<th scope="row"><?php _e('Select Image'); ?></th>
    257 <td><form enctype="multipart/form-data" id="upload-form" method="post" action="">
     257<td><form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post" action="">
    258258    <p>
    259259        <label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br />
  • trunk/wp-admin/custom-header.php

    r22030 r22459  
    526526    }
    527527    ?></p>
    528     <form enctype="multipart/form-data" id="upload-form" method="post" action="<?php echo esc_attr( add_query_arg( 'step', 2 ) ) ?>">
     528    <form enctype="multipart/form-data" id="upload-form" class="wp-upload-form" method="post" action="<?php echo esc_attr( add_query_arg( 'step', 2 ) ) ?>">
    529529    <p>
    530530        <label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br />
  • trunk/wp-admin/includes/plugin-install.php

    r22026 r22459  
    143143function install_plugins_upload( $page = 1 ) {
    144144?>
    145     <h4><?php _e('Install a plugin in .zip format') ?></h4>
    146     <p class="install-help"><?php _e('If you have a plugin in a .zip format, you may install it by uploading it here.') ?></p>
    147     <form method="post" enctype="multipart/form-data" action="<?php echo self_admin_url('update.php?action=upload-plugin') ?>">
    148         <?php wp_nonce_field( 'plugin-upload') ?>
     145    <h4><?php _e('Install a plugin in .zip format'); ?></h4>
     146    <p class="install-help"><?php _e('If you have a plugin in a .zip format, you may install it by uploading it here.'); ?></p>
     147    <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-plugin'); ?>">
     148        <?php wp_nonce_field( 'plugin-upload'); ?>
    149149        <label class="screen-reader-text" for="pluginzip"><?php _e('Plugin zip file'); ?></label>
    150150        <input type="file" id="pluginzip" name="pluginzip" />
    151         <input type="submit" class="button" value="<?php esc_attr_e('Install Now') ?>" />
     151        <?php submit_button( __( 'Install Now' ), 'button', 'install-plugin-submit', false ); ?>
    152152    </form>
    153153<?php
  • trunk/wp-admin/includes/template.php

    r22396 r22459  
    788788    else :
    789789?>
    790 <form enctype="multipart/form-data" id="import-upload-form" method="post" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>">
     790<form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_attr(wp_nonce_url($action, 'import-upload')); ?>">
    791791<p>
    792792<label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>)
  • trunk/wp-admin/includes/theme-install.php

    r21323 r22459  
    135135function install_themes_upload($page = 1) {
    136136?>
    137 <h4><?php _e('Install a theme in .zip format') ?></h4>
    138 <p class="install-help"><?php _e('If you have a theme in a .zip format, you may install it by uploading it here.') ?></p>
    139 <form method="post" enctype="multipart/form-data" action="<?php echo self_admin_url('update.php?action=upload-theme') ?>">
    140     <?php wp_nonce_field( 'theme-upload') ?>
     137<h4><?php _e('Install a theme in .zip format'); ?></h4>
     138<p class="install-help"><?php _e('If you have a theme in a .zip format, you may install it by uploading it here.'); ?></p>
     139<form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-theme'); ?>">
     140    <?php wp_nonce_field( 'theme-upload'); ?>
    141141    <input type="file" name="themezip" />
    142142    <?php submit_button( __( 'Install Now' ), 'button', 'install-theme-submit', false ); ?>
  • trunk/wp-admin/js/common.js

    r22268 r22459  
    250250            interval: 90
    251251        });
    252        
     252
    253253        menu.on('focus.adminmenu', '.wp-submenu a', function(e){
    254254            $(e.target).closest('li.menu-top').addClass('opensub');
     
    389389            e.target.scrollIntoView(false);
    390390    });
     391
     392    // Disable upload buttons until files are selected
     393    (function(){
     394        var button, input, form = $('form.wp-upload-form');
     395        if ( ! form.length )
     396            return;
     397        button = form.find('input[type="submit"]');
     398        input = form.find('input[type="file"]');
     399        function toggleUploadButton() {
     400            button.prop('disabled', '' === input.val());
     401        }
     402        toggleUploadButton();
     403        input.on('change', toggleUploadButton);
     404    })();
    391405});
    392406
Note: See TracChangeset for help on using the changeset viewer.