WordPress插件开发注意事项

Using CURL Instead of HTTP API

WordPress comes with an extensive HTTP API that should be used instead of creating your own curl calls. It’s both faster and more extensive. It’ll fall back to curl if it has to, but it’ll use a lot of WordPress’ native functionality first.

Note: If using CURL in 3rd party vendor libraries, that’s permitted.

Data Must be Sanitized, Escaped, and Validated

When you include POST/GET/REQUEST/FILE calls in your plugin, it’s important to sanitize, validate, and escape them. The goal here is to prevent a user from accidentally sending trash data through the system, as well as protecting them from potential security issues.

  • SANITIZE: Data that is input (either by a user or automatically) must be sanitized as soon as possible. This lessens the possibility of XSS vulnerabilities and MITM attacks where posted data is subverted.

  • VALIDATE: All data should be validated, no matter what. Even when you sanitize, remember that you don’t want someone putting in ‘dog’ when the only valid values are numbers.

  • ESCAPE: Data that is output must be escaped properly when it is echo’d, so it can’t hijack admin screens. There are many esc_*() functions you can use to make sure you don’t show people the wrong data.

WordPress comes with a number of sanitization and escaping functions:

Remember: You must use the most appropriate functions for the context. If you’re sanitizing email, use sanitize_email(), if you’re outputting HTML, use esc_html(), and so on.

$body = wp_unslash( $_POST );
上一篇 ZenCart类库payment.php解读实现原理
下一篇 woocommerce plugin add_action always return -1
目录
文章列表
1 有赞前端组件库Vant
有赞前端组件库Vant
2
搭建nodejs代理服务器解决跨域问题
搭建nodejs代理服务器解决跨域问题
3
Flutter Widget之GridView
Flutter Widget之GridView
4
Groovy代码示例 - groovy包(package)的导入
Groovy代码示例 - groovy包(package)的导入
5
Java图片缩略图裁剪水印缩放旋转压缩转格式-Thumbnailator图像处理
Java图片缩略图裁剪水印缩放旋转压缩转格式-Thumbnailator图像处理
最新评论
一位WordPress评论者
一位WordPress评论者
2月12日
您好,这是一条评论。若需要审核、编辑或删除评论,请访问仪表盘的评论界面。评论者头像来自 Gravatar。