Plugin Directory

Changeset 204179


Ignore:
Timestamp:
02/11/2010 12:47:51 PM (16 years ago)
Author:
conis
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-markkeyword/trunk/index.php

    r202738 r204179  
    44Plugin URI: http://conis.cn/1365/
    55Description: This plugin can high light keyword after someone searchecd it, which supports the search engines like google, baidu, ask,  yahoo&bing.wp-markKeyword可以高亮显示来自搜索引擎的关键字,支持多个搜索引擎,更多请访问我的博客
    6 Version: 0.6
     6Version: 0.8
    77Author: Conis
    88Author URI: http://conis.cn/
     
    1111$mmkKeyword;
    1212$mmkIsShowMsg;
    13 
     13function momoReplace($content)
     14{
     15    global $mmkKeyword;
     16    if(isset($mmkKeyword))
     17    {
     18        $arrKeyword = explode(' ', $mmkKeyword);
     19        foreach($arrKeyword as $item)
     20        {
     21            $pattern = "/(".$item.")(?=[^<>]*<)/";
     22            $content = preg_replace($pattern,'<span class="wmkHighLight">\1</span>',$content);
     23        }
     24    }
     25    return $content;   
     26}
    1427function momoMarkKeywordMsg()
    1528{
     
    3447    global $mmkIsShowMsg;
    3548    if($mmkIsShowMsg) return $content;
    36     if(isset($mmkKeyword))
    37     {
    38         $arrKeyword = explode(' ', $mmkKeyword);
    39         foreach($arrKeyword as $item)
    40         {
    41             $content = str_ireplace('/(>.*)('.$item.')(.*<)/U', '<span class="wmkHighLight">'.$item.'</span>', $content);
    42             //$content = str_ireplace( $item, '<span class="wmkHighLight">'.$item.'</span>', $content);
    43         }
    44     }
     49    $content = momoReplace($content);
    4550    $mmkIsShowMsg = true;
    4651    return momoMarkKeywordMsg().$content;
     
    4954function momoMarkKeywordExcerpt($content = '')
    5055{       
    51     global $mmkKeyword;
    52     if(isset($mmkKeyword))
    53     {
    54         $arrKeyword = explode(' ', $mmkKeyword);
    55         foreach($arrKeyword as $item)
    56         {
    57             $content = str_ireplace( $item, '<span class="wmkHighLight">'.$item.'</span>', $content);   
    58         }
    59     }
     56    $content = momoReplace($content);
    6057    return $content;
    6158}
Note: See TracChangeset for help on using the changeset viewer.