我希望有人可以帮助我。下面的代码来自WordPress插件。从插件选项页面我输入一些简单的html -
<h3>Showname</h3><p>with DJ Top</p>
使用下面的代码($ showname)来显示我输入的内容,但它实际上显示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;
}
答案 0 :(得分:1)
您输出的是text/plain
MIME类型的变体。您需要使用默认标头(text/html
)将其发送出去,以便浏览器正确解析它。
例如:
<?php
header('Content-Type: text/html', true);
echo showtime_schedule_handler($atts, $content);
?>
答案 1 :(得分:0)
而不是
return $output;
尝试
return html_entity_decode($output);