I have a shortcode inside a plugin I wrote. The shortcode always prints on top, after a bit of research I found that I have to ‘return’ instead of ‘echo’ for me to get it in the right place.
I have inline HTML , css , javascript in various script tags inside the PHP file. Is there a way I can get it work without trying to return all the inline HTML. (adding ‘return’ to all html tags is a huge endeavour) ?
I know that a question on shortcode printing on top has been asked but this is not entirely the same problem I am having.
Appreciate your answers.
Just for people to get an idea of the code I am dealing with: This is just a small chunk of the code, but there is html, css spread all over the place.
extract(shortcode_atts(array(
'id'=>'0', 'key'=>'0'), $atts));
if(substr($id, -3) == "***") $id = substr($id, 0, 8);
$id_licenses = getDbInfo($id);
$id_desc = array();
if(is_array($id_licenses)) $id_desc = $id_licenses;
else $id_desc[0] = $id_licenses;
if(isset($_POST['desc'])) {
$info = $_POST['desc'];
$ids = getDbInfoByDesc($info);
}
?>
<style type="text/css">
label.inputlabel
{
width: 8em;
float: left;
text-align: left;
margin-right: 0.5em;
display: block;
padding-left: 0.5em;
font-family: Tahoma;
}
You have to return the final result but if you want you can buffer the result and
echoanything inside the buffer then can retun the buffered data, i.e.