我想要我的下一個wordpress主題創建選項,但在這個主題我用選項樹插件幾乎80%的選項的CSS,所以我創建了一個style.php
文件,並在像其他的CSS頭添加它文件。獲得500服務器錯誤的WordPress
但我得到500服務器錯誤,如果我運行文件直接我得到這個錯誤500服務器錯誤:
我style.php文件The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must to be declared in the document or in the transfer protocol.
代碼:
<?php ob_start();
header("Content-type: text/css");
include("../../../wp-load.php");
header("HTTP/1.0 200 OK");
?>
<?php
if(function_exists('ot_get_option')){
?>
body{
<?php
$option = ot_get_option('website_width');
if(isset($option[0]) && isset($option[1])){
echo "width:".$option[0].$option[1];
}
?>;
}
.span8{
<?php
$option = ot_get_option('width_with_sidebar');
if(isset($option[0]) && isset($option[1])){
echo "width:".$option[0].$option[1];
}
?>;
}
.span6{
<?php
$option = ot_get_option('content_width_with_two_sidebar');
if(isset($option[0]) && isset($option[1])){
echo "width:".$option[0].$option[1];
}
?>;
}
.span12{
<?php
$option = ot_get_option('content_width_for_full_width');
if(isset($option[0]) && isset($option[1])){
echo "width:".$option[0].$option[1];
}
?>;
}
.span6,.span8,.span12{
<?php
$option = ot_get_option('content_margins');
if(isset($option[0]) && isset($option[1])){
echo "margin:".$option[0].$option[1];
}
?>;
<?php
$option = ot_get_option('content_padding');
if(isset($option[0]) && isset($option[1])){
echo "padding:".$option[0].$option[1];
}
?>;
}
body{
<?php
$option = ot_get_option('style');
if(isset($option)){
if($option=='full_width'){
echo "width:100% !important";
}
}
?>;
}
#site-title{
<?php
$option = ot_get_option('site_title')
if(isset($option)){
if(isset($option['font-color'])){
echo "color:".$option['font-color'].";";
}
if(isset($option['font-family'])){
echo "font-family:".$option['font-family'].";";
}
if(isset($option['font-size'])){
echo "font-size:".$option['font-size'].";";
}
if(isset($option['font-variant'])){
echo "font-variant:".$option['font-variant'].";";
}
if(isset($option['font-weight'])){
echo "font-weight:".$option['font-weight'].";";
}
if(isset($option['letter-spacing'])){
echo "letter-spacing:".$option['letter-spacing'].";";
}
if(isset($option['line-height'])){
echo "line-height:".$option['line-height'].";";
}
if(isset($option['text-decoration'])){
echo "text-decoration:".$option['text-decoration'].";";
}
if(isset($option['text-transform'])){
echo "text-transform:".$option['text-transform'].";";
}
}
?>
}
<?php
}
header("HTTP/1.0 200 OK");
?>
我懷疑一個字符編碼警告將是一個500錯誤的原因。你看過網絡服務器錯誤日誌中顯示的內容嗎? –
「NetworkError:500內部服務器錯誤 - http://wptesting.wpengine.com/wp-content/themes/standard/style.php」 style.php HTML文檔的字符編碼未聲明。如果文檔包含US-ASCII範圍之外的字符,則該文檔將在某些瀏覽器配置中呈現亂碼文本。頁面的字符編碼必須在文檔或傳輸協議中聲明。 –
yeesh。 WP因爲缺乏編碼而投擲500個?我猜WP編碼器將核彈一個城市,因爲在一個公寓的衣櫃有幾個蒼蠅。 –