<?php
/*
  入力フィールドの生成
/*-------------------------------------------*/
add_action( 'lightning_design_setting_meta_fields', 'lightning_design_setting_header_trans_meta_fields' );
function lightning_design_setting_header_trans_meta_fields() {

	global $post;

	$form = '<h4>' . __( 'Header transmission', 'lightning-g3-pro-unit' ) . '</h4>';

	// トップページの設定を取得
	$page_on_front = intval( get_option( 'page_on_front' ) ); // フロントに指定する固定ページ
	$show_on_front = get_option( 'show_on_front' ); // or posts

	if ( 'page' === $show_on_front && $post->ID === $page_on_front ) {
		$form .= '<p>' . sprintf( __( 'Please set from <a href="%s" target="_blank">Appearance > Customize</a> > Lightning Header Setting.', 'lightning-g3-pro-unit' ), admin_url() . '/cusomize.php' ) . '</p>';
	} else {
		$saved_post_meta = get_post_meta( $post->ID, '_lightning_design_setting', true );
		$id              = '_lightning_design_setting[header_trans]';

		$form   .= '<select id="' . esc_attr( $id ) . '" name="' . esc_attr( $id ) . '">';
		$options = array(
			'default' => __( 'Use common settings', 'lightning-g3-pro-unit' ),
			'true'    => __( 'Enable transparency', 'lightning-g3-pro-unit' ),
			'normal'  => __( 'Disable transparency', 'lightning-g3-pro-unit' ),
		);
		foreach ( $options as $key => $value ) {
			$selected = '';
			if ( isset( $saved_post_meta['header_trans'] ) ) {
				if ( $key === $saved_post_meta['header_trans'] ) {
					$selected = ' selected';
				}
			}
			$form .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $value ) . '</option>';
		}
		$form .= '</select>';

		$form .= '<p>' . sprintf( __( '"Common setting" can set from <a href="%s" target="_blank">Appearance > Customize</a> > Lightning Header Setting.', 'lightning-g3-pro-unit' ), admin_url() . '/cusomize.php' ) . '</p>';
	}

	echo $form;
}
