最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Preserving backslashes in post_content

programmeradmin2浏览0评论

I am trying to preserve backslahes in "post_content". When I escape the content with another backslash, it gets saved into the database correctly. However the next time I load the page in admin to edit it, the backslash is unescaped. So when I save the page after edits, it disappears as PHP thinks I am trying to escape the character after it.

Example: \\something in page gets saved as \something in the database. The next time I load the page in admin, there's only \something (that's what's saved in the DB). If I save the page now, the backslash disappears and only something is saved.

I have tried save_post and content_save_pre hooks to manually add another backslash to escape "my" backslash. For some reason str_replace() worked for only the first few hundred characters of post_content.

Do you please have any better way to preserve backslashes without having to manually escape all of them when saving a page after editing?

发布评论

评论列表(0)

  1. 暂无评论