Hi @ozarkrepair,
Have you tried using an opening php tag (<?php) in the PHP snippet? We try to automatically remove that but if it’s not at the beginning of the snippet it might not work and could cause issue.
Hi @gripgrip, I re-tried, both with and without open and close php tags and each combination of the two, without any expected snippet output.
Ah! In addition to the echo, I added a file output debug statement:
<?php // <--- Opening tag auto-included
file_put_contents("/var/lib/wordpress/debug/foobar.txt", "testing\n");
...
echo "foobar";
?> // <--- End tag manually included
I don’t see the echo output on the webpage like I do with the universal snippet, but I do see the foobar.txt debug file output, so it is executing, but looks like the text output gets swallowed…
Maybe it’s related to these lines 267, 268 in file insert-headers-and-footers/includes/class-wpcode-snippet-execute.php
:
// Catch any output from running the code.
ob_start();
?
Hi @ozarkrepair,
That’s used specifically to be able to catch the output of your snippet and return it so that it doesn’t create output too early. You don’t have to add any opening of closing tags for PHP snippets, I suggest trying to remove those.
Hi Mircea, thank you. I’ve tried with all combos of tags, including without also. Maybe it’s something in the astra template that suppresses the output. Using the universal tag works as expected… If you feel like having me try anything, happy to help, but I have an understanding of what I need to use now and an adjusted expectation of what to expect in my environment from the php snippet (ie: output may not work, but non-output code seems to be ok)… So I’m good now as far as I’m concerned. Thanks!