ericmann / WP-Publication-Archive

Allows users to upload, manage, search, and download publications, documents, and similar content (PDF, Power-Point, etc.) in WordPress.
http://wordpress.org/extend/plugins/wp-publication-archive/
27 stars 12 forks source link

Broken "View" links #38

Open alexmansfield opened 9 years ago

alexmansfield commented 9 years ago

I was having trouble getting the "View" links for the alternate publication files to work on a project I was working on for Rocket Lift. Clicking the "View" link simply loaded the publication page, with the addition of "/altview" to the URL. Eventually I tracked the issue down to this line of the lib/class.wp-publication-archive.php file:

if ( urldecode( $wp_query->query_vars['wppa_alt'] ) === $alt['description'] ) {

The query variable had been sanitized to remove upper case letters and spaces, but the document description still included both upper case letters and spaces. Obviously this if statement was false, so therefore no document URL was being generated.

Adding sanitize_title() to the $alt['description'] solved the problem for me:

if ( urldecode( $wp_query->query_vars['wppa_alt'] ) === sanitize_title( $alt['description'] ) ) {

I'm not sure if this is a bug in the plugin, or if there's something on my site that's preventing $alt['description'] from being sanitized properly. Any details you can provide about this issue would be appreciated. I can also generate a pull request if you'd like. Thanks!