blakewilson/wp-enforce-semver

一个用于在WordPress插件中强制实施SemVer的类。

安装次数: 5,317

依赖者: 0

建议者: 0

安全: 0

星标: 10

关注者: 2

分支: 1

开放问题: 0

语言: TypeScript

3.0.1 2024-07-05 18:56 UTC

This package is auto-updated.

Last update: 2024-09-07 05:19:47 UTC


README

Screenshot of plugins list with Semantic Versioning for WordPress enabled

轻松地在您的WordPress插件中实施SemVer

使用此类,当插件的新版本为主要更新时,将禁用自动更新,并在插件的更新部分提供有用的通知,指出可能会有破坏性更改。

用法

  1. 通过composer将类作为依赖项安装
composer require blakewilson/wp-enforce-semver
  1. 在您的插件中初始化该类
// Init autoloader from Composer
if ( file_exists( plugin_dir_path( __FILE__ ) . 'vendor/autoload.php' ) ) {
	require plugin_dir_path( __FILE__ ) . 'vendor/autoload.php';
}

use EnforceSemVer\EnforceSemVer;

new EnforceSemVer('my-plugin/my-plugin.php');

就是这样!一旦您的最终用户安装了您的插件,他们将受到针对主要版本的自动更新的保护,并在插件列表中看到有用的消息,显示您的插件更新

Screenshot of plugins list with Semantic Versioning for WordPress enabled

此外,此通知文本可以通过过滤器进行修改

add_filter( 'semantic_versioning_notice_text', function($notice_text, $plugin_file_name) {
	// Modify notice text here.

	return $notice_text;
});