カスタムフィールドスニペットプラグインで、自分でスニペット追加できるようにしました。


Advanced Custom Fields のフィールド登録機能と似た仕組みです。自分が使いやすいスニペットを登録できます。
inc/class.phpにある、Tabdata クラスを継承して作ってください。(このプラグイン特有の設定を使うのではなく)PHP の機能であるオブジェクトの継承を活用するようにしています。
abstract class Tabdata {
protected $name;
protected $label;
abstract public function getdata();
final public function getname() {
if ('' != $this->name) {
return $this->name;
} else {
return get_called_class();
}
}
final public function getlabel() {
if ('' != $this->label) {
return $this->label;
} else {
return $this->getname();
}
}
}
getdataメソッドで、実際に出力するスニペットを定義してください。詳細は inc/class.php の Defaulttabクラスを参考にしてください。
自分で作ったスニペットを登録するには、register_cfs_tabs関数を使います。
if (function_exists('register_cfs_tabs')) {
register_cfs_tabs('CLASS NAME HERE');
}
といった記述を、テーマの functions.php や自作プラグイン等に追加してください。