wp_import_upload_form

Outputs the form used by the importers to accept the data to be imported.

Description

wp_import_upload_form( (string) $action ); 

Parameters (1)

0. $action (string)
The action attribute for the form.

Usage

  1. if ( !function_exists( 'wp_import_upload_form' ) ) { 
  2. require_once ABSPATH . '/wp-admin/includes/template.php'; 
  3.  
  4. // The action attribute for the form. 
  5. $action = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_import_upload_form($action); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-admin/includes/template.php  
  1. function wp_import_upload_form( $action ) { 
  2.  
  3. /** 
  4. * Filters the maximum allowed upload size for import files. 
  5. * @since 2.3.0 
  6. * @see wp_max_upload_size() 
  7. * @param int $max_upload_size Allowed upload size. Default 1 MB. 
  8. */ 
  9. $size = size_format( $bytes ); 
  10. $upload_dir = wp_upload_dir(); 
  11. if ( ! empty( $upload_dir[error] ) ) : 
  12. ?><div class="error"><p><?php _e('Before you can upload your import file, you will need to fix the followingerror'); ?></p> 
  13. <p><strong><?php echo $upload_dir[error]; ?></strong></p></div><?php 
  14. else : 
  15. ?> 
  16. <form enctype="multipart/form-data" id="import-upload-form" method="post" class="wp-upload-form" action="<?php echo esc_url( wp_nonce_url( $action, 'import-upload' ) ); ?>"> 
  17. <p> 
  18. <label for="upload"><?php _e( 'Choose a file from your computer:' ); ?></label> (<?php printf( __('Maximum size: %s' ), $size ); ?>) 
  19. <input type="file" id="upload" name="import" size="25" /> 
  20. <input type="hidden" name="action" value="save" /> 
  21. <input type="hidden" name="max_file_size" value="<?php echo $bytes; ?>" /> 
  22. </p> 
  23. <?php submit_button( __('Upload file and import'), 'primary' ); ?> 
  24. </form> 
  25. <?php 
  26. endif;