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 c7ad94d6..172e746c 100644
--- a/inc/post-type-manager/package/class.post-type-manager.php
+++ b/inc/post-type-manager/package/class.post-type-manager.php
@@ -128,6 +128,66 @@ public static function add_meta_box_action() {
echo '';
echo '
';
+
+ /*******************************************
+ * Menu Icon
+ */
+ echo '' . esc_html__( 'Menu Icon(Optional)', 'vk-all-in-one-expansion-unit' ) . '
';
+ echo '' . esc_html__( 'Select an icon from the images below, or enter a custom Dashicon class.' ) . '
';
+
+ echo '';
+ $icons = [
+ 'dashicons-admin-post',
+ 'dashicons-admin-site',
+ 'dashicons-admin-users',
+ 'dashicons-admin-media',
+ 'dashicons-admin-comments',
+ 'dashicons-admin-appearance',
+ 'dashicons-welcome-write-blog',
+ 'dashicons-dashboard',
+ 'dashicons-admin-plugins',
+ 'dashicons-admin-settings',
+ 'dashicons-admin-network',
+ 'dashicons-admin-home',
+ 'dashicons-admin-generic',
+ 'dashicons-admin-collapse',
+ ];
+
+ foreach ($icons as $icon) {
+ echo '
';
+ }
+
+ echo '
';
+
+ echo '
';
+
+ echo '
';
+
+ // JavaScript to update icon selection and validate input
+ echo '';
+
/*******************************************
* Export to Rest api
@@ -270,6 +330,7 @@ public static function save_cf_value( $post_id ) {
'veu_post_type_id',
'veu_post_type_items',
'veu_menu_position',
+ 'veu_menu_icon',
'veu_post_type_export_to_api',
'veu_post_type_rewrite',
'veu_taxonomy',
@@ -311,8 +372,21 @@ public static function add_post_type() {
);
$custom_post_types = get_posts( $args );
if ( $custom_post_types ) {
+
foreach ( $custom_post_types as $key => $post ) {
+ /*******************************************
+ * メニューアイコンを設定するためのコード
+ */
+ $menu_icon = get_post_meta($post->ID, 'veu_menu_icon', true);
+ if (empty($menu_icon)) {
+ $menu_icon = 'dashicons-admin-post';
+ } elseif ($menu_icon === 'none') {
+ $menu_icon = ''; // CSSでスタイリング可能に
+ } elseif (!strpos($menu_icon, 'dashicons-') === 0 && !strpos($menu_icon, 'data:image/svg+xml;base64,') === 0) {
+ $menu_icon = 'dashicons-admin-post';
+ }
+
/*******************************************
* 投稿タイプ追加.
*/
@@ -329,6 +403,10 @@ public static function add_post_type() {
foreach ( $post_type_items as $key => $value ) {
$supports[] = $key;
}
+
+ // 投稿タイプのアイコンを取得
+ $menu_icon = get_post_meta($post->ID, 'veu_menu_icon', true);
+ $menu_icon = !empty($menu_icon) ? $menu_icon : 'dashicons-admin-post';
// カスタム投稿タイプのスラッグ.
$post_type_id = mb_strimwidth( mb_convert_kana( mb_strtolower( esc_html( get_post_meta( $post->ID, 'veu_post_type_id', true ) ) ), 'a' ), 0, 20, '', 'UTF-8' );
@@ -362,6 +440,7 @@ public static function add_post_type() {
'public' => true,
'has_archive' => true,
'menu_position' => $menu_position,
+ 'menu_icon' => $menu_icon,
'supports' => $supports,
'rewrite' => $rewrite,
);
diff --git a/readme.txt b/readme.txt
index 34dcffb7..b36d0ea2 100644
--- a/readme.txt
+++ b/readme.txt
@@ -81,6 +81,8 @@ e.g.
== Changelog ==
+[ Add setting ][ Post Type Manager ] Add a menu icon setting.
+
= 9.97.2 =
[ Bug fix ] In WordPress 6.5, a link to the plugin page has been added to the admin bar on the front end by default. Consequently, ExUnit has been modified to no longer add this link on the front end.