From 0e204455fa116cf47fac76d2db486d47600a34cf Mon Sep 17 00:00:00 2001 From: mtdkei Date: Thu, 24 Oct 2024 12:20:21 +0900 Subject: [PATCH 01/10] Add get_help_notice() function to display help notices based on locale --- .../package/class.post-type-manager.php | 90 +++++++++++++++---- 1 file changed, 73 insertions(+), 17 deletions(-) diff --git a/inc/post-type-manager/package/class.post-type-manager.php b/inc/post-type-manager/package/class.post-type-manager.php index 45076d46..59224e8d 100644 --- a/inc/post-type-manager/package/class.post-type-manager.php +++ b/inc/post-type-manager/package/class.post-type-manager.php @@ -57,6 +57,55 @@ public static function add_cap_post_type_manage() { $role->add_cap( 'publish_others_' . $post_type_name . 's' ); } + /** + * ヘルプ通知 + * + * @return string + */ + public static function get_help_notice() { + // サイトの言語が日本語 (ja) であるかどうかを判定 + if ( get_locale() !== 'ja' ) { + return ''; // 日本語以外の場合は何も返さない + } + + $dismiss_url = esc_url( + wp_nonce_url( + add_query_arg('vkblocks-dismiss-pro', 'dismiss_admin_notice'), + 'vkblocks-dismiss-pro-' . get_current_user_id() + ) + ); + + // ヘルプ通知のHTMLを生成して返す + return wp_kses_post( + '
+

' . __( 'Help and Documentation', 'vk-all-in-one-expansion-unit' ) . ': ' . __( 'Learn more about custom post type settings by visiting the following resources:', 'vk-all-in-one-expansion-unit' ) . '

+ +

' . esc_html__( 'Dismiss this notice', 'vk-blocks' ) . '

+
' + ); + } + + /** + * Display help notice on specific page + * + * @return void + */ + public static function display_help_notice() { + // 現在のページを取得 + global $pagenow; + + // 特定のページのみ通知を表示する + if ($pagenow === 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] === 'post_type_manage') { + // 通知のHTMLを取得して表示 + echo self::get_help_notice(); + } + + } + /******************************************* * カスタムフィールドの meta box を作成. */ @@ -70,11 +119,15 @@ public static function add_meta_box() { * @return void */ public static function add_meta_box_action() { + global $post; // CSRF対策の設定(フォームにhiddenフィールドとして追加するためのnonceを「'noncename__post_type_manager」として設定). wp_nonce_field( wp_create_nonce( __FILE__ ), 'noncename__post_type_manager' ); + // 通知メッセージを取得して表示 + echo self::get_help_notice(); + ?>