I need to add some PHP and HTML to a action hook in my WordPress site
I can not work out how to add the php so that Sub total text is translatable _e(‘Sub-total’, ‘wpsc’)
That line throws a syntax error in my editor
Thanks to both of you! Very helpful. I could use a little clarification. The use of a period when the code is being echoed as a string by being in single quotes, switch between HTML and PHP. Is that a fair description?
I think that felgall’s version is clearer to read fro a novice like me. Any reason one is better than the other?
I guess cpradio’s version does not require me to go in and out of php tags within my functions file, I can just open one for the whole file
Just to explain why my method did not work and @felgall ; did.
I missed the fact that _e() was performing an echo to write out the translation, and because of that, it would produce the HTML result you received where the translation was outside of the table.
Ugh… You should never have html in a function like that. Your function should deal with pure data. You should then be calling the function in your view (html) script and using the data returned to create the view/html.
If you hard code html into functions like that, you’ll make your site virtually impossible to change.
*Edit: I’m assuming wordpress doesn’t expect you to do that? I’ve never coded in wordpress before. It’s a horrible way to write code, because you end up with a design that’s nigh on impossible to change. Don’t do it!