Adding Replace link to Uploaded to this post screen
-
Hi,
I am trying to Add the replace link to the attachments uploaded to this post screen when viewing attachments.
I’ve been playing around with this, which adds the text on the screen but it generates the incorrect noonce and I am unable to redirect successfully to the media replace screen. Any idea what I am doing wrong?
add_action( 'init', 'hhs_init' ); function hhs_init() { register_taxonomy_for_object_type( 'category', 'attachment' ); } add_filter( 'attachment_fields_to_edit', 'hhs_attachment_fields_to_edit', 10, 2 ); function hhs_attachment_fields_to_edit( $fields, $post ) { if ( isset( $fields['category'] ) ) $fields['category']['show_in_modal'] = false; $url = admin_url( "upload.php?page=enable-media-replace/enable-media-replace.php&noheader=true&action=media_replace_upload&attachment_id=".$post->ID); $action = "media_replace_upload"; $formurl = wp_nonce_url( $url, $action ); if (FORCE_SSL_ADMIN) { $formurl = str_replace("http:", "https:", $formurl); } $fields['test-media-item'] = array( 'label' => 'Upload a New Version of this document, the file name of the document being uploaded will be modified to that of the original document file name.', 'input' => 'html', //'html' => '<br/>'.add_media_action( '', $post->ID), 'html' => '<a href="'.$formurl.'">Replace / Upload</a><br />', 'show_in_edit' => false, ); return $fields; }
The topic ‘Adding Replace link to Uploaded to this post screen’ is closed to new replies.