WordPress.org

Ready to get started?Download WordPress

Forums

How to add plugin shortcode as php in template (5 posts)

  1. SpartanCopy
    Member
    Posted 11 months ago #

    I am using Artpal which used the shortcode [artpal=insert] in the post content to add paypal button and pricing to the post.

    Unfortunately the plugin does not provide a php version of this shortcode so it can added directly to the template. Is there a way to convert this in to a php script?

    I have tried <?php echo ('[artpal=insert]'); ?> however this just displays the text [artpal=insert]

    Any ideas on how I could imbed this into the template or turn it in to php command?

  2. SpartanCopy
    Member
    Posted 11 months ago #

    I miss typed the code above.

    I've tried <?php echo do_shortcode ('[artpal=insert]'); ?> however this just displays the text [artpal=insert]

  3. bcworkz
    Member
    Posted 11 months ago #

    Your second script is correct in theory, but for some reason the script is not matching up the tag in the array of callbacks used to route shortcodes to the correct functions.

    Try a var_dump() of the global $shortcode_tags to determine why there is no match. You might also try calling whatever callback is listed here for that tag directly.

    In other words, the array should have an entry similar to

    ["artpal=insert"]=>
       string(18) "some_function_name"

    You could try calling some_function_name() from your template.

  4. SpartanCopy
    Member
    Posted 11 months ago #

    Thanks for the help bcworkz. I tried your suggestion of var_dump($shortcode_tags) but strangely the artpal shortcode was not listed. However it turns out I will not be using the artpal plugin due to a massive security risk in the coding. I think I'll need to revert to using something like WP e-commerce.

    Turns out if you save the product page off-line and view/edit the page source you can manually set the price of a product as the paypal button has it in a simple list for all to see and edit.

    <input type="hidden" value="134" name="item_number">
    <input type="hidden" value="300.00" name="amount">
    <input type="hidden" value="GBP" name="currency_code">
    <input type="hidden" value="1" name="quantity">

  5. bcworkz
    Member
    Posted 11 months ago #

    That explains why do_shortcode() doesn't work. The shortcode handler must be added and removed dynamically only during content output, or filtered in some other manner. Seems like the author took some measures to only allow the shortcode to work in content and nowhere else.

    I'm not sure how massive a risk that really is, you would want a parallel payment verification process in any case that would catch any price tampering. But I can see how this would make you uneasy, which is reason enough to seek alternatives.

Reply

You must log in to post.

About this Topic