[wp-trac] [WordPress Trac] #46063: echo in functions called by add_shortcode()
WordPress Trac
noreply at wordpress.org
Tue Jan 22 13:28:55 UTC 2019
#46063: echo in functions called by add_shortcode()
--------------------------+-----------------------------------
Reporter: kaikli | Owner: (none)
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: REST API | Version: 5.0.3
Severity: normal | Resolution: invalid
Keywords: | Focuses: javascript, rest-api
--------------------------+-----------------------------------
Comment (by kaikli):
Replying to [comment:1 johnbillion]:
> Thanks for the report @kaikli . Shortcode callback functions shouldn't
echo their output, only return it. If your shortcode handler returns its
output, then the REST API will work as expected.
>
> More info here: https://codex.wordpress.org/Shortcode_API
Thanks for your answer @johnbillion
I know that shortcode callback functions shouldn't echo their output.
In my case, it was a function somwhere included in the callback function
and it was not easy to find this issue.
\\
Is it than possible to add a error message, simply saying "Hey, you should
not echo something in your callback!" or "Hey, a callback function echos
some data!" or (sry, when this is wrong and wouldn't fix this) include a
ob_get_clean() in the REST-API.
\\
Only producing a error, even with no detailed information, would make it
plugin developers easier to recognize this problem.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46063#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list