Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions admin/admin-active-setting-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,11 @@
?>
<?php echo ( $count > 1 && $i >= 1 ) ? ' | ' : ''; ?>
<span>
<a href="<?php echo ( $att['url'] ) ? esc_html( $att['url'] ) : admin_url() . 'admin.php?page=vkExUnit_main_setting'; ?>">
<?php echo esc_html( $att['name'] ); ?>
</a></span>
<a href="<?php echo ( $att['url'] ) ? esc_url( $att['url'] ) : admin_url() . 'admin.php?page=vkExUnit_main_setting'; ?>"
<?php echo ( isset( $att['target'] ) && $att['target'] === '_blank' ) ? 'target="_blank"' : ''; ?>>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mtdkei
あー、これは「ExUnit の有効化設定画面で別ウィンドウで開く設定を追加」で趣旨が少し異なるので、微妙なラインですが別のプルリクであげて欲しいですー。で、多分こういう変更は作業中に発生してすぐに承認して欲しい時が多いと思うので、別でプルリクだけ作って、説明とかは適当で良いので、優先ですぐ見て欲しいとか連絡いただけるといいかなとー。
(今回はこのままでいいですー🙂)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そうですね、おっしゃる通りです。次から別のプルリクで対応します。

<?php echo esc_html( $att['name'] ); ?>
</a>
</span>

<?php
endif;
Expand Down
108 changes: 91 additions & 17 deletions inc/post-type-manager/package/class.post-type-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,73 @@ public static function add_cap_post_type_manage() {
$role->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(
'<div class="notice notice-info is-dismissible">
<p style="margin-top: 10px;"><strong>' . __( 'Help and Documentation', 'vk-all-in-one-expansion-unit' ) . ':</strong> ' . __( 'Learn more about custom post type settings by visiting the following resources:', 'vk-all-in-one-expansion-unit' ) . '</p>
<ul style="list-style-type: disc; margin-top: 0; margin-left: 20px;">
<li><a href="https://ex-unit.nagoya/ja/about/custom_post_type_manager" target="_blank">' . __( 'ExUnit Site: Custom Post Type Manager', 'vk-all-in-one-expansion-unit' ) . '</a></li>
<li><a href="https://training.vektor-inc.co.jp/courses/x-t9-custom-post-type/" target="_blank">' . __( 'Vektor Training: X-T9 Setup Guide for Custom Post Types', 'vk-all-in-one-expansion-unit' ) . '</a></li>
<li><a href="https://training.vektor-inc.co.jp/courses/lightning-basic-settings/lessons/lightning-custom-post-type-lightning/" target="_blank">' . __( 'Vektor Training: Lightning Basic Settings for Custom Post Types', 'vk-all-in-one-expansion-unit' ) . '</a></li>
</ul>
<p><a href="' . $dismiss_url . '" target="_parent">' . esc_html__( 'Dismiss this notice', 'vk-blocks' ) . '</a></p>
</div>'
);
}

/**
* 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 を作成.
*/
Expand All @@ -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();

?>
<style type="text/css">
table.table { border-collapse: collapse; border-spacing: 0;width:100%; }
Expand Down Expand Up @@ -170,24 +241,25 @@ public static function add_meta_box_action() {
echo '<hr>';

// JavaScript to update icon selection and validate input
echo '<script>
function updateIconSelection(icon) {
document.getElementById("veu_menu_icon").value = icon;
}
echo '
<script>
function updateIconSelection(icon) {
document.getElementById("veu_menu_icon").value = icon;
}

document.addEventListener("DOMContentLoaded", function () {
var inputField = document.getElementById("veu_menu_icon");
// `change` イベントを使用して、フォーカスが外れたときにチェックする
inputField.addEventListener("change", function() {
// SVGデータURI、\'none\'、または\'dashicons-\'で始まる値を許可
if (!this.value.startsWith("dashicons-") && !this.value.startsWith("data:image/svg+xml;base64,") && this.value !== \'none\') {
alert("' . __( 'Please enter a valid input. You can enter a Dashicon class, a base64-encoded SVG, or \'none\' to leave it blank for CSS customization.', 'vk-all-in-one-expansion-unit' ) . '");
this.value = ""; // 不正な入力をクリア
}
});
});
</script>';
document.addEventListener("DOMContentLoaded", function () {
var inputField = document.getElementById("veu_menu_icon");
// `change` イベントを使用して、フォーカスが外れたときにチェックする
inputField.addEventListener("change", function() {
// SVGデータURI、\'none\'、または\'dashicons-\'で始まる値を許可
if (!this.value.startsWith("dashicons-") && !this.value.startsWith("data:image/svg+xml;base64,") && this.value !== \'none\') {
alert("' . __( 'Please enter a valid input. You can enter a Dashicon class, a base64-encoded SVG, or \'none\' to leave it blank for CSS customization.', 'vk-all-in-one-expansion-unit' ) . '");
this.value = ""; // 不正な入力をクリア
}
});
});
</script>';

/*******************************************
* Export to Rest api
Expand Down Expand Up @@ -568,4 +640,6 @@ public function __construct() {

$VK_Post_Type_Manager = new VK_Post_Type_Manager(); // phpcs:ignore

add_action('admin_notices', array('VK_Post_Type_Manager', 'display_help_notice'), 20);

}
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ e.g.

== Changelog ==

[ Add function ][ Post Type Manager ] Added links to explanatory articles and Vectre from the custom post type settings.
[ Add setting ][ Category list ] Enable to specify ascending/descending order

= 9.99.6 =
Expand Down
6 changes: 6 additions & 0 deletions veu-packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,12 @@ function veu_get_packages( $is_block_theme = null ) {
'url' => admin_url() . 'edit.php?post_type=post_type_manage',
'enable_only' => 1,
),
( get_locale() === 'ja' ) ? array(
'name' => __( 'Learn more', 'vk-all-in-one-expansion-unit' ),
'url' => 'https://ex-unit.nagoya/ja/about/custom_post_type_manager',
'target' => '_blank',
'enable_only' => false,
) : null,
),
'default' => true,
'include' => 'post-type-manager/post-type-manager-config.php',
Expand Down
Loading