[wp-trac] [WordPress Trac] #50695: Make media_sideload_image extension list filterable

WordPress Trac noreply at wordpress.org
Thu Oct 1 20:25:49 UTC 2020


#50695: Make media_sideload_image extension list filterable
-------------------------------------------------+-------------------------
 Reporter:  paulschreiber                        |       Owner:  (none)
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  5.6
Component:  Media                                |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch needs-dev-note needs-      |     Focuses:
  unit-tests                                     |
-------------------------------------------------+-------------------------

Comment (by paulschreiber):

 How about this to clean up the list?

 {{{#!php
 <?php
 $allowed_extensions = array_filter(
     array_map(
         function( $item ) {
             return preg_replace( '/[^A-Z0-9]/i', '', $item );
         },
         $allowed_extensions
     )
 );

 if ( ! $allowed_extensions ) {
     return new WP_Error( 'image_sideload_failed', __( 'Invalid extension
 list.' ) );
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50695#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list