概要
cptui_below_post_type_select
フィルタは、WordPress の Custom Post Type UI プラグインで利用できるフィルタです。このフィルタは、カスタム投稿タイプを選択するセレクトボックスの下に追加の内容を挿入したり変更したりするために使用されます。このフィルタは、管理画面でカスタム投稿タイプを設定する際にカスタマイズが必要な場面でよく使用されます。
よく使われる機能
- 管理画面にてカスタムフィールドの説明文を追加。
- 特定のカスタム投稿タイプに関する注意事項の表示。
- ユーザーへのガイドラインメッセージの追加。
- カスタム投稿タイプ選択時の説明テキストを表示。
- プラグイン独自の設定オプションの説明追加。
- 開発者向けのヒントやショートコードの説明を提供。
フィルタの概要
- 構文:
add_filter( 'cptui_below_post_type_select', 'your_function_name' );
- パラメータ:
string $content
: デフォルトのコンテンツ。
- 戻り値: 変更後のコンテンツ。
- 使用可能なプラグインバージョン: Custom Post Type UI 1.0 〜 最新版
- 使用可能なWordPressバージョン: WordPress 4.0 〜 最新版
サンプルコード
サンプルコード 1
add_filter( 'cptui_below_post_type_select', 'add_custom_field_description' );
function add_custom_field_description( $content ) {
$content .= '<p>カスタムフィールドの設定を行うことができます。</p>';
return $content;
}
このコードは、カスタム投稿タイプのセレクトボックス下に「カスタムフィールドの設定を行うことができます。」という説明文を追加します。
サンプルコード 2
add_filter( 'cptui_below_post_type_select', 'add_custom_note' );
function add_custom_note( $content ) {
$content .= '<p>注意: カスタム投稿タイプは必要に応じて管理してください。</p>';
return $content;
}
このコードは、セレクトボックスの下に「注意: カスタム投稿タイプは必要に応じて管理してください。」という注意文を表示します。
サンプルコード 3
add_filter( 'cptui_below_post_type_select', 'add_guideline_message' );
function add_guideline_message( $content ) {
$content .= '<p>ヒント: 画像サイズは1200px x 800pxが推奨です。</p>';
return $content;
}
このコードは、「ヒント: 画像サイズは1200px x 800pxが推奨です。」というガイドラインメッセージを追加します。
サンプルコード 4
add_filter( 'cptui_below_post_type_select', 'add_shortcode_info' );
function add_shortcode_info( $content ) {
$content .= '<p>ショートコード: [custom_post] を使用して、この投稿タイプを表示できます。</p>';
return $content;
}
このコードは、ショートコードに関する情報を提供し、使用方法を簡潔に説明します。
サンプルコード 5
add_filter( 'cptui_below_post_type_select', 'add_plugin_setting_explanation' );
function add_plugin_setting_explanation( $content ) {
$content .= '<p>この設定は、プラグインの機能を拡張するために重要です。</p>';
return $content;
}
このコードは、プラグインの設定に関連する重要な情報を示します。
この関数のアクションでの使用可能性
アクション | 使用可能 |
---|---|
mu_plugin_loaded | |
registered_post_type | |
plugins_loaded | |
wp_roles_init | |
setup_theme | |
after_setup_theme | |
set_current_user | |
init | |
register_sidebar | |
wp_loaded | |
send_headers | |
parse_query | |
pre_get_posts | |
wp | |
template_redirect | |
get_header | |
wp_head |
この表は、cptui_below_post_type_select
フィルタが各アクションで使用可能かどうかを示しています。