wpbp/generator

Wordpress 插件样板代码生成器

1.3.9 2024-02-06 16:09 UTC

README

License Downloads Codacy Badge

此生成器(基于PHP)解析 WordPress 插件样板代码 并移除你不需要的内容。

要求

让我们看看你需要什么以及如何安装它

Debian/Ubuntu

sudo apt install php php-zip php-mbstring php-yaml

Fedora/Centos

sudo dnf install php php-zip php-mbstring php-yaml

Mac OS

brew install pkg-config zlib pecl install zip mbstring yaml (来源:https://grrr.tech/posts/installing-homebrew-php-extensions-with-pecl)

安装

您可以从 这里 下载 phar 版本,或者选择使用 composer 安装

composer global require wpbp/generator:dev-master

将此目录添加到您的 ~/.bash_profile(或 ~/.bashrc)中的 PATH,如下所示

export PATH=~/.composer/vendor/bin:$PATH

执行

wpbp-generator --help 获取命令列表

--dark
     Use a dark theme for console output.

--dev
     Download from the master branch (the development version).

--help
     Show the help page for this command.

--json
     Generate a wpbp.json file in the current folder. Suggested to use the WordPress plugin folder.

--no-download
     Do you want to execute composer and npm manually? This is your flag!

--verbose
     Verbose output. Because this can be helpful for debugging!

wpbp.json

文件 包含所有将用于脚手架的默认变量。

  • plugin/author 部分包括 WordPress 插件标准的插件名称,以及每个文件中的注释部分
  • public-assets 部分包括前端代码,用于 注册 CSS 和 JS 文件
  • act-deact 部分包括插件本身 激活/停用 的代码和 uninstall.php 文件
  • admin-assets 部分包括后端代码,用于 注册 CSS 和 JS 文件settings 适用于插件设置页面,admin 适用于后端其余部分,admin-page 添加一个新的设置插件页面
  • ajax 部分添加了 WordPress Ajax 系统的代码,用于 登录/未登录用户
  • git-repo 在创建的文件夹中自动执行 git init
  • block 添加了对自定义块的支持,grumphp 添加了对 GrumPHPphpstan 的支持
  • phpcs/phpstan 为这些工具启用了预定义的设置和规则集
  • unit-test 添加了 tests 文件夹和 codeception.dist.yml 文件,其中包含有关 Codeception 的 composer 各种包
  • wpcli 在插件代码中添加了对 WP-CLI 工具 的支持
  • language-files 添加了 po/mo 文件和加载自定义语言文件的代码
  • libraries 包含所有将随样板代码一起下载的 composer 包以及相关的示例代码,移除它们将不会添加它们
  • 片段分布在各个子部分中,根据WordPress的各种需求集成特定代码片段,删除它们不会添加它们