标题要求

如入门中所述,主 PHP 文件应包含标头注释,告诉 WordPress 该文件是一个插件并提供有关该插件的信息。

最小字段

标头注释至少必须包含插件名称:

/*
 * Plugin Name: YOUR PLUGIN NAME
 */

标头字段

可用的标头字段:

带有标题注释的有效 PHP 文件可能如下所示:

/*
 * Plugin Name:       My Basics Plugin
 * Plugin URI:        https://example.com/plugins/the-basics/
 * Description:       Handle the basics with this plugin.
 * Version:           1.10.3
 * Requires at least: 5.2
 * Requires PHP:      7.2
 * Author:            John Smith
 * Author URI:        https://author.example.com/
 * License:           GPL v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Update URI:        https://example.com/my-plugin/
 * Text Domain:       my-basics-plugin
 * Domain Path:       /languages
 */

这是另一个允许文件级 PHPDoc DocBlock 以及 WordPress 插件文件头的示例:

/**
 * Plugin Name
 *
 * @package           PluginPackage
 * @author            Your Name
 * @copyright         2019 Your Name or Company Name
 * @license           GPL-2.0-or-later
 *
 * @wordpress-plugin
 * Plugin Name:       Plugin Name
 * Plugin URI:        https://example.com/plugin-name
 * Description:       Description of the plugin.
 * Version:           1.0.0
 * Requires at least: 5.2
 * Requires PHP:      7.2
 * Author:            Your Name
 * Author URI:        https://example.com
 * Text Domain:       plugin-slug
 * License:           GPL v2 or later
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * Update URI:        https://example.com/my-plugin/
 */

笔记

为项目分配版本号时,请记住 WordPress 使用 PHP version_compare() 函数来比较插件版本号。因此,在发布新版本的插件之前,您应该确保该 PHP 函数认为新版本比旧版本“更好”。例如,1.02 实际上大于 1.1。

 

 


版本号 #1
由 Vcanson 创建于 15 九月 2023 15:21:03
由 Vcanson 更新于 26 九月 2023 15:34:10