<?php if ( !defined( 'ABSPATH' ) ) exit;//PHPの宣言と直接アクセスの拒否

/*** 追加の設定値を定義する関数 ***/
/* 共通するキーがある場合は後から指定する値が適用されるので注意 */
function haup_add_css_custom_properties( $settings ) {

	//コールバック関数を作ってリストに入れる
	$new_settings = array(
		'color' => array(
			'hr-icon-bg-color' => haup_variables_block_design_hr_icon_bg_callback(),
			'home-top-icon-color' => haup_variables_top_home_scroll_content_color_callback(),
			'home-top-button-color' => haup_variables_top_home_scroll_button_color_callback(),
			'tooltip-text-color' => haup_variables_tooltip_text_color_callback(),
			'tooltip-bg-color' => haup_variables_tooltip_background_color_callback(),
			'tooltip-border-color' => haup_variables_tooltip_border_color_callback(),
		),
		'text' => array(
			'smooth-scroll' => haup_variables_top_home_scroll_smooth_callback(),
			'group-hidden-message' => haup_variables_block_design_group_hidden_message_callback(),
			'para-warn-prefix' => haup_variables_block_design_para_warn_prefix_callback(),
			'para-notice-prefix' => haup_variables_block_design_para_notice_prefix_callback(),
			'para-info-prefix' => haup_variables_block_design_para_info_prefix_callback(),
			'para-idea-prefix' => haup_variables_block_design_para_idea_prefix_callback(),
			'pt-link-text-color' => haup_variables_page_top_scroll_text_color_callback(),
			'pt-link-hover-text-color' => haup_variables_page_top_scroll_hover_text_color_callback(),
			'group-before-click-message' => haup_variables_block_design_group_before_click_message_callback(),
		)
	);

	// 既存の設定と新しい設定でキーが重複した場合、後から追加されたものが優先されます。
	return array_merge_recursive( $settings, $new_settings );
}
add_filter( 'haup_custom_css_preset_values_filter', 'haup_add_css_custom_properties' );

/***** コールバック *****/
/*** ホーム・トップぺ戻る ***/
/* スムーススクロール */
function haup_variables_top_home_scroll_smooth_callback(){
	//スムーススクロールの有効化
	if(isset( GetOP06_addcontent()['enable-top-home-s-scroll'] )){
		$smooth = GetOP06_addcontent()['enable-top-home-s-scroll'];
	}else{
		$smooth = '';
	}

	if($smooth == '1'){
		$s_scroll = 'smooth';
	}else{
		$s_scroll = 'auto';
	}

	return $s_scroll;
}

/* アイコンの色 */
function haup_variables_top_home_scroll_content_color_callback(){
	if(isset( GetOP06_addcontent()['top-home-scroll-content-color'] ) && !empty( GetOP06_addcontent()['top-home-scroll-content-color'] )){
		$icon_color = sanitize_hex_color(GetOP06_addcontent()['top-home-scroll-content-color']);
	}else{
		$icon_color = sanitize_hex_color('#000000');
	}

	return $icon_color;
}

/* ボタンの背景色 */
function haup_variables_top_home_scroll_button_color_callback(){
	if(isset( GetOP06_addcontent()['top-home-scroll-int-bg-color'] ) && !empty( GetOP06_addcontent()['top-home-scroll-int-bg-color'] )){
		$back_color = sanitize_hex_color(GetOP06_addcontent()['top-home-scroll-int-bg-color']);
	}else{
		$back_color = sanitize_hex_color('#ffffff');
	}

	return $back_color;
}

/*** block design ***/
/* 区切り　アイコンの背景 */
function haup_variables_block_design_hr_icon_bg_callback(){
	if(isset( GetOP01_utility()['separate-icon-bg'] )){
		$icon_background_color = GetOP01_utility()['separate-icon-bg'];
	}else{
		$icon_background_color = '';
	}

	if(empty($icon_background_color)){
		$icon_bg = '#ffffff';
	}else{
		$icon_bg = $icon_background_color;
	}

	return $icon_bg;
}

/* グループ　非表示のメッセージ */
function haup_variables_block_design_group_hidden_message_callback(){
	$hidden_message = __('"This group is not visible in the frontend. Please cancel the Front Hidden style if you want to display"','hima-art-utility');
	
	return $hidden_message;
}

/* グループ　クリックして表示で非表示時のボタン文字列 */
function haup_variables_block_design_group_before_click_message_callback(){
		$hidden_message = __('"Click to view contents"','hima-art-utility');
	
	return $hidden_message;
}

/* 段落　タブ付き見出しのテキスト　警告 */
function haup_variables_block_design_para_warn_prefix_callback(){
	//警告用の文字列
	if(isset( GetOP01_utility()['warn-para-block-header-prefix'] )){
		$wh_title = GetOP01_utility()['warn-para-block-header-prefix'];
	}else{
		$wh_title = '';
	}

	if(!empty( $wh_title )){
		$warn_head_content = '"'.$wh_title.'"';
	}else{
		$warn_head_content = '"Attention"';
	}

	return $warn_head_content;
}

/* 段落　タブ付き見出しのテキスト　注意 */
function haup_variables_block_design_para_notice_prefix_callback(){
if(isset( GetOP01_utility()['notice-para-block-header-prefix'] )){
		$nh_title = GetOP01_utility()['notice-para-block-header-prefix'];
	}else{
		$nh_title = '';
	}
if(!empty( $nh_title )){
	$notice_head_content = '"'.$nh_title.'"';
}else{
	$notice_head_content = '"Notice"';
}

	return $notice_head_content;
}

/* 段落　タブ付き見出しのテキスト　チェック */
function haup_variables_block_design_para_info_prefix_callback(){
if(isset( GetOP01_utility()['info-para-block-header-prefix'] )){
		$ih_title = GetOP01_utility()['info-para-block-header-prefix'];
	}else{
		$ih_title = '';
	}
if(!empty( $ih_title )){
	$info_head_content = '"'.$ih_title.'"';
}else{
	$info_head_content = '"Check Point"';
}

	return $info_head_content;
}

/* 段落　タブ付き見出しのテキスト　アイディア */
function haup_variables_block_design_para_idea_prefix_callback(){
if(isset( GetOP01_utility()['idea-para-block-header-prefix'] )){
		$idh_title = GetOP01_utility()['idea-para-block-header-prefix'];
	}else{
		$idh_title = '';
	}

if(!empty( $idh_title )){
	$idea_head_content = '"'.$idh_title.'"';
}else{
	$idea_head_content = '"Discovery"';
}

	return $idea_head_content;
}

function haup_variables_tooltip_text_color_callback(){
	//文字色の指定
if(isset( GetOP03_addcontent()['tooltip-text-color'] )){
	$text_color = GetOP03_addcontent()['tooltip-text-color'];
}else{
	$text_color = '';
}


if(empty($text_color)){
	$set_text_color = sanitize_hex_color('#222');
}else{
	$set_text_color = sanitize_hex_color($text_color);
}

	return $set_text_color;
}

/*** ツールチップショートコード ***/
function haup_variables_tooltip_background_color_callback(){
	//背景色の指定
if(isset( GetOP03_addcontent()['tooltip-bg-color'] )){
	$bg_color = GetOP03_addcontent()['tooltip-bg-color'];
}else{
	$bg_color = '';
}

if(empty($bg_color)){
	$set_bg_color = sanitize_hex_color('#eee');
}else{
	$set_bg_color = sanitize_hex_color($bg_color);
}

	return $set_bg_color;
}

function haup_variables_tooltip_border_color_callback(){
	//枠線色の指定
if(isset( GetOP03_addcontent()['tooltip-border-color'] )){
	$border_color = GetOP03_addcontent()['tooltip-border-color'];
}else{
	$bg_color = '';
}

if(empty($border_color)){
	$set_border_color = sanitize_hex_color('#777');
}else{
	$set_border_color = sanitize_hex_color($border_color);
}

	return $set_border_color;
}

/*** ページ上部へ戻る ***/
/* スムーススクロール */
function haup_variables_page_top_scroll_smooth_callback(){
	//スムーススクロールの有効化
	if(isset( GetOP12_addcontent()['enable-auto-top-link-s-scroll'] )){
		$smooth = esc_html(GetOP12_addcontent()['enable-auto-top-link-s-scroll']);
	}else{
		$smooth = '';
	}

	if($smooth == '1'){
		$s_scroll = 'smooth';
	}else{
		$s_scroll = 'auto';
	}

	return $s_scroll;
}

/* 文字色 */
function haup_variables_page_top_scroll_text_color_callback(){
	if(isset( GetOP12_addcontent()['auto-top-link-text-color'] )){
		$text_color = esc_html(GetOP12_addcontent()['auto-top-link-text-color']);
	}else{
		$text_color = '';
	}

	if(empty($text_color)){
		$t_color = sanitize_hex_color('#555555');
	}else{
		$t_color = sanitize_hex_color($text_color);
	}

	return $t_color;
}

/* ホーバー時の文字色 */
function haup_variables_page_top_scroll_hover_text_color_callback(){
	if(isset( GetOP12_addcontent()['auto-top-link-text-color'] )){
		$text_color_hov = esc_html(GetOP12_addcontent()['auto-top-link-text-color-hover']);
	}else{
		$text_color_hov = '';
	}

	if(empty($text_color_hov)){
		$t_color_hov = esc_html('var(--wp--preset--color--foreground)');
	}else{
		$t_color_hov = sanitize_hex_color($text_color_hov);
	}

	return $t_color_hov;
}