官术网_书友最值得收藏!

The main concepts behind the Wall plugin

Before we start with our plugin, let's take a moment and create a design outline covering the main areas of the plugin.

  • Widget: Obviously, the first thing on our list is to create a sidebar area for the wall. We will use WordPress widget API to do that.
  • Wall Comments: We will store the user comments in the WordPress database.
  • Comment Management: The administrator needs to be able to access comments, and approve, disapprove, or delete them.
  • Security and Spam protection: Being on the front page and on most other pages of our site, the wall is exposed to various threats. We need to think of a way to protect our blog from unwanted spam.
  • Options and Styling: Last but not least, we want to be able to customize the look of the widget. Since the wall will be constrained within a relatively small area (the sidebar), we need to carefully plan the look and the functionality of the widget.

The main development concerns here are the management of comments, and spam protection.

A typical PHP approach to address these concerns would be:

  1. Create a database to store the comments in.
  2. Create an administrative backend with comment management functionality.
  3. Implement a set of rules for combating spam, such as black lists, user IP bans, and so on.

It is obvious that this approach needs a long development time. On the other hand, this is a book about WordPress, which is arguably the best blogging platform in the world today. Blogging includes a lot of commenting, and WordPress already features one of the most advanced commenting engines available. So why just not take advantage of it?

The main principle behind our idea is to dedicate a WordPress page as a place holder for all user comments. This allows us to use the WordPress commenting engine to take care of most of the hard work, such as adding the comments, administrative management and best of all—spam protection.

WordPress already comes with built-in comment spam and flood protection.

The main concepts behind the Wall plugin

There are also a number of popular anti-spam plugins such as Akismet that deal with the problem of spam in the comments. So instead of reinventing the wheel, we will leave these dedicated plugins to do the job.

By using built-in WordPress functionalities whenever we can, we also provide the opportunity for the plugin to develop itself automatically with the development of WordPress. For example, if the next version of WordPress brings comment editing in a super cool 3D way, all comments for our widget will become editable in the same way automatically.

This will allow us to spend more time focusing on other areas of the widget—like deciding which jQuery effects we can use to make it more attractive.

Tip

Use built-in WordPress functionalities whenever you can. Try to think outside of the box and find features of WordPress that can help you with your plugin. Always try to find fresh ways to re-use the code that a large community of WordPress developers has already contributed. It saves time and gets you free upgrades.

主站蜘蛛池模板: 库伦旗| 尚志市| 蒙阴县| 边坝县| 桐柏县| 容城县| 红原县| 肇东市| 公安县| 万宁市| 三亚市| 冀州市| 上犹县| 岳西县| 临朐县| 榆中县| 太仆寺旗| 柳江县| 体育| 大城县| 泽州县| 本溪| 文安县| 屯门区| 西宁市| 永和县| 格尔木市| 加查县| 南澳县| 慈溪市| 棋牌| 华阴市| 汉川市| 阜阳市| 达日县| 丹江口市| 贵溪市| 故城县| 犍为县| 高平市| 三河市|