我有一个“自定义插件”,用于抓取网站内容并通过简码放在我的网站上。在更新 wordpress 的 newset 版本(并切换到 HTTPS)后,短代码不起作用。
我试图打开其他主题,但没有帮助。
<?php
function file_get_contents_utf8($fn) {
$content = file_get_contents($fn);
$ary[] = "ISO-8859-2";
$ary[] = "UTF-8";
$ary[] = "ASCII";
return w1250_to_utf8($content);
/*return mb_convert_encoding($content, 'UTF-8',
mb_detect_encoding($content,$ary, true));*/
}
function w1250_to_utf8($text) {
// map based on:
// http://konfiguracja.c0.pl/iso02vscp1250en.html
// http://konfiguracja.c0.pl/webpl/index_en.html#examp
// http://www.htmlentities.com/html/entities/
$map = array(
chr(0x8A) => chr(0xA9),
chr(0x8C) => chr(0xA6),
chr(0x8D) => chr(0xAB),
chr(0x8E) => chr(0xAE),
chr(0x8F) => chr(0xAC),
chr(0x9C) => chr(0xB6),
chr(0x9D) => chr(0xBB),
chr(0xA1) => chr(0xB7),
chr(0xA5) => chr(0xA1),
chr(0xBC) => chr(0xA5),
chr(0x9F) => chr(0xBC),
chr(0xB9) => chr(0xB1),
chr(0x9A) => chr(0xB9),
chr(0xBE) => chr(0xB5),
chr(0x9E) => chr(0xBE),
chr(0x80) => '€',
chr(0x82) => '‚',
chr(0x84) => '„',
chr(0x85) => '…',
chr(0x86) => '†',
chr(0x87) => '‡',
chr(0x89) => '‰',
chr(0x8B) => '‹',
chr(0x91) => '‘',
chr(0x92) => '’',
chr(0x93) => '“',
chr(0x94) => '”',
chr(0x95) => '•',
chr(0x96) => '–',
chr(0x97) => '—',
chr(0x99) => '™',
chr(0x9B) => '’',
chr(0xA6) => '¦',
chr(0xA9) => '©',
chr(0xAB) => '«',
chr(0xAE) => '®',
chr(0xB1) => '±',
chr(0xB5) => 'µ',
chr(0xB6) => '¶',
chr(0xB7) => '·',
chr(0xBB) => '»',
);
if(strpos(get_permalink(),"eurojackpot") !== false)
return $text;
else
return html_entity_decode(mb_convert_encoding(strtr($text, $map), 'UTF-8', 'ISO-8859-2'), ENT_QUOTES, 'UTF-8');
}
function download_tipos( $atts ) {
$atts = shortcode_atts( array(
'url' => '',
), $atts, 'download_tipos' );
$content = file_get_contents_utf8($atts["url"]);
if($atts["url"] == "http://eurojackpot.tipos.sk/sk/eurojackpot/vysledky"){
preg_match('/(<div class="row".*?)<div id="footer"/s',$content,$vys);
}
else{
preg_match('/(<div class="bgResultsPnlTop".*?)<div class="bgResultsPnlBottom"/s',$content,$vys);
}
$ret = str_replace('<div id="M5_pnlOptional1"',$reklama.'<div id="M5_pnlOptional1"',$vys[1]).$reklama2;
$ret = str_replace('<div id="_7b7b0a087277_pnlOptional1"',$reklama.'<div id="_7b7b0a087277_pnlOptional1"',$ret);
$ret = str_replace('<p class="kenoPlusNo"',$reklama.'<p class="kenoPlusNo"',$ret);
$ret = str_replace('<div class="content col-md-6 right-col"',$reklama.'<div class="content col-md-6 right-col"',$ret);
$ret = preg_replace('#<a.*?>.*?</a>#i', '', $ret);
$ret = preg_replace('#<img.*?>#i', '', $ret);
return $ret;
}
add_shortcode( 'download_tipos', 'download_tipos' );
add_action('wp_head','hook_css');
function hook_css() {?>
<style>
.orderedNumbers span,.unorderedNumbers span,.result-number li{
border-radius: 50px;
background-color: #eee;
width: 50px;
display: inline-block;
text-align: center;
font-size: 20px;
}
</style>
<?php
}
?>
在输出页面中有这个shortode:
<p>[download_tipos url="http://www.tipos.sk/Default.aspx?CatID=711"]
</p>
我期望的是带有数字的表格,但我没有得到任何输出,并且在源代码中找不到的输出 URL(download_tipos 标记)。有没有办法调试这个问题?