Reputation: 727
If I have this →
<input type="hidden" name="meta_adtracking" value="custom form" />
then I can easily convert this into a returnable string →
$output = '<input type="hidden" name="meta_adtracking" value="custom form" />'
Of course the output will later be returned:
return $output;
But this becomes challenging for me when It has a jQuery or a Wordpress Localized Function.
<input type="submit" class="one" name="aweber_submit" value="<?php _e("Subscribe", 'text-domain');?>" />
How to convert the above into a returnable string? [P.S. → The php tags are actually not required because the shortcode function is in a file that is .php extension], but then If I just remove a PHP tag would that be ok?
$output = '<input type="submit" class="one" name="aweber_submit" value="_e("Subscribe", 'text-domain');" />'
Is this Ok?
Upvotes: 1
Views: 696
Reputation: 12374
Almost. Try this!
You need to break out of the string and concatenate whatever the function returns.
$output = '<input type="submit" class="one" name="aweber_submit" value="'._e("Subscribe", 'text-domain').'" />';
Upvotes: 6
Reputation: 1168
You will need to change the following to prevent the PHP function being stored as part of the string or in this case, causing a parse error because of the inverted commas.
$output = '<input type="submit" class="one" name="aweber_submit" value="_e("Subscribe", 'text-domain');" />'
to
$output = '<input type="submit" class="one" name="aweber_submit" value="'._e("Subscribe", 'text-domain').'" />';
Also note that the _e
function will need to return a value for expected behavior.
Upvotes: 1