diff --git a/admin/admin-active-setting-page.php b/admin/admin-active-setting-page.php index 20fcef52..bbfc665f 100644 --- a/admin/admin-active-setting-page.php +++ b/admin/admin-active-setting-page.php @@ -66,9 +66,11 @@ ?> 1 && $i >= 1 ) ? ' | ' : ''; ?> - - - + > + + + add_cap( 'publish_others_' . $post_type_name . 's' ); } + /** + * ヘルプ通知 + * + * @return string + */ + public static function add_post_type_get_help_notice() { + + $dismiss_url = esc_url( + wp_nonce_url( + add_query_arg('vk-all-in-one-expansion-unit-dismiss', 'dismiss_admin_notice'), + 'vk-all-in-one-expansion-unit-dismiss-' . 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' ) . '

+
' + ); + } + + /** + * Check if the help notice should be displayed on the current page. + * + * @return bool + */ + public static function is_display_help_notice() { + global $pagenow; + + if ( get_locale() !== 'ja' ) { + return false; + } + + // 特定のページのみ通知を表示する + if ($pagenow === 'edit.php' && isset($_GET['post_type']) && $_GET['post_type'] === 'post_type_manage') { + // ユーザーが通知を無視したフラグが保存されているかどうかを確認 + if (!get_user_meta(get_current_user_id(), 'vk-all-in-one-expansion-unit_dismissed_notice', true)) { + return true; + } + } + } + + /** + * Display help notice on specific page + * + * @return void + */ + public static function display_help_notice() { + + if (self::is_display_help_notice()) { + + echo self::add_post_type_get_help_notice(); + } + + if (isset($_GET['vk-all-in-one-expansion-unit-dismiss']) && $_GET['vk-all-in-one-expansion-unit-dismiss'] === 'dismiss_admin_notice') { + check_admin_referer('vk-all-in-one-expansion-unit-dismiss-' . get_current_user_id()); + update_user_meta(get_current_user_id(), 'vk-all-in-one-expansion-unit_dismissed_notice', true); + } + } + /******************************************* * カスタムフィールドの meta box を作成. */ @@ -70,11 +137,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::add_post_type_get_help_notice(); + ?>