【问题标题】:Wordpress shortcode, backslash added in front of double quotation marksWordpress 简码,在双引号前添加反斜杠
【发布时间】:2016-03-18 10:48:13
【问题描述】:

例如,我需要在短代码图像标签中添加一些 html

<img src="http://image.com/design/images/5Stars.png" alt="5 star rating">

当我检查数据库中的值时,我可以看到所有用反斜杠格式化的双引号

<img src=\"http://image.com/design/Images/5Stars.png\" alt=\"5 star rating\">

我尝试使用“htmlspecialchars()”和“esc_attr()”,但是当我使用简码时,我可以看到简单的文本而不是 html。

【问题讨论】:

  • 你可以使用stripslashes()同时保存在数据库中。
  • 不,stripslashes() 给出相同的结果

标签: php wordpress shortcode magic-quotes


【解决方案1】:

试试ob_start 像这个例子:

function my_shortcode() {
    ob_start();
    ?> <HTML> <here> ... <?php
      return ob_get_clean(); }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-03
    • 2014-07-26
    • 1970-01-01
    • 2019-12-05
    • 1970-01-01
    相关资源
    最近更新 更多