Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Jackson Whelan

    (@madjax)

    That other plugin isn’t actually using a shortcode for the button if you look deeper. It uses some regex via a filter added to the_content to replace [wp_cart] not the add_shortcode function.

    What if you were to customize your NGG template file to change this:

    <?php echo $image->caption ?>

    To something like this?

    <?php echo apply_filters(‘the_content’, $image->caption) ?>

    As far as I can see NGG is not applying these filters to the caption, so it will never properly convert the shortcode.

    Let me know how it goes.

    Thread Starter jakobud

    (@jakobud)

    That didn’t seem to work. The apply_filters function above just results in a blank/empty output.

    I’ve looked at the docs for apply_filters but I don’t really understand what it is wanting for input. Like you chose “the_content” to use as the hook in the function. Why did you choose that out of all the hooks? I’m just not sure what hook to use here…

    Can anyone help here?

    Plugin Author Jackson Whelan

    (@madjax)

    If your captions only include the shortcode, you could use:

    echo do_shortcode($image->caption);

    I was however thinking that you might also have normal text in the caption to appear. If so, applying the filters hooked to the_content would result in do_shortcode being run.

    do_shortcode() is registered as a default filter on ‘the_content’ with a priority of 11.

    https://codex.www.ads-software.com/Shortcode_API

    Plugin Author Jackson Whelan

    (@madjax)

    I just tested both solutions with success on a NGG install.

    What I did;

    – Added [paypal type="add" amount="10.00" productname="Something" sku="123" shipadd="0"] to the description field for the image in the Manage Gallery screen.

    – Edited the view template. In my case was /view/gallery.php – yours may be different depending on what view you’re showing.

    Added

    <?php echo apply_filters('the_content', $image->caption); ?>
    <?php echo do_shortcode($image->caption); ?>

    Presto change-o – two paypal buttons below the picture.

    Make sure you are testing with a complete shortcode with attributes. Example: [paypal type=”add” amount=”10.00″ productname=”Something” sku=”123″ shipadd=”0″] NOT just [paypal]

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: JW PayPal Shortcodes] Shortcodes dont work with Nextgen gallery’ is closed to new replies.