[wp-trac] Re: [WordPress Trac] #8960: Post edit form is missing enctype field

WordPress Trac wp-trac at lists.automattic.com
Mon Jan 26 14:47:06 GMT 2009


#8960: Post edit form is missing enctype field
----------------------------+-----------------------------------------------
 Reporter:  chrisnorthwood  |        Owner:  anonymous
     Type:  enhancement     |       Status:  new      
 Priority:  normal          |    Milestone:  2.8      
Component:  Administration  |      Version:  2.7      
 Severity:  minor           |   Resolution:           
 Keywords:  has-patch       |  
----------------------------+-----------------------------------------------
Comment (by Denis-de-Bernardy):

 Personally, I use:


 {{{
 if ( !function_exists('ob_multipart_entry_form') ) :
 #
 # ob_multipart_entry_form_callback()
 #

 function ob_multipart_entry_form_callback($buffer)
 {
         $buffer = str_replace(
                 '<form name="post"',
                 '<form enctype="multipart/form-data" name="post"',
                 $buffer
                 );

         return $buffer;
 } # ob_multipart_entry_form_callback()


 #
 # ob_multipart_entry_form()
 #

 function ob_multipart_entry_form()
 {
         if ( $GLOBALS['editing'] )
         {
                 ob_start('ob_multipart_entry_form_callback');
         }
 } # ob_multipart_entry_form()

 add_action('admin_head', 'ob_multipart_entry_form');


 #
 # add_file_max_size()
 #

 function add_file_max_size()
 {
         $bytes = apply_filters( 'import_upload_size_limit',
 wp_max_upload_size() );

         echo  "\n" . '<input type="hidden" name="MAX_FILE_SIZE" value="' .
 $bytes .'" />' . "\n";
 }

 add_action('edit_form_advanced', 'add_file_max_size');
 add_action('edit_page_form', 'add_file_max_size');
 endif;
 }}}

 (that being said, I fully agree that this form tag should be pluginable.)

-- 
Ticket URL: <http://trac.wordpress.org/ticket/8960#comment:4>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list