插件介紹

Pure-Highlightjs一個(gè)基于Highlightjs實(shí)現(xiàn)的WordPress代碼高亮插件,此次分享的是仿mac風(fēng)格代碼塊,支持代碼一鍵全選、復(fù)制功能,滿足用戶所需,支持 N 多種語言高亮,還提供多種主題兼容適配。支持在 WordPress 可視化編輯模式下插入代碼。

插件優(yōu)勢

Pure Highlightjs 這個(gè)插件經(jīng)過精簡目前只有0.5 MB,非常小巧,基本不會(huì)給網(wǎng)站加載帶來多余的負(fù)載。

插件演示

//Wordpress 文章關(guān)鍵詞自動(dòng)內(nèi)鏈

function tag_sort($a, $b){

	if ( $a->name == $b->name ) return 0;

	return ( strlen($a->name) > strlen($b->name) ) ? -1 : 1;

}

function tag_link($content){

	$match_num_from = 1;	//一個(gè)標(biāo)簽少于幾次不鏈接

	$match_num_to = 1;	//一個(gè)標(biāo)簽最多鏈接幾次

	$posttags = get_the_tags();

	if ($posttags) {

		usort($posttags, "tag_sort");

		foreach($posttags as $tag) {

			$link = get_tag_link($tag->term_id);

			$keyword = $tag->name;

			//鏈接代碼

			$cleankeyword = stripslashes($keyword);

			$url = "<a href="$link" title="".str_replace('%s',addcslashes($cleankeyword, '$'),__('更多關(guān)于 %s 的文章')).""";

			$url .= ' target="_blank"';

			$url .= ">".addcslashes($cleankeyword, '$')."</a>";

			$limit = rand($match_num_from,$match_num_to);

			//不鏈接代碼

			$content = preg_replace( '|(<a[^>]+>)(.*)<pre.*?>('.$ex_word.')(.*)</pre>(</a[^>]*>)|U'.$case, '$1$2%&&&&&%$4$5', $content);

			$content = preg_replace( '|(<img)(.*?)('.$ex_word.')(.*?)(>)|U'.$case, '$1$2%&&&&&%$4$5', $content);

			$cleankeyword = preg_quote($cleankeyword,''');

			$regEx = ''(?!((<.*?)|(<a.*?)))('. $cleankeyword . ')(?!(([^<>]*?)>)|([^>]*?</a>))'s' . $case;

			$content = preg_replace($regEx,$url,$content,$limit);

			$content = str_replace( '%&&&&&%', stripslashes($ex_word), $content);

		}

	}

	return $content;

}

add_filter('the_content','tag_link',1);







 

 

 

安裝說明

1、安裝

進(jìn)入 WordPress 后臺(tái)管理頁面, 插件 > 安裝插件 > 上傳插件 ,上傳剛才下載的 ZIP 文件,然后安裝。

或者解壓安裝包,上傳到插件目錄 /wp-content/plugins/

2、啟用

安裝完畢后,在已經(jīng)安裝的插件里啟用 “Pure Highlightjs”

使用說明

1、編輯器可視化插入代碼

2、Pure Highlightjs 后臺(tái)進(jìn)入設(shè)置選項(xiàng)

3、Pure Highlightjs 選擇代碼高亮樣式“Coy”

聲明:本站所有資源由用戶發(fā)布分享以及互聯(lián)網(wǎng)轉(zhuǎn)載,只作為宣傳購買原版的參考,版權(quán)爭議與本站無關(guān);如果你有什么不錯(cuò)的資源,也可以提供給本站免費(fèi)幫你發(fā)布宣傳;本站不對(duì)任何資源負(fù)法律責(zé)任以及索取相關(guān)費(fèi)用,您若發(fā)現(xiàn)本站侵犯了你的版權(quán)利益,請(qǐng)聯(lián)系本站刪除處理!謝謝!