<?php if ( !defined( 'ABSPATH' ) ) exit;//PHPの宣言と直接アクセスの拒否
/* セクションID haumenu_define_section_id_05_utility() */
/* タブのスラグ haumenu_define_tab_slug_05_utility() */
/* $option_name 設定名 haumenu_define_option_name_05_utility() */
/* get_option GetOP05_utility() */

/***** 親設定の有効／無効に合わせて子設定の表示方法を変更する *****/
/* 関数名・設定名は画面ごとに変えること（関数重複を防ぐ） */
/* add_action('admin_notices', 'current_pagehook');を追加してページ名を取得し、$page_fooksuffixの値を変える */
/* 連動マップ（ID => セレクター）の項目を編集する */

function haup_child_setting_view_control_05_utility( $hook_suffix ) {
	//ページフックにより出力を判断
	$page_fooksuffix = 'ha-utilitiy_page_haumenu_page_utility';

	if ( $page_fooksuffix !== $hook_suffix ) {
		return;
	}

	//メインスクリプトのハンドル
	$handle = 'haup-child-setting-control-js';

	// メインスクリプトが登録されていなければ終了(スクリプトの読み込みはmain-menu.phpで記述)
	if ( ! wp_script_is( $handle, 'registered' ) ) {
		return;
	}

	//設定名
	$set_name = haumenu_define_option_name_05_utility();

	// 連動マップ（ID => セレクター）
	// 1つのIDに対して複数のCSSクラスを指定する（1つなら1行）
	$dependency_map = array(
		$set_name . 'is-use-auto-link' => array(
			'.is-use-auto-link-wrapper', // 自動リンク機能の連動
		),

		$set_name . 'enable-notification-users' => array(
			'.enable-notification-users-wrapper', // メール通知機能の連動
		),

	);

	$inner_js = "";
	foreach ( $dependency_map as $id => $selectors ) {
		foreach ( (array) $selectors as $selector ) {
			// translators: %s stands for the CSS Class & ID.
			$inner_js .= sprintf(
				"haup_apply_dependency('%s', '%s');\n",
				esc_js( $id ),
				esc_js( $selector )
			);
		}
	}

	if ( $inner_js ) {
		$js_code = "if (window.haup_apply_dependency) {\n" . $inner_js . "}";
		// 第3引数を 'after' にすることで、本体JSの直後に出力
		wp_add_inline_script( $handle, $js_code, 'after' );
	}
}
add_action( 'admin_enqueue_scripts', 'haup_child_setting_view_control_05_utility', 20 );

/*** 累積アクセス数カウント ***/
/* 項目の追加とデータの更新 */
function haumenu_init_field_access_count(){
//項目の追加
	add_settings_field(
		'access-count', // 設定名
		__('Simple access number count','hima-art-utility'), // 設定タイトル
		'haumenu_access_count', // 設定項目のHTMLを出力する関数名
		haumenu_define_tab_slug_05_utility(), //表示させるタブのスラグ
		haumenu_define_section_id_05_utility(),// $section 表示させるセクションのID
		array( 'class' => 'ha-settings-separate' )
	);

}
add_action( 'admin_init', 'haumenu_init_field_access_count' );

/* 入力フォーム */
function haumenu_access_count() {
	$set_name = haumenu_define_option_name_05_utility(); //  $option_name 設定名
	$options = get_option($set_name);
	$option_name = 'access-count'; //個別配列名

	//テーブルに値がなかった場合の措置（PHP8.x以降への対応）
	if(isset($options[$option_name])){
		$checked = $options[$option_name];
	}else{
		$checked = '';
	}
?>
<label>
	<input type="checkbox" id="<?php echo esc_html($set_name . $option_name ); ?>" name="<?php echo esc_html($set_name . '[' .$option_name. ']'); ?>" class="wppd-ui-toggle" <?php checked( $checked , 1 ); ?> value="1">
	<p><?php esc_html_e('Measure the cumulative number of accesses for each post/fixed page, excluding accesses from bots (crawlers) and accesses by logged-in users.','hima-art-utility'); ?></p>
</label>
	<p class="haup-admin-bk"><?php esc_html_e('*We try to be as accurate as possible, but not all. Please use the number of accesses as a guide only.','hima-art-utility'); ?></p>
<details class="accordion"  style="margin: 5px 0px 0px 0px;overflow: hidden;">
<summary class="accordion__title" style="cursor: pointer;"><?php esc_html_e('View detailed description','hima-art-utility'); ?></summary>
<div class="accordion__content">
<ul style="list-style: disc;">
	<li><?php esc_html_e('Display the cumulative number of accesses on the list of posts and fixed pages on the management screen','hima-art-utility'); ?></li>
	<li><?php esc_html_e('The access count column on the management screen can be sorted in ascending or descending order.','hima-art-utility'); ?></li>
	<li><?php esc_html_e('By inserting the [ha-views] shortcode in a single template or in the body shortcode block, you can display the total number of accesses anywhere.','hima-art-utility'); ?>
	<br>
	<?php esc_html_e('Note that it does not work inside a query block','hima-art-utility'); ?></li>
</ul>
</div>
</details>
<?php
}

/*** モバイルではテーブルを横スクロールさせる ***/
/* 項目の追加とデータの更新 */
function haumenu_init_field_mobile_table_block_scroll(){
//項目の追加
	add_settings_field(
		'mobile-table-block-scroll', // 設定名
		__('Horizontal scrolling of table blocks','hima-art-utility'), // 設定タイトル
		'haumenu_mobile_table_block_scroll', // 設定項目のHTMLを出力する関数名
		haumenu_define_tab_slug_05_utility(), //表示させるタブのスラグ
		haumenu_define_section_id_05_utility(),// $section 表示させるセクションのID
		array( 'class' => 'ha-settings-separate' )
	);

}
add_action( 'admin_init', 'haumenu_init_field_mobile_table_block_scroll' );

/* 入力フォーム */
function haumenu_mobile_table_block_scroll() {
	$set_name = haumenu_define_option_name_05_utility(); //  $option_name 設定名
	$options = get_option($set_name);
	$option_name = 'mobile-table-block-scroll'; //個別配列名

	//テーブルに値がなかった場合の措置（PHP8.x以降への対応）
	if(isset($options[$option_name])){
		$checked = $options[$option_name];
	}else{
		$checked = '';
	}
?>
<label>
	<input type="checkbox" id="<?php echo esc_html($set_name . $option_name ); ?>" name="<?php echo esc_html($set_name . '[' .$option_name. ']'); ?>" class="wppd-ui-toggle" <?php checked( $checked , 1 ); ?> value="1">
	<p><?php esc_html_e('Prevents the table design from collapsing by scrolling the table block horizontally on mobile display.','hima-art-utility'); ?></p>
</label>
<?php
}

/*** 投稿公開時にサイトメールアドレスへ通知 ***/
/* 項目の追加とデータの更新 */
function haumenu_init_field_post_publish_notification(){
//項目の追加
	add_settings_field(
		'post-publish-notification', // 設定名
		__('Post Published Notification','hima-art-utility'), // 設定タイトル
		'haumenu_post_publish_notification', // 設定項目のHTMLを出力する関数名
		haumenu_define_tab_slug_05_utility(), //表示させるタブのスラグ
		haumenu_define_section_id_05_utility(),// $section 表示させるセクションのID
		array( 'class' => 'ha-settings-separate' )
	);

}
add_action( 'admin_init', 'haumenu_init_field_post_publish_notification' );

/* 入力フォーム */
function haumenu_post_publish_notification() {
	$set_name = haumenu_define_option_name_05_utility(); //  $option_name 設定名
	$options = get_option($set_name);
	$option_name = 'post-publish-notification'; //個別配列名

	//テーブルに値がなかった場合の措置（PHP8.x以降への対応）
	if(isset($options[$option_name])){
		$checked = $options[$option_name];
	}else{
		$checked = '';
	}
?>
<label>
	<input type="checkbox" id="<?php echo esc_html($set_name . $option_name ); ?>" name="<?php echo esc_html($set_name . '[' .$option_name. ']'); ?>" class="wppd-ui-toggle" <?php checked( $checked , 1 ); ?> value="1">
	<p><?php esc_html_e('Notify the site email address when a post is published','hima-art-utility'); ?></p>
</label>
<?php echo wp_kses_post(haup_usage_info_haup_is_single_filter()); ?>
<?php
}

/*** プロフィールでhtmlを許可 ***/
/* 項目の追加とデータの更新 */
function haumenu_init_field_allow_user_profile_html(){
//項目の追加
	add_settings_field(
		'allow-user-profile-html', // 設定名
		__('Allow HTML in profile information','hima-art-utility'), // 設定タイトル
		'haumenu_allow_user_profile_html', // 設定項目のHTMLを出力する関数名
		haumenu_define_tab_slug_05_utility(), //表示させるタブのスラグ
		haumenu_define_section_id_05_utility(),// $section 表示させるセクションのID
		array( 'class' => 'ha-settings-separate' )
	);

}
add_action( 'admin_init', 'haumenu_init_field_allow_user_profile_html' );

/* 入力フォーム */
function haumenu_allow_user_profile_html() {
	$set_name = haumenu_define_option_name_05_utility(); //  $option_name 設定名
	$options = get_option($set_name);
	$option_name = 'allow-user-profile-html'; //個別配列名

	//テーブルに値がなかった場合の措置（PHP8.x以降への対応）
	if(isset($options[$option_name])){
		$checked = $options[$option_name];
	}else{
		$checked = '';
	}
?>
<label>
	<input type="checkbox" id="<?php echo esc_html($set_name . $option_name ); ?>" name="<?php echo esc_html($set_name . '[' .$option_name. ']'); ?>" class="wppd-ui-toggle" <?php checked( $checked , 1 ); ?> value="1">
	<p><?php esc_html_e('HTML tags can be entered in "Profile information" on the user profile setting screen.','hima-art-utility'); ?></p>
</label>
<p class="haup-admin-bk">
	<span>
		<?php esc_html_e('Useful for formatting when using the author block or displaying your own author info content','hima-art-utility'); ?>
	</span>
	<br>
	<span class="haup-admin-font-red">
		<?php esc_html_e('Please note that HTML tags will be lost if profile information edited with HTML after enabling this function is updated after disabling this function.','hima-art-utility'); ?>
	</span>
</p>
<?php
}

/*** メディアの画像をユーザー画像として使う ***/
/* 項目の追加とデータの更新 */
function haumenu_init_field_user_image_used_media_library(){
//項目の追加
	add_settings_field(
		'user-image-used-media-library', // 設定名
		__('Use a media image as a user picture','hima-art-utility'), // 設定タイトル
		'haumenu_user_image_used_media_library', // 設定項目のHTMLを出力する関数名
		haumenu_define_tab_slug_05_utility(), //表示させるタブのスラグ
		haumenu_define_section_id_05_utility(),// $section 表示させるセクションのID
		array( 'class' => 'ha-settings-separate' )
	);

}
add_action( 'admin_init', 'haumenu_init_field_user_image_used_media_library' );

/* 入力フォーム */
function haumenu_user_image_used_media_library() {
	$set_name = haumenu_define_option_name_05_utility(); //  $option_name 設定名
	$options = get_option($set_name);
	$option_name = 'user-image-used-media-library'; //個別配列名

	//テーブルに値がなかった場合の措置（PHP8.x以降への対応）
	if(isset($options[$option_name])){
		$checked = $options[$option_name];
	}else{
		$checked = '';
	}
?>
<label>
	<input type="checkbox" id="<?php echo esc_html($set_name . $option_name ); ?>" name="<?php echo esc_html($set_name . '[' .$option_name. ']'); ?>" class="wppd-ui-toggle" <?php checked( $checked , 1 ); ?> value="1">
	<p><?php esc_html_e('Allows you to set an image from the media library as the user image','hima-art-utility'); ?><br><?php esc_html_e('This means that you will no longer need to register with Gravater to display your user image in the author information on the site.','hima-art-utility'); ?></p>
</label>
<p class="haup-admin-bk">
	<span>
		<?php esc_html_e('After enabling the function, a setting item called "HAUP Alternate User Image" will be added to the profile editing screen, so please specify an image there.','hima-art-utility'); ?>
	</span>
	<br>
	<span class="haup-admin-font-red">
		<?php esc_html_e('This function replaces the user image on the site, so if you want to automatically display the user image in the comments section of an external site, you will need to register with Gravater.','hima-art-utility'); ?>
	</span>
	<br>
	<span class="haup-admin-font-red">
		<?php esc_html_e('There are similar functions in membership plugins, so please disable this function if it conflicts.','hima-art-utility'); ?>
	</span>
</p>
<div style="text-align:right;margin-top:1rem;"><a href="<?php echo esc_url(HAUP_MANUAL_DIR); ?>/hotouse-local-avatar" target="_blank"><?php echo esc_html(haup_manual_text()); ?></a></div>
<?php
}

/*** タームの説明でhtmlを許可 ***/
/* 項目の追加とデータの更新 */
function haumenu_init_field_allow_term_html(){
//項目の追加
	add_settings_field(
		'allow-term-html', // 設定名
		__('Allow HTML in Term Description','hima-art-utility'), // 設定タイトル
		'haumenu_allow_term_html', // 設定項目のHTMLを出力する関数名
		haumenu_define_tab_slug_05_utility(), //表示させるタブのスラグ
		haumenu_define_section_id_05_utility(),// $section 表示させるセクションのID
		array( 'class' => 'ha-settings-separate' )
	);

}
add_action( 'admin_init', 'haumenu_init_field_allow_term_html' );

/* 入力フォーム */
function haumenu_allow_term_html() {
	$set_name = haumenu_define_option_name_05_utility(); //  $option_name 設定名
	$options = get_option($set_name);
	$option_name = 'allow-term-html'; //個別配列名

	//テーブルに値がなかった場合の措置（PHP8.x以降への対応）
	if(isset($options[$option_name])){
		$checked = $options[$option_name];
	}else{
		$checked = '';
	}
?>
<label>
	<input type="checkbox" id="<?php echo esc_html($set_name . $option_name ); ?>" name="<?php echo esc_html($set_name . '[' .$option_name. ']'); ?>" class="wppd-ui-toggle" <?php checked( $checked , 1 ); ?> value="1">
	<p><?php esc_html_e('Allows you to use HTML tags in the term description','hima-art-utility'); ?></p>
</label>
<p class="haup-admin-bk">
	<span>
		<?php esc_html_e('By enabling this, you will be able to use HTML tags in the description of your custom taxonomy in addition to the standard WordPress "categories" and "tags".','hima-art-utility'); ?>
	</span>
	<br>
	<span class="haup-admin-font-red">
		<?php esc_html_e('When this function is enabled, only users with administrator privileges will be allowed to use it.','hima-art-utility'); ?>
	</span>
	<br>
	<span class="haup-admin-font-red">
		<?php esc_html_e('We have taken security into consideration by disabling the use of scripts, but please be aware that they may open holes in the basic security of WordPress, so please enable them only after you understand this.','hima-art-utility'); ?>
	</span>
</p>
<?php
}

/*** 自動キーワードリンク機能を使用する ***/
/* 項目の追加とデータの更新 */
function haumenu_init_field_is_use_auto_link(){
//項目の追加
	add_settings_field(
		'is-use-auto-link', // 設定名
		__('Use Keyword Auto Link','hima-art-utility'), // 設定タイトル
		'haumenu_is_use_auto_link', // 設定項目のHTMLを出力する関数名
		haumenu_define_tab_slug_05_utility(), //表示させるタブのスラグ
		haumenu_define_section_id_05_utility(),// $section 表示させるセクションのID
		array( 'class' => 'ha-settings-separate' )
	);

}
add_action( 'admin_init', 'haumenu_init_field_is_use_auto_link' );

/* 入力フォーム */
function haumenu_is_use_auto_link() {
	$set_name = haumenu_define_option_name_05_utility(); //  $option_name 設定名
	$options = get_option($set_name);
	$option_name = 'is-use-auto-link'; //個別配列名

	//テーブルに値がなかった場合の措置（PHP8.x以降への対応）
	if(isset($options[$option_name])){
		$checked = $options[$option_name];
	}else{
		$checked = '';
	}
?>
<label>
	<input type="checkbox" id="<?php echo esc_html($set_name . $option_name ); ?>" name="<?php echo esc_html($set_name . '[' .$option_name. ']'); ?>" class="wppd-ui-toggle" <?php checked( $checked , 1 ); ?> value="1">
	<p><?php esc_html_e('Enables the function to automatically replace pre-registered keywords with links when they appear in the text.','hima-art-utility'); ?></p>
</label>
<details class="accordion"  style="margin: 5px 0px 0px 0px;overflow: hidden;">
<summary class="accordion__title" style="cursor: pointer;"><?php esc_html_e('View detailed description','hima-art-utility'); ?></summary>
<div class="accordion__content">
<ol>
	<li><?php esc_html_e('When you enable the function, the "Links" will be added to the HA Utility menu.','hima-art-utility'); ?></li>
	<li><?php esc_html_e('Just like creating a post, click "Add New", enter keywords in the title and the destination URL in the link URL, and click the "Publish" button.','hima-art-utility'); ?></li>
	<li><?php esc_html_e('If you check the "Automatically set keyword links" box displayed in the right sidebar of the post or static page editing screen and update it, any keywords registered in the text will automatically be converted to links.','hima-art-utility'); ?></li>
</ol>
<div class="haup-admin-bk">
<p><?php esc_html_e('Please note the following points when using','hima-art-utility'); ?></p>
<ul>
	<li><?php esc_html_e('The text in the body of the message will be replaced with a link only if it exactly matches the keyword in terms of capital letters, full-width and half-width characters, hiragana and katakana, etc.','hima-art-utility'); ?></li>
	<li><?php esc_html_e('In the "Link Collection" list, if "Title (Keyword) is Duplicate" is displayed, the set of keywords and links is duplicated. In this case, problems will occur when replacing with links, so please check regularly and perform maintenance.','hima-art-utility'); ?></li>
	<li><?php esc_html_e('This function compares all the text in the body of the page with the keywords registered in the link collection every time the page is displayed and replaces them with links. If the text is long or there are many keywords registered, this may affect the display speed or put a strain on the server.','hima-art-utility'); ?></li>
</ul>
</div>
</div>
</details>
<?php echo wp_kses_post(haup_usage_info_haup_is_single_filter()); ?>
<?php
}

/*** 自動キーワードリンク機能を全コンテンツに適用する ***/
/* 項目の追加とデータの更新 */
function haumenu_init_field_all_content_auto_keword_link(){
//項目の追加
	add_settings_field(
		'all-content-auto-keword-link', // 設定名
		'', // 設定タイトル
		'haumenu_all_content_auto_keword_link', // 設定項目のHTMLを出力する関数名
		haumenu_define_tab_slug_05_utility(), //表示させるタブのスラグ
		haumenu_define_section_id_05_utility(),// $section 表示させるセクションのID
		array( 'class' => 'ha-settings-convine' )
	);

}
add_action( 'admin_init', 'haumenu_init_field_all_content_auto_keword_link' );

/* 入力フォーム */
function haumenu_all_content_auto_keword_link() {
	$set_name = haumenu_define_option_name_05_utility(); //  $option_name 設定名
	$options = get_option($set_name);
	$option_name = 'all-content-auto-keword-link'; //個別配列名

	//テーブルに値がなかった場合の措置（PHP8.x以降への対応）
	if(isset($options[$option_name])){
		$checked = $options[$option_name];
	}else{
		$checked = '';
	}
?>
<div class="is-use-auto-link-wrapper" style="margin-bottom: 10px;">
<label>
	<input type="checkbox" id="<?php echo esc_html($set_name . $option_name ); ?>" name="<?php echo esc_html($set_name . '[' .$option_name. ']'); ?>" class="wppd-ui-toggle" <?php checked( $checked , 1 ); ?> value="1">
	<span><?php esc_html_e('Apply this feature to all content','hima-art-utility'); ?></span>
</label>
<details class="accordion"  style="margin: 5px 0px 0px 0px;overflow: hidden;">
<summary class="accordion__title" style="cursor: pointer;"><?php esc_html_e('View detailed description','hima-art-utility'); ?></summary>
<div class="accordion__content">
	<p>
	<span>
		<?php esc_html_e('Normally, this function works by checking the "Automatic Keyword Link Settings" box displayed on the editing screen of each piece of content, so that the automatic link function is enabled only for that piece of content.','hima-art-utility'); ?>
	</span>
	<br>
	<span>
		<?php esc_html_e('If you enable this setting, the feature will be enabled for all posts and static pages regardless of whether "Automatically set keyword links" is checked or not.','hima-art-utility'); ?>
	</span>
	<br>
	<span>
		<?php esc_html_e('Enable it if you want the feature to immediately work on all previously published content.','hima-art-utility'); ?>
	</span>
	<br>
	<span class="haup-admin-font-red">
		<?php esc_html_e('*As stated in the function description, the automatic link function converts strings that match the keywords you set into links every time a page is displayed, so sites with high traffic or sites with many automatic links set may experience high server loads or malfunctions.','hima-art-utility'); ?>
	</span>
	<br>
	<span class="haup-admin-font-red">
		<?php esc_html_e('Unless there is a strong need to apply the function to all past content at once, we strongly recommend that you do not enable this function, but instead use the basic function to individually check that the automatic linking function is working properly for each piece of content before enabling automatic linking.','hima-art-utility'); ?>
	</span>
	</p>
	<p class="haup-admin-bk">
		<?php esc_html_e('If you want to apply this to content published using custom post types, use the custom post type filter as with the basic function.','hima-art-utility'); ?>
	</p>

</div>
</details>

<div style="text-align:right;margin-top:1rem;"><a href="<?php echo esc_url(HAUP_MANUAL_DIR); ?>/howtouse-auto-internal-link" target="_blank"><?php echo esc_html(haup_manual_text()); ?></a></div>
</div>
<?php
}

/*** 自動タグ紐づけ機能 ***/
/* 項目の追加とデータの更新 */
function haumenu_init_field_use_auto_tagger(){
//項目の追加
	add_settings_field(
		'use-auto-tagger', // 設定名
		__('Automatic tag linking function','hima-art-utility'), // 設定タイトル
		'haumenu_use_auto_tagger', // 設定項目のHTMLを出力する関数名
		haumenu_define_tab_slug_05_utility(), //表示させるタブのスラグ
		haumenu_define_section_id_05_utility(),// $section 表示させるセクションのID
		array( 'class' => 'ha-settings-separate' )
	);

}
add_action( 'admin_init', 'haumenu_init_field_use_auto_tagger' );

/* 入力フォーム */
function haumenu_use_auto_tagger() {
	$set_name = haumenu_define_option_name_05_utility(); //  $option_name 設定名
	$options = get_option($set_name);
	$option_name = 'use-auto-tagger'; //個別配列名

	//テーブルに値がなかった場合の措置（PHP8.x以降への対応）
	if(isset($options[$option_name])){
		$checked = $options[$option_name];
	}else{
		$checked = '';
	}
?>
<label>
	<input type="checkbox" id="<?php echo esc_html($set_name . $option_name ); ?>" name="<?php echo esc_html($set_name . '[' .$option_name. ']'); ?>" class="wppd-ui-toggle" <?php checked( $checked , 1 ); ?> value="1">
	<p><?php esc_html_e('This function automatically links and registers the tag when the edit screen is saved and there are a certain number of words in the text that are the same as the tag.','hima-art-utility'); ?></p>
</label>
<p class="haup-admin-font-red"><?php esc_html_e('Please note that this function is for adding associations with tags when saving, and once an association has been registered, the tag will remain registered even if you change the content of the text.','hima-art-utility'); ?></p>
<?php echo wp_kses_post(haup_usage_info_haup_is_single_filter()); ?>
<?php echo wp_kses_post(haup_usage_info_change_post_tag_min_count()); ?>
<?php
}


/*** サイトから送信されるメールのメールアドレスを管理者メールアドレスへ変更する ***/
/* 項目の追加とデータの更新 */
function haumenu_init_field_change_send_author_mail_address(){
//項目の追加
	add_settings_field(
		'change-send-author-mail-address', // 設定名
		__('Change Sender Email','hima-art-utility'), // 設定タイトル
		'haumenu_change_send_author_mail_address', // 設定項目のHTMLを出力する関数名
		haumenu_define_tab_slug_05_utility(), //表示させるタブのスラグ
		haumenu_define_section_id_05_utility(),// $section 表示させるセクションのID
		array( 'class' => 'ha-settings-separate' )
	);

}
add_action( 'admin_init', 'haumenu_init_field_change_send_author_mail_address' );

/* 入力フォーム */
function haumenu_change_send_author_mail_address() {
	$set_name = haumenu_define_option_name_05_utility(); //  $option_name 設定名
	$options = get_option($set_name);
	$option_name = 'change-send-author-mail-address'; //個別配列名

	//テーブルに値がなかった場合の措置（PHP8.x以降への対応）
	if(isset($options[$option_name])){
		$checked = $options[$option_name];
	}else{
		$checked = '';
	}
?>
<label>
	<input type="checkbox" id="<?php echo esc_html($set_name . $option_name ); ?>" name="<?php echo esc_html($set_name . '[' .$option_name. ']'); ?>" class="wppd-ui-toggle" <?php checked( $checked , 1 ); ?> value="1">
	<p><?php esc_html_e('Change the email address for emails sent from the site to the administrator email address (the email address specified in the "Settings" panel of the admin screen)','hima-art-utility'); ?></p>
</label>
<p class="haup-admin-bk">
	<span class="haup-admin-font-red">
		<?php esc_html_e('When installing WordPress, the administrator email address and the email address of the first administrator user you register are the same. If you enable the function in this state, the administrator users email address will be exposed, so please make sure that the administrator email address and the administrator users email address are different.','hima-art-utility'); ?>
	</span>
	<br>
	<span style="font-size:0.8rem">
		<?php esc_html_e('To avoid the trouble of not receiving emails when you need them, we recommend that you try out the SMTP email sending function, which can be set up in the plugins "Site Optimization" → "Encrypt Outgoing Email" section, to ensure that your emails are always delivered.','hima-art-utility'); ?>
	</span>
</p>
<?php
}

/*** サイトから送信されるメールの送信者名をサイト名へ変更する ***/
/* 項目の追加とデータの更新 */
function haumenu_init_field_change_send_author_name(){
//項目の追加
	add_settings_field(
		'change-send-author-name', // 設定名
		__('Change Sender Name','hima-art-utility'), // 設定タイトル
		'haumenu_change_send_author_name', // 設定項目のHTMLを出力する関数名
		haumenu_define_tab_slug_05_utility(), //表示させるタブのスラグ
		haumenu_define_section_id_05_utility(),// $section 表示させるセクションのID
		array( 'class' => 'ha-settings-separate' )
	);

}
add_action( 'admin_init', 'haumenu_init_field_change_send_author_name' );

/* 入力フォーム */
function haumenu_change_send_author_name() {
	$set_name = haumenu_define_option_name_05_utility(); //  $option_name 設定名
	$options = get_option($set_name);
	$option_name = 'change-send-author-name'; //個別配列名

	//テーブルに値がなかった場合の措置（PHP8.x以降への対応）
	if(isset($options[$option_name])){
		$checked = $options[$option_name];
	}else{
		$checked = '';
	}
?>
<label>
	<input type="checkbox" id="<?php echo esc_html($set_name . $option_name ); ?>" name="<?php echo esc_html($set_name . '[' .$option_name. ']'); ?>" class="wppd-ui-toggle" <?php checked( $checked , 1 ); ?> value="1">
	<p><?php esc_html_e('Change the sender name of emails sent from the site to the site name','hima-art-utility'); ?></p>
</label>
<p class="haup-admin-bk" style="font-size:0.8rem"><?php esc_html_e('To avoid the trouble of not receiving emails when you need them, we recommend that you try out the SMTP email sending function, which can be set up in the plugins "Site Optimization" → "Encrypt Outgoing Email" section, to ensure that your emails are always delivered.','hima-art-utility'); ?></p>
<?php
}


