adding a button to the media uploader

When i needed to do something similar i used the admin_print_scripts-media-upload-popup hook to add my own js/Jquery code to insert a button and handled it’s click event with ajax. something like this: add_action(‘admin_print_scripts-media-upload-popup’,’add_my_media_button’); function add_my_media_button(){ ?> <script> jQuery(document).ready(function() { //loop over all attachments jQuery(“.savesend”).each(function(i,v){ if (jQuery(this).next().attr(‘id’) != “”){ //get attachment id var att_id = jQuery(this).next().attr(‘id’); … Read more

Get all media files for current author

Media are just posts – so just query posts. This is untested: $args = array( ‘author’ => $author_id, ‘post_type’ => ‘attachment’, ); $query = new WP_Query( $args ); I’m not sure if you want currently logged in user or the author of the post currently in the loop – either way you can set $author_id … Read more

A link (not in the post) to download a specific PDF file

The pdf is itself an attachment post so in wordpress template hierarchy we can create a template named pdf.php Then you can write following code in it which force download the pdf file. <?php if (have_posts()) : the_post(); $pdf_title = $post->post_title; $pdf_src = get_attached_file($post->ID ); $bytes = filesize( $pdf_src ); header(“Pragma: public”); // required header(“Expires: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)