• 27
  • 十一月

一个Wordpress中显示代码高亮的插件——wp-syntax

Kenami 发布于 15:38:17  |  阅读 302 次 |  评论  

以前用的代码高亮插件是:google-syntax-highlighter,因为博客更新了,也想找找有没有更好的代码高亮插件,看到用wp-syntax 的人比较多,所以就装个看看,总体感觉效果不错。

下面附上一些例子:
PHP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class NTLMSoapClient extends SoapClient {
	function __doRequest($request, $location, $action, $version) {
 
		$headers = array(
			'Method: POST',
			'Connection: Keep-Alive',
			'User-Agent: PHP-SOAP-CURL',
			'Content-Type: text/xml; charset=utf-8',
			'SOAPAction: "'.$action.'"',
		);
 
		$this->__last_request_headers = $headers;
		$ch = curl_init($location);
		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
		curl_setopt($ch, CURLOPT_POST, true );
		curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
		curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
		curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_NTLM);
		curl_setopt($ch, CURLOPT_USERPWD, $this->user.':'.$this->password);
		$response = curl_exec($ch);
 
		return $response;
	}
 
	function __getLastRequestHeaders() {
		return implode("\n", $this->__last_request_headers)."\n";
	}
}
 
// Authentification parameter
class MyServiceNTLMSoapClient extends NTLMSoapClient {
	protected $user = 'myuser';
	protected $password = '*******';
}


查看全文>>