説明
HameThreadは、大掛かりな設定なしにWordPressをスレッド形式のQ&Aフォーラム/サポートデスクに変えます。各トピックはthread投稿として作成され、返信は通常のWordPressコメントとして扱われるため、モデレーション、権限グループ、REST APIについてすでにご存知の知識がそのまま活用できます。
一般的なフォーラムにはない強みがあります:
- WooCommerce商品サポート — 商品ページに「サポートを受ける」ボタンを表示し、購入者からの質問をマイアカウント内でスレッドとして収集します。
- 非公開スレッド — 投稿者、招待されたユーザー、編集者のみが読めるスレッドを開けます。有料サポートや機密性の高いサポートに最適です。
- ベストアンサー — 質問を解決した返信をマークし、スレッド全体を解決済みとしてフラグ付けします。
- ブロックファースト — 任意のページにスレッドボタンブロックを配置するだけで、訪問者がスレッドを開始できます。テンプレート編集もコードも不要です。
機能
topicタクソノミーを持つthread投稿タイプ- AJAX/REST投稿によるコメントベースの返信(ページ全体のリロード不要)
- ベストアンサー&解決済み/未解決ステータス
- 権限チェック付きの非公開スレッド
- 一定期間動きがないスレッドの自動クローズ
- コメントへの評価機能
- スレッド購読者へのメール通知
- SEO向けのJSON-LD(
QAPage)構造化データ - WooCommerceのマイアカウントサポートページと商品ごとのサポートボタン
- 任意の公開投稿タイプでコメントスレッドを有効化可能
- 設定 ディスカッションの管理画面設定(一般的な調整はコード不要)
カスタマイズ
一般的な設定は設定 ディスカッションから行えます:
- スレッドの説明
- ユーザーが非公開スレッドを開始できるようにする
- HameThread形式のコメントスレッドを有効にする投稿タイプ
その他の項目もすべてフィルターで変更可能です。下記の開発者向け情報をご覧ください。
開発者向け情報
返信は標準のWordPressコメント、スレッドは標準の投稿タイプなので、コアのフックがそのまま使えます。さらにHameThreadは多くのフィルター/アクションを公開しています。特に便利なものは以下の通りです:
Hook
Type
Purpose
hamethread_before_thread_form / hamethread_after_thread_form
action
Add markup/fields to the thread form
hamethread_new_thread_post_params
filter
Register extra REST parameters for new threads
hamethread_new_thread_post_arg
filter
Modify the post array before a thread is inserted
hamethread_new_thread_validation
filter
Add validation errors (WP_Error)
hamethread_new_thread_inserted
action
React after a thread is created
hamethread_before_comment_form / hamethread_after_comment_form
action
Add markup/fields to the comment form
hamethread_new_comment_params
filter
Modify comment data before insert
hamethread_default_subscribers / hamethread_subscribers
filter
Control who is notified
hamethread_user_can_start_private_thread
filter
Allow private threads
hamethread_user_can_comment / hamethread_user_can_post
filter
Capability checks
hamethread_dynamic_comment_post_types
filter
Post types that get comment threads
hamethread_post_setting / hamethread_post_type / hamethread_taxonomy
filter
Customize the post type & taxonomy
hamethread_template
filter
Override template parts
例 — スレッドフォームにフィールドを追加して保存する:
// 1. Render the field.
add_action( 'hamethread_after_thread_form', function ( $args, $default ) {
if ( $args['post'] ) {
return; // Only on new threads.
}
echo ' Notify staff';
}, 10, 2 );
// 2. Register the REST parameter.
add_filter( 'hamethread_new_thread_post_params', function ( $params ) {
$params['notify_staff'] = [ 'type' => 'integer', 'default' => 0 ];
return $params;
} );
// 3. React after the thread is created.
add_action( 'hamethread_new_thread_inserted', function ( $post_id, $request ) {
if ( $request->get_param( 'notify_staff' ) ) {
// notify…
}
}, 10, 2 );
例 — post投稿タイプでコメントスレッドを有効にする:
add_filter( 'hamethread_dynamic_comment_post_types', function ( $post_types ) {
$post_types[] = 'post';
return $post_types;
} );
フックの完全な一覧はソースコードにあります。app/ディレクトリとGitHubリポジトリをご覧ください。
ブロック
このプラグインは1個のブロックを提供します。
- Thread Button Display a button that lets users start a new thread or support topic.
インストール
- プラグインを
wp-content/plugins/hamethreadにアップロード(またはプラグイン画面からインストール)して有効化してください。 - 設定 ディスカッションで必要な投稿タイプとオプションを選択してください。
- 任意のページや投稿にスレッドボタンブロックを追加すると、訪問者がスレッドを開始できます。テンプレートから
hamethread_button()を呼び出すこともできます。 - スレッドは
threadアーカイブ(例:/thread/)に一覧表示されます。
WooCommerceは任意です。有効化されている場合、マイアカウントにサポートタブが追加され、商品ページにサポートボタンを表示できます。
FAQ
-
訪問者にスレッドを開始してもらうにはどうすればよいですか?
-
ページにスレッドボタンブロックを追加するか、テンプレート内で
hamethread_button( $parent_id, $label )を呼び出してください。このボタンはREST APIを使ったスレッドフォームを開きます。 -
スレッドだけでなく、投稿やカスタム投稿タイプでも使用できますか?
-
はい。設定 ディスカッション スレッドコメントで必要な投稿タイプにチェックを入れるか、
hamethread_dynamic_comment_post_typesフィルターを使用してください。 -
WooCommerceは必須ですか?
-
いいえ。WooCommerce連携はWooCommerceが有効な場合にのみ自動的に有効になります。それ以外の場合は、単体のフォーラムとして動作します。
-
フォーム、バリデーション、通知はどのようにカスタマイズできますか?
-
HameThreadは多数のフィルターとアクションを公開しています。開発者向け情報をご覧ください。
評価
このプラグインにはレビューがありません。
貢献者と開発者
変更履歴
2.1.0
- ブロックエディター用のスレッドボタンブロックを追加。
- スレッドの説明、非公開スレッド、コメント対応投稿タイプを設定する画面(設定 ディスカッション)を追加。
- WordPress.org Plugin Check準拠のため、エスケープ・国際化・コーディング規約を改善。
2.0.0
- Twitter BootstrapとFontAwesomeへの依存を削除。
- JavaScriptをモダン化。
1.2.0
- PHPの最小バージョンを7.4に引き上げ。
1.1.0
- 構造化データを追加。
- ベストアンサー機能を追加。
1.0.0
- 初回リリース。
すべての変更履歴はGitHub Releasesをご覧ください。
