[wp-trac] [WordPress Trac] #47049: Unzip_file causing Media file upload error

WordPress Trac noreply at wordpress.org
Sat Apr 27 13:42:35 UTC 2019


#47049: Unzip_file causing Media file upload error
---------------------------+------------------------------
 Reporter:  troytempleman  |       Owner:  (none)
     Type:  defect (bug)   |      Status:  new
 Priority:  normal         |   Milestone:  Awaiting Review
Component:  Upload         |     Version:  5.1.1
 Severity:  normal         |  Resolution:
 Keywords:                 |     Focuses:
---------------------------+------------------------------

Comment (by troytempleman):

 Hi Mehrshad,

 Thanks for your help. Ideally I want it in the Customizer, after uploading
 a zip file of icon fonts. For example, in the Twenty Nineteen theme, in
 the inc/customizer.php file, I have the following control added to the
 twentynineteen_customize_register function:
 {{{
 $wp_customize->add_section( 'icon_fonts' , array(
     'title' => __( 'Icon Fonts', 'icon-fonts' ),
 ) );

 $wp_customize->add_setting('icon_fonts', array(
     'default' => '',
 ));

 $wp_customize->add_control( new WP_Customize_Upload_Control($wp_customize,
 'icon_fonts', array(
     'label' => __('Icon Fonts', 'twentynineteen'),
     'section' => 'icon_fonts',
 )));
 }}}

 This Customizer control can upload a zip file to the current uploads
 folder but when the unzip_file function above is added to functions.php,
 I'm unable to upload a zip file, or any other file to the Media library.

 The function does work properly by unzipping the file if its already in
 the folder. The problem is not being able to upload when the function is
 being used.

 Is there a better way of using it that will allow media uploads? I have
 tried customize_save and customize_save_after hooks, but then I get the
 following error when I click Publish in the Customizer:
 {{{
 Looks like something’s gone wrong. Wait a couple seconds, and then try
 again.
 }}}

 Not sure how to use your suggestions for this.

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


More information about the wp-trac mailing list