2

I have added new mime types with the 'post_mime_types' filter eg. PDF, doc, mp3 etc...

Filtering by custom mime type on the upload.php page in media grid view works as expected but in list view it doesn't.

The problem is that WordPress passes the mime types through urlencode as it builds the html (wp-admin/includes/class-wp-media-list-table.php:73) and so

post_mime_type:application/pdf 

becomes

post_mime_type:application%2Fpdf

for the drop down value.

When the filter form is submitted the encoded '/' is ignored and doesn't filter properly.

Changing the '%2F' back to a '/' with JS would work but I'd like to know if anyone has a solution to decode the string before its processed and the page reloaded.

  • The problem is that "/" character is double enconded. First it is encoded for the dropdown value, so "/" becomes "%2F". Then it is encoded again and "%2F" becomes "%252F" in the URL request. "%252F" decodes to "%/", no to "/", and that is because the filter fails. The "/" character should be sent as "%2F". I'm now investigating a solution. – cybmeta Oct 27 '14 at 11:58
  • thanks for looking into it @cymeta. I added a bug ticket to the core trac here core.trac.wordpress.org/ticket/30123#ticket – chris Oct 27 '14 at 16:11
  • A similar question was posted here. – birgire Oct 27 '14 at 17:03
1

Here's a workaround you can put in a plugin or your theme's functions.php file. So far no problems.

/*
* Workaround Bug 30123
* Affects WP 4.0+, should be fixed in WP 4.1
* https://core.trac.wordpress.org/ticket/30123
*/
function bugfix30123__action__admin_init() {
    if ( isset( $_GET['attachment-filter'] ) && is_string( $_GET['attachment-filter'] ) ) {
        $_GET['attachment-filter'] = $_REQUEST['attachment-filter'] = str_replace( '%2F', '/', $_GET['attachment-filter'] );
    }
}
add_action( 'admin_init', 'bugfix30123__action__admin_init' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.