php - How would you combine this wordpress shortcode template code?
I am using a plugin that is generating my price value and pulling it from an array:
<?php echo __('Price: ', 'event_espresso'); ?></span> <?php echo $org_options['currency_symbol'].$event->event_cost; ?>
I want to convert this generated value into my visitors own currency depending on the country their in with the plugin 'Worldcurrency'
However you have to input a value in the short code like so:
[worldcurrency curr="EUR" value="25"] in united states will show: (~30$ USD)
Now I know how to use a shortcode in a template php file but I don't know if its possible to insert my array value and currency symbol into this shortcode. Rather than using
value="25" i need to use:
value="<?php echo $org_options['currency_symbol'].$event->event_cost; ?>"
Is this possible?
I'm not sure whether it's possible to use PHP code inline in a shortcode - and I suspect not, however an easy enough way to implement this would be to write a shortcode of your own that then called the other shortcode.
Your shortcode would generate the text you want (eg '[worldcurrency curr="EUR" value="25"]'), and call "do_shortcode($content)" which would then cause the other plugin to do the currency lookup for you.
You could put this in a plugin file and it would probably amount to less than 15 lines of code.
The other option is to modify the currency conversion plugin you are using to produce the output you want.