[wp-trac] [WordPress Trac] #54601: wp_insert_post function removes backslashes

WordPress Trac noreply at wordpress.org
Sat Dec 11 16:40:31 UTC 2021


#54601: wp_insert_post function removes backslashes
-------------------------------+----------------------
 Reporter:  sweetheatmn        |       Owner:  (none)
     Type:  defect (bug)       |      Status:  closed
 Priority:  normal             |   Milestone:
Component:  Posts, Post Types  |     Version:
 Severity:  normal             |  Resolution:  invalid
 Keywords:                     |     Focuses:
-------------------------------+----------------------
Changes (by ocean90):

 * status:  reopened => closed
 * resolution:   => invalid
 * milestone:  Awaiting Review =>


Comment:

 Hello @sweetheatmn,

 by default `wp_insert_post()` doesn't add slashes to the post data because
 it '''expects''' the data already to be slashed. Before the data gets
 stored into the database `wp_unslash()` is called. That's why the slash
 from your input is removed.
 To solve this you have to call `wp_slash()` on your data first.

 Related: #41593

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54601#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list