Creating the attachments addon

As usual, we have to start by creating a plugin directory with a main plugin file, and inserting the header comments to define it as a plugin. We are not going to repeat the code in this section. You can find a directory and files for attachments addon inside the wpquick-attachments-addon directory in source codes. We are going to start the development by restricting the PDF files to users with a subscriber role. Let's implement the wpqpa_post_attachment_list_item filter we added in the previous section:

add_filter( 'wpqpa_post_attachment_list_item', 'wpqaa_post_attachment_list_item' , 10 ,2 );function wpqaa_post_attachment_list_item( $display, $file_data ){ $upload_dir = wp_upload_dir(); $file_dir = $upload_dir['basedir'] ...

Get WordPress Development Quick Start Guide 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.