几款实用 Wordpress 插件

Posted by Allen on 2016-01-06
Coding

之前看到给朋友做网站的英国老爷爷装了一堆 Wordpress Plugin,正好手边有个项目把 Wordpress 当 REST API 来用,就小小研究下了装了下面这几个 Plugin:

  1. JSON API
  2. Magic Fields 2
  3. WP Super Cache
  4. Disable Google Fonts
  5. WP Acceleration for China
  6. WordPress Security Firewall
  7. WP-DBManager
  8. Disable Comments
  9. Disable All WordPress Updates
  10. Custom Dashboard Help
  11. Admin Dashboard Last Edits
  12. Admin Menu Editor

如果安装 Wordpress Plugin 提示权限不够需要输入 FTP 账号验证的话,可以 SSH 到 Server 上配置下权限,Apache 和 Nginx 的默认用户是 www-data,通过以下文件可以看到:

$ cat /etc/nginx/nginx.conf

或者:

$ ps -ef |grep apache2

我们要做的就是把 Wordpress 所在目录的所有权交给 www-data:

$ sudo chgrp -R www-data ./wordpress
$ sudo chown -R www-data:www-data ./wordpress

接下来,重启,使配置生效:

$ sudo service nginx restart

然后就发现终于可以愉快地玩耍啦!

1. JSON API

虽然 Wordpress 在 4.4 Clifford 开始把 REST API 纳入到 Core 中,但是我接触的时候用了 JSON API 这个插件。

This plugin was created at The Museum of Modern Art for the weblog Inside/Out, which is served from Ruby on Rails. Instead of reimplementing the site templates as a WordPress theme, we opted for a Rails front-end that displays content served from a WordPress back-end. JSON API provides the necessary interface for retrieving content and accepting comment submissions.

事实上我就是看了这段介绍才对 REST API 有初步的认识,使用非常简单,比如对一个刚装完的 Wordpress 发送 GET request http://localhost/wordpress/?json=1 会返回 JSON 如下:

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
36
37
38
39
40
41
42
43
44
{
"status": "ok",
"count": 1,
"count_total": 1,
"pages": 1,
"posts": [
{
"id": 1,
"type": "post",
"slug": "hello-world",
"url": "http:\/\/localhost\/wordpress\/?p=1",
"title": "Hello world!",
"title_plain": "Hello world!",
"content": "<p>Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!<\/p>\n",
"excerpt": "Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!\n",
"date": "2009-11-11 12:50:19",
"modified": "2009-11-11 12:50:19",
"categories": [],
"tags": [],
"author": {
"id": 1,
"slug": "admin",
"name": "admin",
"first_name": "",
"last_name": "",
"nickname": "",
"url": "",
"description": ""
},
"comments": [
{
"id": 1,
"name": "Mr WordPress",
"url": "http:\/\/wordpress.org\/",
"date": "2009-11-11 12:50:19",
"content": "<p>Hi, this is a comment.<br \/>To delete a comment, just log in and view the post's comments. There you will have the option to edit or delete them.<\/p>\n",
"parent": 0
}
],
"comment_count": 1,
"comment_status": "open"
}
]
}

Our old friend, in JSON format now. LOL. 我用了 NodeJS 的 Request middleware 去 call Wordpress 的 REST API 获取 JSON。

2. Magic Fields 2

强烈推荐 Magic Fields 2 这个插件,可以根据不同需求生成表单,主要是


Comments: