[WP Plugin Dev] WordPress プラグイン開発の定石を探る
WordPress プラグイン開発の定石を探ってみた。memo.
[markdown]
## Boilerplate
いくつかソースをのぞいてみましたが、ディレクトリ構成や命名規則などはバラバラでした。
特に規約はなさそうで自由に作っているよう。
– jetpack
– table-of-contents-plus
– wp-paginavi
Boilerplate やフレームワークと呼ばれているものがいくつかあるよう。
ディレクトリ構成などは Hatamoto がシンプルで取っつきやすい。
> * [megumiteam/hatamoto: Grunt template for WordPress plugin.](https://github.com/megumiteam/hatamoto)
> * [DevinVinson/WordPress-Plugin-Boilerplate: [WordPress] A foundation for WordPress Plugin Development that aims to provide a clear and consistent guide for building your plugins.](https://github.com/DevinVinson/WordPress-Plugin-Boilerplate)
> * [getherbert/herbert: The WordPress Plugin Framework:](https://github.com/getherbert/herbert)
## View template
既存プラグインでも HTML がべた書きしてありました。
個人的には据わりが悪いので View に分割したい。
こちらのスライド「[WordPressプラグイン作成入門](https://www.slideshare.net/yuka2py/wordpress-15359306)」で、普通に [include()](http://php.net/manual/ja/function.include.php) されていて参考になりました。
いろいろ分かりやすい。
> * [include()とrequire()の違い | PHP入門編](http://wp-p.info/tpl_rep.php?cat=php-biginner&fl=r14)
## Class
あるかなと思って探したら、そのものズバリがあって参考になります。
> * [WordPressプラグインをクラス定義する方法 | Developers.IO](http://dev.classmethod.jp/server-side/wordpress-plugin-classdef/)
## Form
管理画面の入力フォームで利用する WordPress 関数のサンプル。
> * [【WordPressプラグイン開発】独自設定ページでオプションを追加・変更する方法 | はぴすぷ](http://hapisupu.com/2015/11/wordpress-plugin-create-03/)
## Settings API
こちらを読んでいてフォーム作りが大変そうだなと思っていたら、Settings API というものがあるとか。
売り上げランキング: 60,529
知りたかったのはこっちだったかも。
> * [Settings API – WordPress Codex 日本語版](http://wpdocs.osdn.jp/Settings_API)
> * [WordPressの管理画面に独自のオプション保存をするためのSettings APIの使い方 – Shinichi Nishikawa’s](https://nskw-style.com/2014/wordpress/settings-api.html)
## 補遺
> * [WordPressのプラグインを開発しよう(初級編) | webOpixel](http://www.webopixel.net/wordpress/631.html)
> * [WordPressでオリジナルのデータベース(テーブル)を作成する [プラグイン開発中級編] | webOpixel](http://www.webopixel.net/wordpress/637.html)
> * [ASCII.jp:これなら作れる!WordPressプラグイン開発に役立つ記事まとめ](http://ascii.jp/elem/000/001/188/1188582/)
[/markdown]