• Hello,

    The plugin works like a charm, thanks for that.

    I’m using it to create a download link for each entry of a list of attachments from the media library.

    I had to include an onclick action for Ajax purposes (tracking downloads). So I modified the plugin output a bit, from

    return sprintf( '<a href="%1$s" class="%2$s">%3$s</a>', esc_url( $url ), esc_attr( $class ), esc_attr( $label ) );

    to

    return sprintf( '<a href="%1$s" class="%2$s">%3$s</a>', esc_url( $url ), esc_attr( $class ), esc_attr( $label ), get_the_ID(), get_current_user_ID() );

    around line 141 of download-shortcode.php.

    It still does the trick, the URL includes the relevant onClick and the shortcode works.

    But I also had to filter the list by category and used an Ajax action (‘load-filter’) for that.

    When the new filtered list is displayed in Ajax, get_the_ID() doesn’t work anymore.

    An idea about how to fix that ?

    Thanks

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

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Drew Jaynes

    (@drewapicture)

    Sounds like you need to pass the ID in there. get_the_ID() really only works inside the loop, and if your doing AJAX things it may fall outside the purview of the Loop.

    Also, it probably couldn’t hurt to make the return in download_shortcode_cb filterable, something I may add in the next version.

    Thread Starter mperrien

    (@mperrien)

    Thanks,
    I thought so.
    I’m going to try and find a workaround.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcode onClick Ajax’ is closed to new replies.