0

我希望有人可以帮助我。下面的代码来自一个 WordPress 插件。从插件选项页面,我输入了一些简单的 html -

<h3>Showname</h3><p>with DJ Top</p>

下面的代码 ($showname) 用于(一个 WordPress 短代码)显示我输入的内容,但它实际上显示 HTML 而不是处理它,即显示 HTML 标题和段落。

谁能指出我的方向,以便 $showname 处理 HTML,而不仅仅是将其逐字打印出来。

非常感谢

function showtime_schedule_handler($atts, $content=null, $code=""){

global $wpdb;
global $showtimeTable;

//Get the current schedule, divided into days
$daysOfTheWeek = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");

$schedule = array();

$output = '';

foreach ($daysOfTheWeek as $day) {
    //Add this day's shows HTML to the $output array
    $showsForThisDay =  $wpdb->get_results( $wpdb->prepare ( "SELECT * FROM $showtimeTable WHERE dayOfTheWeek = '$day' ORDER BY startTime" ));

    //Check to make sure this day has shows before saving the header
    if ($showsForThisDay){
        $output .= '<h2>'.$day.'</h2>';
        $output .= '<ul class="showtime-schedule">';
        foreach ($showsForThisDay as $show){
            $showName = $show->showName;
            $startClock = $show->startClock;
            $endClock = $show->endClock;
            $linkURL = $show->linkURL;

            if ($linkURL){
                $showName = '<a href="'.$linkURL.'">'.$showName.'</a>';
            }
            $output .= '<li><strong>'.$startClock.'</strong> - <strong>'.$endClock.'</strong>: '.$showName.'</li>';

        }
        $output .= '</ul>';
    }
}
return $output;
}
4

2 回答 2

1

您正在输出text/plainMIME 类型的变体。您需要使用默认标头 ( text/html) 将其发送出去,以便浏览器正确解析它。

例如:

<?php
    header('Content-Type: text/html', true);
    echo showtime_schedule_handler($atts, $content);
?>
于 2012-10-22T21:07:01.017 回答
0

代替

return $output;

尝试

return html_entity_decode($output);
于 2012-10-23T01:43:22.540 回答