WordPress.org

Make WordPress Core

Changeset 13577


Ignore:
Timestamp:
03/03/2010 07:53:39 PM (12 years ago)
Author:
nacin
Message:

Support for extra POST fields in WP_Filesystem. props dd32. see #12094

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/file.php

    r13290 r13577  
    808808 * @param boolean $error if the current request has failed to connect
    809809 * @param string $context The directory which is needed access to, The write-test will be performed on  this directory by get_filesystem_method()
     810 * @param string $extra_fields Extra POST fields which should be checked for to be included in the post.
    810811 * @return boolean False on failure. True on success.
    811812 */
    812 function request_filesystem_credentials($form_post, $type = '', $error = false, $context = false) {
    813     $req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error, $context);
     813function request_filesystem_credentials($form_post, $type = '', $error = false, $context = false, $extra_fields = null) {
     814    $req_cred = apply_filters( 'request_filesystem_credentials', '', $form_post, $type, $error, $context, $extra_fields );
    814815    if ( '' !== $req_cred )
    815816        return $req_cred;
     
    820821    if ( 'direct' == $type )
    821822        return true;
     823
     824    if ( is_null( $extra_fields ) )
     825        $extra_fields = array( 'version', 'locale' );
    822826
    823827    $credentials = get_option('ftp_credentials', array( 'hostname' => '', 'username' => ''));
     
    955959</table>
    956960
    957 <?php if ( isset( $_POST['version'] ) ) : ?>
    958 <input type="hidden" name="version" value="<?php echo esc_attr(stripslashes($_POST['version'])) ?>" />
    959 <?php endif; ?>
    960 <?php if ( isset( $_POST['locale'] ) ) : ?>
    961 <input type="hidden" name="locale" value="<?php echo esc_attr(stripslashes($_POST['locale'])) ?>" />
    962 <?php endif; ?>
     961<?php
     962foreach ( (array) $extra_fields as $field ) {
     963    if ( isset( $_POST[ $field ] ) )
     964        echo '<input type="hidden" name="' . esc_attr( $field ) . '" value="' . esc_attr( stripslashes( $_POST[ $field ] ) ) . '" />';
     965}
     966?>
    963967<p class="submit">
    964968<input id="upgrade" name="upgrade" type="submit" class="button" value="<?php esc_attr_e('Proceed'); ?>" />
Note: See TracChangeset for help on using the changeset viewer.