[wp-trac] [WordPress Trac] #41025: get_comment_text and comment_text do not return the same result.
WordPress Trac
noreply at wordpress.org
Thu Jun 15 05:49:06 UTC 2017
#41025: get_comment_text and comment_text do not return the same result.
--------------------------+----------------------
Reporter: BackuPs | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: Comments | Version: 4.8
Severity: normal | Resolution: invalid
Keywords: | Focuses:
--------------------------+----------------------
Changes (by swissspidy):
* status: new => closed
* resolution: => invalid
* component: General => Comments
* milestone: Awaiting Review =>
Comment:
> Can you explain more as both functions comment_text() and
get_comment_text() call the filter and i still don't understand where the
difference in result is coming from.
That's not the case. `get_comment_text()` has the `get_comment_text`
filter in it and `comment_text()` has the `comment_text` filter.
If you look at `wp-includes/default-filters.php`, you can see plenty of
functions that are hooked to `comment_text`, but not `get_ comment_text`.
These functions are for formatting and add the actual paragraphs etc.
> comment_text does the echo of the comment whereas using get_comment_text
returns the string. But that string should be exactly the same without any
difference in the text as comment_text.
For historical reasons, those are not the same. `get_comment_text()` is
good for modifying the text before processing it. You don't really want
automatically generated HTML to be in there.
> So why does get_comment_text strip all p-tags and comment_text does not?
It's the other way around. In `comment_text()`, the HTML is being
''added''. If you want to have the same HTML in `get_comment_text()` as
well, you can add the needed functions to the filter.
------
I'm closing this because it's not really a bug and for BC reasons it's not
something we should change.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41025#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list