プラグインCustom Post Type UIのcptui_below_post_type_tab_menuアクションの使用方法・解説

概要

cptui_below_post_type_tab_menuは、WordPressのプラグインCustom Post Type UIにおけるアクションフックです。このフックは、カスタム投稿タイプのタブメニューの下に独自のコンテンツを追加するために使用されます。これを使うことで、管理画面でのユーザーインターフェースを拡張し、特定の設定や機能を追加することが可能となります。

よく使われる機能

  1. カスタムメタボックスの追加
  2. カスタム設定オプションの表現
  3. ユーザー向けのカスタム情報の表示
  4. プラグイン設定のリンク追加
  5. ヘルプ情報の追加
  6. 専用ショートコードの実行結果を表示

構文

add_action('cptui_below_post_type_tab_menu', 'custom_function_name');

パラメータ

  • なし

戻り値

  • なし

プラグインバージョン

  • Custom Post Type UI: 1.0以上(バージョンに依存する可能性があります)

WordPressバージョン

  • WordPress: 4.0以上(バージョンに依存する可能性があります)

この関数のアクションでの使用可能性

アクション 使用例
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

サンプルコード

サンプル1: カスタムメタボックスの追加

このコードは、カスタム投稿タイプの管理画面にカスタムメタボックスを追加します。

add_action('cptui_below_post_type_tab_menu', 'add_custom_metabox');

function add_custom_metabox() {
    echo '<div class="custom-metabox">This is a custom metabox!</div>';
}

引用元: https://developer.wordpress.org/reference/functions/add_action/

サンプル2: 設定オプションの追加

このコードは、特定の設定オプションを管理画面に追加します。

add_action('cptui_below_post_type_tab_menu', 'display_custom_settings_link');

function display_custom_settings_link() {
    echo '<a href="options-general.php?page=custom-settings">Custom Settings</a>';
}

引用元: https://codex.wordpress.org/Function_Reference/add_action

サンプル3: ヘルプ情報の表示

このコードは、管理画面にヘルプ情報を表示するためのものです。

add_action('cptui_below_post_type_tab_menu', 'add_help_info');

function add_help_info() {
    echo '<p>ここにヘルプ情報を記載します。</p>';
}

引用元: https://wordpress.stackexchange.com/questions/40598/how-can-i-add-custom-help-text-to-the-edit-screen

サンプル4: ショートコードの実行

このコードは、特定のショートコードを実行し、その結果を表示します。

add_action('cptui_below_post_type_tab_menu', 'execute_shortcode');

function execute_shortcode() {
    echo do_shortcode('[your_shortcode]');
}

引用元: https://developer.wordpress.org/reference/functions/do_shortcode/

サンプル5: カスタムスタイルの追加

このコードは、タブメニューの下にカスタムスタイルを適用します。

add_action('cptui_below_post_type_tab_menu', 'add_custom_styles');

function add_custom_styles() {
    echo '<style>.custom-tab { background-color: #f9f9f9; }</style>';
}

引用元: https://developer.wordpress.org/reference/functions/wp_enqueue_style/

この関数について質問する


上の計算式の答えを入力してください