[wp-trac] [WordPress Trac] #34064: Filter the file type error message

WordPress Trac noreply at wordpress.org
Mon Sep 28 20:42:58 UTC 2015


#34064: Filter the file type error message
----------------------------+-----------------------------
 Reporter:  kraftbj         |      Owner:
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Filesystem API  |    Version:
 Severity:  normal          |   Keywords:
  Focuses:                  |
----------------------------+-----------------------------
 When uploading a file type that is not permitted, the error `Sorry, this
 file type is not permitted for security reasons.` is returned.

 By adding a filter, a plugin/site admin can add a customized message.

 An example use case: A plugin that allows a front-end post submission
 system that allow file add-ons. By filtering the response, the
 author/admin can give more detailed specifications including allowable
 file types, if desired.

 Example function of the filter in psudocode:

 {{{
 add_filter( 'upload_filetype_error', 'bk_test_error' );
 function bk_test_error() {
         $allowed = get_allowed_mime_types();
         $message = "This type of file is not allowed! Please use one of
 the following: " . implode( ', ', array_keys( $allowed ) );
         return $message;
 }
 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34064>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list