• Resolved hjerem

    (@hjerem)


    Hi again !
    As I said, here is a post about problems I encountered because of the WordPress function wptexturize (documentation).

    When I started using plugin, all paths and links were broken. Here is the complete list of attributes available in templates which were broken:

    • file_url
    • base_file
    • file
    • path

    To make things work, I had to modify the plugin a bit.
    The culprit was wptexturize that makes some text transformations which produces wrong path, url or links.
    In class-mla-shortcode-support.php file I replaced this (line 1007):
    $item_values['file_url'] = wptexturize( $attachment->guid );

    By this:
    $item_values['file_url'] = $attachment->guid;

    I also replaced this (line 1060):

    $item_values['base_file'] = wptexturize( $base_file );
    $item_values['file'] = wptexturize( $base_file );

    By this:

    $item_values['base_file'] = $base_file;
    $item_values['file'] = $base_file;

    And this (line 1068):

    $item_values['base_file'] = wptexturize( $base_file );
    $item_values['path'] = wptexturize( substr( $base_file, 0, $last_slash + 1 ) );
    $item_values['file'] = wptexturize( $file_name );

    By this:

    $item_values['base_file'] = $base_file;
    $item_values['path'] = substr( $base_file, 0, $last_slash + 1 );
    $item_values['file'] = $file_name;

    Now everything is working fine. Why did you used wptexturize on these variables ?

    • This topic was modified 8 years ago by hjerem.
    • This topic was modified 8 years ago by hjerem.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author David Lingren

    (@dglingren)

    Thanks for your report, the detective work you’ve done and for posting the details of the modifications you’ve made.

    I looked back through the MLA archives and the use of wptexturize() goes back to MLA v0.80 released in November 2012. Obviously, I have learned a lot about WordPress since then, but no one has ever noticed this problem until your report.

    The WordPress [gallery] shortcode uses wptexturize() to compose caption values, and I suspect I just copied the practice when I first developed [mla_gallery]. It makes sense for “text” values like Title, Excerpt/Caption and Description but not for the variables you identified and fixed.

    I will go through the code, remove the function where it should not apply and incorporate the changes in my next version. Thanks for identifying this MLA defect.

    Thread Starter hjerem

    (@hjerem)

    no one has ever noticed this problem until your report

    This is strange than no one has ever got this problem because it breaks almost all links, paths and file name for me.

    You’re welcome ! That’s the least I can do for your continued support.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Use of wptexturize produces broken links and paths’ is closed to new replies.