H5P Plugin in WordPress Giving You Crazy Code on Download Attempt?

Crazy looking code that's generated when trying to download the h5p file.

We ran into this yesterday and it led to all kinds of other nonsense that wasn’t the issue.

What was happening was that when you tried to Reuse>Download an existing H5P file it wouldn’t download it but would print the nonsense that is in the image above.

We ended up going down all kinds of rabbit holes because we were also having an issue with permission and updating H5P libraries. Those issues weren’t related at all but did eat up some serious time. Those things tend to snowball and I end up adding a wheeluser in WHM so I can SSH into a sub-install and mess with folder/file permissions via terminal.1

Anyway, what interests me in some ways is that I finally gave up and posted for help on Twitter at 8:07 this morning. I hate to ask people for help if I haven’t worked pretty hard at solving something.

By 9:00AM my brain finally kicked loose where I’d seen that weird code-like stuff before . . . expletive-string2 mime types. A bit of Stackoverflow later and I was able to add the following to the .htaccess file and fix the issue by 9:10 or so. Maybe finally giving in releases some mental blocks because this happens fairly often.

AddType application/zip .h5p

<FilesMatch "\.(?i:h5p)$">
  ForceType application/zip
  Header set Content-Disposition attachment
</FilesMatch>

1 It sounds fancy and I hate it. Not how I want to spend my time. Anyone can do it but the vocabulary alone is such a hassle and the result is . . . basic functionality for a folder/file.

2 Not an actual technical term but it should be.