1

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.

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?

2 Answers 2

6

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').'" />';
Sign up to request clarification or add additional context in comments.

3 Comments

Why should OP try this? Can you explain the difference between your answer, and OPs attempt?
Yes, that's better :-) though there is missing a quote to close the value attribute, you now have ..value="something />, which causes a syntax error on php and invalid HTML
well spotted! fixed
1

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.

1 Comment

You mean this → 'return $output';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.