插件开发文档

什么是插件?

💡 云策文档标注

概述

插件是扩展WordPress核心功能的代码包,通常由PHP代码和其他资源(如图像、CSS和JavaScript)组成。通过创建插件,开发者可以在WordPress基础上构建额外功能,例如显示最新文章链接或创建完整的支持票务系统。

关键要点

  • 插件是扩展WordPress功能的代码包,主要基于PHP,并可包含图像、CSS和JavaScript等资源。
  • 插件可以简单如Hello Dolly(仅100行代码),也可以复杂如支持自定义文章类型、电子邮件通知和客户门户的系统。
  • 插件至少需要一个主文件,其中包含特定格式的DocBlock头信息,但通常由多个文件组成。
  • 作为WordPress.org插件作者,开发者有机会创建被数百万用户安装和使用的插件,Plugin Handbook提供相关帮助。

📄 原文内容

Plugins are packages of code that extend the core functionality of WordPress. WordPress plugins are made up of PHP code and can include other assets such as images, CSS, and JavaScript.

By making your own plugin you are extending WordPress, i.e. building additional functionality on top of what WordPress already offers. For example, you could write a plugin that displays links to the ten most recent posts on your site.

Or, using WordPress’ custom post types, you could write a plugin that creates a full-featured support ticketing system with email notifications, custom ticket statuses, and a client-facing portal. The possibilities are endless!

Most WordPress plugins are composed of many files, but a plugin really only needs one main file with a specifically formatted DocBlock in the header.

Hello Dolly, one of the first plugins, is only 100 lines long. Hello Dolly shows lyrics from the famous song in the WordPress admin. Some CSS is used in the PHP file to control how the lyric is styled.

As a WordPress.org plugin author, you have an amazing opportunity to create a plugin that will be installed, tinkered with, and loved by millions of WordPress users. All you need to do is turn your great idea into code. The Plugin Handbook is here to help you with that.