今天把wordpress的post-template.php修改了

为的是把amazon的资料采集到wordpress时发生的摘要令到wordpress的模板错位, 自己记录下, 因为自己还不会编写wordpress的插件,所以先直接改源代码.

位置, wp-includes目录下,

修改内容在post-template.php的129行,改成:

  1. function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
  2. global $id, $post, $more, $page, $pages, $multipage, $preview, $pagenow;
  3.  
  4. $output = '';
  5.  
  6. if ( !empty($post->post_password) ) { // if there's a password
  7. if ( !isset($_COOKIE['wp-postpass_'.COOKIEHASH]) || stripslashes($_COOKIE['wp-postpass_'.COOKIEHASH]) != $post->post_password ) {    // and it doesn't match the cookie
  8. $output = get_the_password_form();
  9. return $output;
  10. }
  11. }
  12.  
  13. if ( $more_file != '' )
  14. $file = $more_file;
  15. else
  16. $file = $pagenow; //$_SERVER['PHP_SELF'];
  17.  
  18. if ( $page > count($pages) ) // if the requested page doesn't exist
  19. $page = count($pages); // give them the highest numbered page that DOES exist
  20.  
  21. $content = $pages[$page-1];
  22.  
  23. if ( preg_match('/<!--more(.*?)?-->/', $content, $matches) ) {
  24.  
  25. $content = explode($matches[0], $content, 2);
  26. if ( !empty($matches[1]) && !empty($more_link_text) )
  27. $more_link_text = strip_tags(wp_kses_no_null(trim($matches[1])));
  28. } else {
  29. $content = array($content);
  30. }
  31. if ( (false !== strpos($post->post_content, '<!--noteaser-->') && ((!$multipage) || ($page==1))) )
  32. $stripteaser = 1;
  33. $teaser = $content[0];
  34. if ( ($more) && ($stripteaser) )
  35. $teaser = '';
  36. $output .= $teaser;
  37. if ( count($content) > 1 ) {
  38. if ( $more ) {
  39. $output .= '<span id="more-'.$id.'"></span>'.$content[1];
  40. } else {
  41. $output = balanceTags($output);
  42. if ( ! empty($more_link_text) )
  43. $output .= ' <a href="'. get_permalink() . "#more-$id\" class=\"more-link\">$more_link_text</a>";
  44.  
  45. //2008.7.4 18:24 my edit
  46. $output=str_replace("<!--amazon-->","</div>",$output);
  47. }
  48.  
  49. }
  50. if ( $preview ) // preview fix for javascript bug with foreign languages
  51. $output =    preg_replace('/\%u([0-9A-F]{4,4})/e',    "'&#'.base_convert('\\1',16,10).';'", $output);
  52.  
  53. return $output;

关于无聊人

一个无聊人而已
此条目发表在php分类目录。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已用*标注