stoutlogic / local-wordpress-theme-repository
用于设置本地wordpress主题包仓库以进行开发或生产
Requires
- composer-plugin-api: ^1.0
This package is auto-updated.
Last update: 2024-09-06 16:17:14 UTC
README
Composer 插件
此 Composer 插件的目的是让您能够轻松设置和维护本地文件系统上的本地 composer 仓库,以便能够将 wordpress 主题包要求添加到您的根站点包中,允许您运行 composer install
或 composer update
,并将该主题符号链接到 wp-content/themes
并管理任何主题依赖项。
这在开发中非常有用,这样您就可以将主题开发与 wordpress 环境分开。您可以在不破坏主题的情况下删除 wordpress 安装。
在服务器上,如果只部署主题,这也很有用。特别是如果您执行滚动部署,您可以将本地 wordpress 主题仓库的位置设置为符号链接的“当前”主题部署路径。
安装
要安装此 composer 插件,只需在您的 composer.json 文件中引用它
"require": { ... "stoutlogic/local-wordpress-theme-repository": "^1.0", ... }
或运行
composer require stoutlogic/local-wordpress-theme-repository
使用
此插件提供了 3 个脚本:init-theme、change-theme-name 和 change-theme-version
init-theme
composer run-script init-theme
这是应该首先执行的命令。它将引导您完成设置本地主题仓库的步骤。它将询问一系列输入。默认值将在 [方括号] 中显示,您可以按回车键接受默认值。
Package name of the theme you wish to init [stoutlogic/understory-theme]:
Relative path of the theme package is or will be located [./theme]:
Relative path to the WordPress themes directory [wp-content/themes]:
然后您将被要求输入 WordPress 安装的主题目录的相对路径
Relative path to the WordPress themes directory [wp-content/themes]:
如果找不到主题包,如果您可以从 Packagist 下载它,您将有机会下载。键入 y 或 yes 以执行此操作,默认行为是不下载
Download stoutlogic/understory-theme using `composer create-project --no-install` [n]?
如果您不这样做,请手动在指定路径中复制、下载或创建主题。请确保在主题的 composer.json 文件中设置了版本。如果没有,您可以手动添加它。确保它与站点 composer.json 文件中要求的版本相匹配,并运行 composer update
重新运行 init-theme 脚本可能更容易。它将默认从您的主题和站点 composer.json 文件中提取已设置的值,因此应该很快完成。
change-theme-name
composer run-script change-theme-name
如果您在站点或主题 composer.json 中指定的名称不同,或者如果您想轻松地更改两者,只需运行 change-theme-name 脚本来更改即可。
change-theme-version
composer run-script change-theme-version
与 change-theme-name 脚本类似,如果您在站点或主题 composer.json 中指定的版本不同,或者如果您想轻松地更改两者,只需运行 change-theme-version 脚本来更改即可。