WordPress.org

Ready to get started?Download WordPress

Forums

Download Shortcode
[resolved] Could you please help me... (9 posts)

  1. karpediem
    Member
    Posted 1 year ago #

    Sorry for my bad english...

    I unfortunately can't find the right way to use this plugin correctly ;-(

    My files are stored in wp-content/uploads/dowload/*.*
    So I change the supported directory in functions.php like this :

    function change_download_files_directory() {
        return 'uploads/download/';
    }
    add_filter( 'fds_download_files_directory', 'change_download_files_directory' );

    Is it the right way ?

    My shortcode 1

    [download label="logo (.ai)"]http://rainbowflash.org/uploads/download/rbw_logo.ai[/download]

    It display this :

    <a href="http://rainbowflash.org/download/http://rainbowflash.org/uploads/download/rbw_logo.ai" class="">logo (.ai)</a>

    If I choose this way :
    Shortcode 2

    [download label="logo (.ai)"]rbw_logo.ai[/download]

    It display this :

    <a href="http://rainbowflash.org/download/http://rbw_logo.ai" class="">logo (.ai)</a>

    If I choose this other way :
    Shortcode 3

    [download label="logo (.ai)"]/rbw_logo.ai[/download]

    display this :

    <a href="http://rainbowflash.org/download//rbw_logo.ai" class="">logo (.ai)</a>

    All those options are wrong...

    Thank you for your help

    http://wordpress.org/extend/plugins/download-shortcode/

  2. Drew Jaynes (DrewAPicture)
    Volunteer Moderator
    Plugin Author

    Posted 1 year ago #

    Hi karpediem,

    Try removing the trailing slash from your new directory path in the filter. Change 'uploads/download/' to 'uploads/download'. Like this:

    function change_download_files_directory() {
        return 'uploads/download';
    }
    add_filter( 'fds_download_files_directory', 'change_download_files_directory' );

    The first of your three examples is the only correct way. You can't specify a relative path in the shortcode, it has to be the full URL like the first one:

    // Correct format
    [download label="logo (.ai)"]http://rainbowflash.org/uploads/download/rbw_logo.ai[/download]
    
    // Incorrect format (relative path not supported)
    [download label="logo (.ai)"]rbw_logo.ai[/download]
    
    // Incorrect format (relative path not supported)
    [download label="logo (.ai)"]/rbw_logo.ai[/download]

    Also:

    Since you're supplying download links for an unsupported file extension (ai), you may need to modify the mime types list in /wp-content/force-download.php/ if files still aren't downloading correctly.

    Not quite sure what the correct mime type is for Adobe Illustrator files, a quick Google search suggested 'application/illustrator', or 'application/pdf'.

    You'd want to open /wp-content/force-download.php/, and find this line:

    case "jpg": $ctype="image/jpg"; break;

    paste this on the next line:

    case "ai": $ctype="application/illustrator"; break;
  3. karpediem
    Member
    Posted 1 year ago #

    Hi and thank you for having answered very fast !

    I made the modifications which you indicated me :
    - functions.php => return 'uploads/download';
    - /wp-content/force-download.php/ => add case "ai": $ctype="application/illustrator"; break;
    - shortcode => [download label="logo (.ai)"]http://rainbowflash.org/uploads/download/rbw_logo.ai[/download]

    Unfortunately it does not work. It display :

    <a href="http://rainbowflash.org/download/http://rainbowflash.org/uploads/download/rbw_logo.ai" class="" rel="none">logo (.ai)</a>

    I do something wrong ?

    Thank you

  4. Drew Jaynes (DrewAPicture)
    Volunteer Moderator
    Plugin Author

    Posted 1 year ago #

    You've left /wp-content/ out of your file's URL. So:

    [download label="logo (.ai)"]http://rainbowflash.org/wp-content/uploads/download/rbw_logo.ai[/download]

    If you still get a 404, I suggest visiting Settings > Permalinks to flush your rewrite rules.

  5. karpediem
    Member
    Posted 1 year ago #

    Hi,
    The shortcode :

    [download label="logo (.ai)"]http://rainbowflash.org/wp-content/uploads/download/rbw_logo.ai[/download]

    display

    <a href="http://rainbowflash.org/download/rbw_logo.ai" >logo (.ai)</a>

    In Settings > Permalinks, I have :
    Post name : http://rainbowflash.org/blog/sample-post/
    I save (is it an other way to flush my rewrite rules ?).
    It's the same issue...

    Now, if I put directly this link in my post :

    <a href="http://rainbowflash.org/wp-content/force-download.php?file=uploads/download/rbw_logo.ai">Download : logo Rainbowflash (.ai)</a>

    The file is right download...

    An other idea please ?

  6. Drew Jaynes (DrewAPicture)
    Volunteer Moderator
    Plugin Author

    Posted 1 year ago #

    Hmm. Using your rbw_logo.ai file, your filter to modify the supported directory and your permalink settings, it's working fine for me.

    One thing that has me a little perturbed is that you said this shortcode:

    [download label="logo (.ai)"]http://rainbowflash.org/wp-content/uploads/download/rbw_logo.ai[/download]

    Outputs this URL in the link:

    http://rainbowflash.org/download/rbw_logo.ai

    But based on the plugin default rewrite scheme, it should actually output the link URL as this (as it did in my tests):

    http://rainbowflash.org/download/download/rbw_logo.ai

    Have you by chance modified the path supplied to the fds_download_rewrite_path filter and not mentioned it?

  7. karpediem
    Member
    Posted 1 year ago #

    No, I made nothing of other one, just to declare in functions.php the already specified code

    function change_download_files_directory() {
        return 'uploads/download';
    }
    add_filter( 'fds_download_files_directory', 'change_download_files_directory' );
  8. Drew Jaynes (DrewAPicture)
    Volunteer Moderator
    Plugin Author

    Posted 1 year ago #

    OK. Well, again, using a path of 'uploads/download', the plugin will output the path as rainbowflash.org/download/download/filename.ext.

    Do you have a live URL with a download shortcode link on it that I can test?

    It's also possible there is a conflict with another plugin or even your theme. Have you tried deactivating all other plugins to see if that will resolve it?

  9. Drew Jaynes (DrewAPicture)
    Volunteer Moderator
    Plugin Author

    Posted 1 year ago #

    Closing as resolved. Feel free to re-open or start a new thread if you have more issues.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic