更新后的Wordpress Shorcode无法正常工作-如何调试?

时间:2019-06-14 19:10:02

标签: wordpress shortcode wordpress-shortcode

我有一个“自定义插件”,用于抓取网站内容并通过简码插入我的网站。更新新版本的wordpress后(并切换到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) => '&euro;',
    chr(0x82) => '&sbquo;',
    chr(0x84) => '&bdquo;',
    chr(0x85) => '&hellip;',
    chr(0x86) => '&dagger;',
    chr(0x87) => '&Dagger;',
    chr(0x89) => '&permil;',
    chr(0x8B) => '&lsaquo;',
    chr(0x91) => '&lsquo;',
    chr(0x92) => '&rsquo;',
    chr(0x93) => '&ldquo;',
    chr(0x94) => '&rdquo;',
    chr(0x95) => '&bull;',
    chr(0x96) => '&ndash;',
    chr(0x97) => '&mdash;',
    chr(0x99) => '&trade;',
    chr(0x9B) => '&rsquo;',
    chr(0xA6) => '&brvbar;',
    chr(0xA9) => '&copy;',
    chr(0xAB) => '&laquo;',
    chr(0xAE) => '&reg;',
    chr(0xB1) => '&plusmn;',
    chr(0xB5) => '&micro;',
    chr(0xB6) => '&para;',
    chr(0xB7) => '&middot;',
    chr(0xBB) => '&raquo;',
     );
     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
 }
?>

在输出页面中,这是此短消息:

  <p>[download_tipos url="http://www.tipos.sk/Default.aspx?CatID=711"] 
 </p>

我期望的是带有数字的表,但是我没有得到任何输出,也没有在源代码(download_tipos标记)中找到的输出URL上。有没有办法调试这个问题?

0 个答案:

没有答案