【问题标题】:HTML not rendering in php array esc_htmlHTML未在php数组esc_html中呈现
【发布时间】:2014-05-19 22:44:00
【问题描述】:

我正在使用来自名为 Divi

的优雅主题的 wordpress 主题

它们有一个全宽滑块,顶部有一个按钮。当您将文本输入到填充按钮的表单字段中时,您可以输入 html,但是当它在页面上呈现时,您可以看到 html 而不是看到输出。

我查看了functions.php 并找到了我放在下面的按钮的代码块。我认为这与esc_html 标签有关,但对此没有太多经验?

add_shortcode( 'et_pb_slide', 'et_pb_slide' );
function et_pb_slide( $atts, $content = '' ) {
    extract( shortcode_atts( array(
            'alignment' => 'center',
            'heading' => '',
        'button_text' => '',
        'button_link' => '#',
        'background_color' => '',
        'background_image' => '',
        'image' => '',
        'image_alt' => '',
        'background_layout' => 'dark',
        'video_bg_webm' => '',
        'video_bg_mp4' => '',
        'video_bg_width' => '',
        'video_bg_height' => '',
        'video_url' => '',
    ), $atts
) );

这是按钮的直接代码。

$button = '';
if ( '' !== $button_text )
    $button = sprintf( '<a href="%1$s" class="et_pb_more_button">%2$s</a>',
        esc_attr( $button_link ),
        esc_html( $button_text )
    );

抱歉,目前无法提供网址。

【问题讨论】:

    标签: php html wordpress themes


    【解决方案1】:

    我删除了 esc_html 并且它起作用了。

    【讨论】:

      猜你喜欢
      • 2020-04-25
      • 1970-01-01
      • 2022-01-20
      • 2020-02-25
      • 1970-01-01
      • 2015-08-06
      • 1970-01-01
      • 2019-01-20
      • 2014-03-14
      相关资源
      最近更新 更多