[WP Plugin Dev] Hatamoto vs wp scaffold plugin

memo.

該当するバージョン。

Hatamoto 97a2f0b343b85e9f7a0b4aff463a4972f338ea69
WP-CLI 1.2.1
VCCW 3.3.2

Contents

Hatamoto

テンプレートを生成する

wordpress/wp-content/plugins/sandbox-hatamoto で実行します。
megumiteam/hatamoto でテンプレートを生成します。
空のディレクトリですが Warning がいろいろでるので --force インストール。

% grunt-init hatamoto --force
Running "init:hatamoto" (init) task
This task will create one or more files in the current directory, based on the
environment and the answers to a few questions. Note that answering "?" to any
question will show question-specific help and answering "none" to most questions
will leave its value blank.
Warning: Existing files may be overwritten! Used --force, continuing.
    :
Please answer the following:
[?] Name of the plugin. (Sandbox Hatamoto)
[?] PHP function prefix (alpha and underscore characters only) (sandbox_hatamoto)
[?] Version of the WordPress that your plugin requires. (4.8)
[?] A brief description of the Plugin. (This is a awesome cool plugin.)
[?] Contributor should be a list of wordpress.org userid's. (DriftwoodJP)
[?] URI of page describing plugin and updates. (https://example.com)
[?] Your name. (Foo Bar)
[?] URI of the plugin author. (https://example.com)
[?] Type of source code repository. (git)
[?] URI of source code repository. (https://github.com/DriftwoodJP/sandbox-hatamoto)
[?] License (GPLv2)
[?] License URI (http://www.gnu.org/licenses/gpl-2.0.html)
[?] Using admin panel? "yes" or "no". (yes)
[?] Will you use "Sass", "LESS", or "none" for CSS with this project? (Sass)
[?] Will you use Composer with this project? "yes" or "no". (yes)
[?] Do you need to make any changes to the above before continuing? (y/N) n
Initialized from template "hatamoto".
Done, but with warnings.

初期インストールだけすませます。

% npm install
% composer install

wp-cli でテストサンプルを生成する

VCCW v3 にログイン。

% vagrant ssh

PHPUnit のサンプルコードを生成します。

$ cd /var/www/html
$ wp scaffold plugin-tests sandbox-hatamoto

プラグインを有効化する

プラグインを有効化します。

$ wp plugin activate sandbox-hatamoto
Plugin 'sandbox-hatamoto' activated.
Success: Activated 1 of 1 plugins.

「管理画面>設定>Sandbox Hatamoto」に Admin Panel が表示されます。

WP-CLI

テンプレートを生成する

VCCW v3 にログイン。

% vagrant ssh

PHPUnit のサンプルコードを生成します。

$ cd /var/www/html/wp-content/plugins
$ wp scaffold plugin sandbox-hatamoto
Success: Created plugin files.
Success: Created test files.

プラグインを有効化する

プラグインを有効化します。

$ wp plugin activate sandbox-hatamoto
Plugin 'sandbox-hatamoto' activated.
Success: Activated 1 of 1 plugins.