How to do it...

  1. Navigate to the WordPress plugin directory of your development installation.
  2. Create a new directory called ch5-custom-file-uploader.
  3. Navigate to this directory and create a new text file called ch5-custom-file-uploader.php.
  4. Open the new file in a code editor and add an appropriate header at the top of the plugin file, naming the plugin Chapter 5 - Custom File Uploader.
  5. Add the following line of code to register a function that will be executed when WordPress is rendering the HTML code at the beginning of the post editor form:
add_action( 'post_edit_form_tag', 'ch5_cfu_form_add_enctype' ); 
  1. Add the following code section to provide an implementation for the ch5_cfu_form_add_enctype function:
function ch5_cfu_form_add_enctype() ...

Get WordPress Plugin Development Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.