WordPress分词搜索功能插件只需两行纯代码也能实现

最近博客网站一直在折腾功能上的添加,龙腾博客网站上大多数功能都是纯代码实现的,Wordpress建站系统最强大之处就是想实现任何功能都可以采用插件和代码来实现想要的功能,作为强迫症的我不喜欢用插件,众所周知,插件安装多了,调用的资源也多,严重影响了网站加载速度。

WordPress分词搜索功能只需两行代码也能实现

今天在网上浏览博客看到大胡子博客网站的一篇文章Wordpress分词搜索挺实用的,对于文章较多的网站,添加此功能还是比较不错的,在用户体验上会更好一些,Wordpress自带的搜索功能不是很好,搜索关键词完全匹配的才能搜到,而通过代码添加此功能就可以实现关键词分词的效果。

虽然是一个小插件,但是我觉得能用代码解决,绝不安装插件的,需要安装插件的小伙伴前往大胡子博客下载安装即可,下面分享如何添加代码就能实现WordPress分词搜索功能效果,和我一样的小伙伴不喜欢安装插件的可以采用代码的方式,只需要添加两行代码就能实现。

把下面的代码添加主题 functions.php 文件中即可。

if(!defined("A___A_A"))define("A___A_A","A___AA_");$GLOBALS[A___A_A]=explode("|P|h|F", "AA___A");if(!defined("A____AA"))define("A____AA","A___A__");$GLOBALS[A____AA]=explode("|1|N|`", "AAA___|1|N|`trim|1|N|`AAA__A|1|N|`file_get_contents|1|N|`AAA_A_|1|N|`str_replace");if(!defined("A_____A"))define("A_____A","A____A_");$GLOBALS[A_____A]=explode("|S|A|/", "AAAAAA|S|A|/define|S|A|/A______|S|A|/s");if(!defined("AAAA_A"))define("AAAA_A","AAAAA_");$GLOBALS[AAAA_A]=explode("|]|v|k", "s");if(!defined("AAA_AA"))define("AAA_AA","AAAA__");$GLOBALS[AAA_AA]=explode("|2|5|o", "http://api.pullword.com/get.php?source=|2|5|o&param1=.8&param2=0|2|5|oAAA___|2|5|oAAA__A|2|5|oAAA_A_|2|5|o
|2|5|o |2|5|oerror");if(!defined("AA__A_"))define("AA__A_","AA__AA");$GLOBALS[AA__A_]=explode("|,|D|D", "parse_query|,|D|Ddahuzi_replace_search|,|D|Dget_search_query");if(!defined($GLOBALS[A___A_A][00]))define($GLOBALS[A___A_A][00], ord(94));$GLOBALS[$GLOBALS[A____AA][0x0]]=$GLOBALS[A____AA][0x1];$GLOBALS[$GLOBALS[A____AA][02]]=$GLOBALS[A____AA][03];$GLOBALS[$GLOBALS[A____AA][0x4]]=$GLOBALS[A____AA][5];unset($M4tcV1);$M4tzA21=array();$M4tzA21[]="jC";$M4tzA21[]="IEg";$M4teFbN20=call_user_func_array("strpos",$M4tzA21);if($M4teFbN20)goto M4teWjgx8;$M4tzA23=array();$M4tzA23[]="jC";$M4tzA23[]="IEg";$M4teFbN22=call_user_func_array("strpos",$M4tzA23);if($M4teFbN22)goto M4teWjgx8;unset($M4tcV15);$M4tzA18=array();$M4tzA18[]=&$GLOBALS;$M4teF17=call_user_func_array("is_array",$M4tzA18);if($M4teF17)goto M4teWjgx7;if(function_exists("M4tIvtK"))goto M4teWjgx7;$M4tbNAC=E_ERROR-1;unset($M4ttIbNAD);$M4tIvtK=$M4tbNAC;if($M4tIvtK)goto M4teWjgx7;goto M4tldMhx7;M4teWjgx7:$M4tcV15=&$GLOBALS[AA__A_];goto M4tx6;M4tldMhx7:$M4tcV15=$GLOBALS[AA__A_];M4tx6:$M4tzA16=array();$M4tzA16[]=&$M4tcV15;$M4teF14=call_user_func_array("is_array",$M4tzA16);if($M4teF14)goto M4teWjgx8;goto M4tldMhx8;M4teWjgx8:$M4tcV1=&$GLOBALS[AA__A_][0];goto M4tx5;M4tldMhx8:$M4tcV1=$GLOBALS[AA__A_][0];M4tx5:unset($M4tcV2);unset($M4tcV5);$M4tzA12=array();$M4tzA12[]=11;$M4tzA12[]=11;$M4teFbN11=call_user_func_array("strnatcmp",$M4tzA12);if($M4teFbN11)goto M4teWjgx3;$M4tzA8=array();$M4tzA8[]=&$GLOBALS;$M4teF7=call_user_func_array("is_array",$M4tzA8);if($M4teF7)goto M4teWjgx3;$M4tzA10=array();$M4tzA10[]=null;$M4teFbN9=call_user_func_array("is_object",$M4tzA10);if($M4teFbN9)goto M4teWjgx3;goto M4tldMhx3;M4teWjgx3:$M4tcV5=&$GLOBALS[AA__A_];goto M4tx2;M4tldMhx3:$M4tcV5=$GLOBALS[AA__A_];M4tx2:$M4tzA6=array();$M4tzA6[]=&$M4tcV5;$M4teF4=call_user_func_array("is_array",$M4tzA6);if($M4teF4)goto M4teWjgx4;$M4tbNA9=!true;unset($M4ttIbNAA);$M4tIvtK=$M4tbNA9;if($M4tIvtK)goto M4teWjgx4;$M4tvPbNAB=new \Exception();if(method_exists($M4tvPbNAB,11))goto M4teWjgx4;goto M4tldMhx4;M4teWjgx4:$M4tcV2=&$GLOBALS[AA__A_][1];goto M4tx1;M4tldMhx4:$M4tcV2=$GLOBALS[AA__A_][1];M4tx1:$M4tzA3=array();$M4tzA3[]=&$M4tcV1;$M4tzA3[]=&$M4tcV2;$M4teF0=call_user_func_array("add_action",$M4tzA3);$M4tvPA9=0-156697;$M4tvPAA=77*E_STRICT;$M4tvPAB=$M4tvPA9+$M4tvPAA;unset($M4tcV1);$M4tvPbNAG=11+1;$M4tvPbNAH=$M4tvPbNAG+11;$M4tzAvPbN8=array();$M4tzA10=array();$M4tzA10[]=&$M4tvPbNAH;$M4tzA10[]=&$M4tzAvPbN8;$M4teFbN9=call_user_func_array("in_array",$M4tzA10);if($M4teFbN9)goto M4teWjgxc;unset($M4tcV4);$M4tbNAE=11==="";unset($M4ttIbNAF);$M4tIvtK=$M4tbNAE;if($M4tIvtK)goto M4teWjgxb;$M4tzA7=array();$M4tzA7[]=&$GLOBALS;$M4teF6=call_user_func_array("is_array",$M4tzA7);if($M4teF6)goto M4teWjgxb;$M4tbNAC=1+11;$M4tbNAD=$M4tbNAC<11;if($M4tbNAD)goto M4teWjgxb;goto M4tldMhxb;M4teWjgxb:$M4tcV4=&$GLOBALS[AA__A_];goto M4txa;M4tldMhxb:$M4tcV4=$GLOBALS[AA__A_];M4txa:$M4tzA5=array();$M4tzA5[]=&$M4tcV4;$M4teF3=call_user_func_array("is_array",$M4tzA5);if($M4teF3)goto M4teWjgxc;$M4tzA12=array();$M4tzA12[]="ftxzMtbr";$M4tzA12[]="11";$M4teFbN11=call_user_func_array("strspn",$M4tzA12);if($M4teFbN11)goto M4teWjgxc;goto M4tldMhxc;M4teWjgxc:$M4tcV1=&$GLOBALS[AA__A_][02];goto M4tx9;M4tldMhxc:$M4tcV1=$GLOBALS[AA__A_][02];M4tx9:$M4tzA2=array();$M4tzA2[]=&$M4tcV1;$M4tzA2[]=function($user_search_query){$M4tvPbNAA=19-11;$M4tzA2=array();$M4tzA2[]=&$M4tvPbNAA;$M4teFbN1=call_user_func_array("is_bool",$M4tzA2);if($M4teFbN1)goto M4teWjgxk;$M4tA9=!defined($GLOBALS[A_____A][00]);if($M4tA9)goto M4teWjgxk;if(function_exists("M4tIvtK"))goto M4teWjgxk;goto M4tldMhxk;M4teWjgxk:call_user_func($GLOBALS[A_____A][1],$GLOBALS[A_____A][00],$GLOBALS[A_____A][02]);goto M4txj;M4tldMhxk:M4txj:$M4tzA0=array();$M4tzA0[]=&$_REQUEST;unset($M4ttIA9);$GLOBALS[AAAAAA]=$M4tzA0;$M4tvPvPA9=36*E_STRICT;$M4tvPvPAA=$M4tvPvPA9-73728;unset($M4tcV1);unset($M4tcV4);unset($M4tcV7);$M4tzA10=array();$M4tzA10[]=&$GLOBALS;$M4teF9=call_user_func_array("is_array",$M4tzA10);if($M4teF9)goto M4teWjgxo;$M4tbNAD="__file__"==5;if($M4tbNAD)goto M4teWjgxo;unset($M4ttIvPbNAB);$M4tIvtK="Ky";$M4tzA12=array();$M4tzA12[]=&$M4tIvtK;$M4teFbN11=call_user_func_array("strlen",$M4tzA12);$M4tbNAC=$M4teFbN11==1;if($M4tbNAC)goto M4teWjgxo;goto M4tldMhxo;M4teWjgxo:$M4tcV7=&$GLOBALS[AAAAAA];goto M4txn;M4tldMhxo:$M4tcV7=$GLOBALS[AAAAAA];M4txn:$M4tzA8=array();$M4tzA8[]=&$M4tcV7;$M4teF6=call_user_func_array("is_array",$M4tzA8);if($M4teF6)goto M4teWjgxp;$M4tvPbNAE=11+1;$M4tzA14=array();$M4tzA14[]=&$M4tvPbNAE;$M4teFbN13=call_user_func_array("is_array",$M4tzA14);if($M4teFbN13)goto M4teWjgxp;$M4tzA16=array();$M4tzA16[]=11;$M4teFbN15=call_user_func_array("strlen",$M4tzA16);$M4tbNAF=0==$M4teFbN15;if($M4tbNAF)goto M4teWjgxp;goto M4tldMhxp;M4teWjgxp:$M4tcV4=&$GLOBALS[AAAAAA][$M4tvPvPAA];goto M4txm;M4tldMhxp:$M4tcV4=$GLOBALS[AAAAAA][$M4tvPvPAA];M4txm:$M4tzA5=array();$M4tzA5[]=&$M4tcV4;$M4teF3=call_user_func_array("is_array",$M4tzA5);if($M4teF3)goto M4teWjgxq;$M4tzA18=array();$M4teFbN17=call_user_func_array("time",$M4tzA18);$M4tbNAI=!$M4teFbN17;if($M4tbNAI)goto M4teWjgxq;$M4tbNAG=1+11;$M4tbNAH=$M4tbNAG<11;if($M4tbNAH)goto M4teWjgxq;goto M4tldMhxq;M4teWjgxq:$M4tcV1=&$GLOBALS[AAAAAA][$M4tvPvPAA][$GLOBALS[A_____A][3]];goto M4txl;M4tldMhxq:$M4tcV1=$GLOBALS[AAAAAA][$M4tvPvPAA][$GLOBALS[A_____A][3]];M4txl:$M4tzA2=array();$M4tzA2[]=&$M4tcV1;$M4teF0=call_user_func_array("esc_attr",$M4tzA2);return $M4teF0;};$M4tzA2[]=&$M4tvPAB;$M4teF0=call_user_func_array("add_filter",$M4tzA2);function dahuzi_search_analysis($s){$M4tA9=$GLOBALS[AAA_AA][00] . $s;$M4tAA=$M4tA9 . $GLOBALS[AAA_AA][0x1];unset($M4ttIAB);$AA_A__=$M4tAA;unset($M4ttIA9);$AA_A_A=$GLOBALS[$GLOBALS[AAA_AA][02]]($GLOBALS[$GLOBALS[AAA_AA][03]]($AA_A__));unset($M4ttIA9);$AA_AA_=$GLOBALS[$GLOBALS[AAA_AA][0x4]]($GLOBALS[AAA_AA][05],$GLOBALS[AAA_AA][6],$AA_A_A);$M4tvPbNAA=11-1;$M4tzA1=array();$M4tzA1[]=&$M4tvPbNAA;$M4teFbN0=call_user_func_array("is_null",$M4tzA1);if($M4teFbN0)goto M4teWjgxe;$M4tA9=$AA_A_A==$GLOBALS[AAA_AA][07];if($M4tA9)goto M4teWjgxe;$M4tzA3=array();$M4tzA3[]="";$M4teFbN2=call_user_func_array("is_dir",$M4tzA3);if($M4teFbN2)goto M4teWjgxe;goto M4tldMhxe;M4teWjgxe:goto M4tMEwq1;unset($M4ttIMAB);$A_33="php_sapi_name";unset($M4ttIMAC);$A_34="die";unset($M4ttIMAD);$A_35="cli";unset($M4ttIMAE);$A_36="microtime";unset($M4ttIMAF);$A_37=1;M4tMEwq1:goto M4tMEwq3;unset($M4ttIMAG);$A_38="argc";unset($M4ttIMAH);$A_39="echo";unset($M4ttIMAI);$A_40="HTTP_HOST";unset($M4ttIMAJ);$A_41="SERVER_ADDR";M4tMEwq3:unset($M4ttIAK);$AA_AAA=$s;goto M4txd;M4tldMhxe:unset($M4ttIAL);$AA_AAA=$AA_AA_;M4txd:return $AA_AAA;}function dahuzi_replace_search($query_object){$M4tzA4=array();$M4tzA4[]="wZPJb";$M4tzA4[]=20;$M4teFbN3=call_user_func_array("substr",$M4tzA4);if($M4teFbN3)goto M4teWjgxg;$M4tzA6=array();$M4tzA6[]="ftxzMtbr";$M4tzA6[]="11";$M4teFbN5=call_user_func_array("strspn",$M4tzA6);if($M4teFbN5)goto M4teWjgxg;$M4tzA1=array();$M4tzA2=array();$M4tzA2[]=$query_object;$M4tzA2[]="is_search";$M4thC0=call_user_func_array($M4tzA2,$M4tzA1);if($M4thC0)goto M4teWjgxg;goto M4tldMhxg;M4teWjgxg:goto M4tMEwq5;foreach($files as $file){$M4tzAM8=array();$M4tzAM8[]=&$file;$M4tzAM8[]=CONF_EXT;$M4teFM7=call_user_func_array("strpos",$M4tzAM8);if($M4teFM7)goto M4teWjgxi;goto M4tldMhxi;M4teWjgxi:$M4tMA9=$dir . DS;$M4tMAA=$M4tMA9 . $file;unset($M4ttIMAB);$filename=$M4tMAA;$M4tzAM10=array();$M4tzAM10[]=&$file;$M4tzAM10[]=PATHINFO_FILENAME;$M4teFM9=call_user_func_array("pathinfo",$M4tzAM10);Config::load($filename,$M4teFM9);goto M4txh;M4tldMhxi:M4txh:}M4tMEwq5:$query_object->set($GLOBALS[AAAA_A][0x0],dahuzi_search_analysis($query_object->query[$GLOBALS[AAAA_A][0x0]]));goto M4txf;M4tldMhxg:M4txf:}
本文原创,作者:阿龙,其版权均为龙腾求知社所有。
如需转载,请注明出处:https://blog.longtengwx.com/6872.html