<?php
/*
このファイルの元ファイルは
https://github.com/vektor-inc/vektor-wp-libraries
にあります。修正の際は上記リポジトリのデータを修正してください。
*/

// Customizer.
add_action( 'customize_register', 'vkfs_customize_register_add_control', 10 );

// Register custom contorol.
if ( ! function_exists( 'vkfs_customize_register_add_control' ) ) {

	/**
	 * Register Customize Control
	 *
	 * @return void
	 */
	function vkfs_customize_register_add_control() {

		/**********************************************
		 * Add text control description
		 */
		class Vk_Font_Selector_Custom_Html extends WP_Customize_Control {
			public $type             = 'customtext';
			public $custom_title_sub = ''; // we add this for the extra custom_html.
			public $custom_html      = ''; // we add this for the extra custom_html.
			/**
			 * Custom HTML Control view
			 *
			 * @return void
			 */
			public function render_content() {
				if ( $this->label ) {
					echo '<h2 class="admin-custom-h2">' . wp_kses_post( $this->label ) . '</h2>';
				}
				if ( $this->custom_title_sub ) {
					echo '<h3 class="admin-custom-h3">' . wp_kses_post( $this->custom_title_sub ) . '</h3>';
				}
				if ( $this->custom_html ) {
					echo '<div>' . wp_kses_post( $this->custom_html ) . '</div>';
				}
			} // public function render_content() {
		} // class VkVk_Font_Selector_Custom_Html extends WP_Customize_Control

	} // function veu_customize_register_add_control(){
} // if ( ! function_exists( 'vkfs_customize_register_add_control' ) ) {


if ( ! class_exists( 'Vk_Font_Selector_Customize' ) ) {

	/**
	 * Font customize class
	 */
	class Vk_Font_Selector_Customize {

		public static $version = '0.1.3';

		public static function init() {
			add_action( 'customize_register', array( __CLASS__, 'register' ) );
			add_action( 'wp_head', array( __CLASS__, 'dynamic_header_css' ), 5 );
			add_action( 'wp_footer', array( __CLASS__, 'load_web_fonts' ) );
			add_action( 'admin_footer', array( __CLASS__, 'load_web_fonts' ) );
			add_action( 'enqueue_block_editor_assets', array( __CLASS__, 'dynamic_editor_css' ), 12 );
		}

		public static function fonts_array() {
			$fonts_array = array(
				''                      => array(
					'label'       => __( 'Unspecified', 'lightning-g3-pro-unit' ),
					'font-family' => '',
				),
				'mincho'                => array(
					'label'       => __( 'Mincho', 'lightning-g3-pro-unit' ),
					'font-family' => 'Hiragino Mincho ProN,"游明朝",serif',
				),
				'hira-kaku'             => array(
					'label'       => __( 'Hiragino Kaku Gothic', 'lightning-g3-pro-unit' ),
					'font-family' => '"ヒラギノ角ゴ ProN W3", Hiragino Kaku Gothic ProN,"游ゴシック Medium","Yu Gothic Medium","游ゴシック体",YuGothic, "Helvetica Neue", sans-serif',
				),
				'yu-gothic'             => array(
					'label'       => __( 'Yu Gothic', 'lightning-g3-pro-unit' ),
					'font-family' => '"游ゴシック Medium","Yu Gothic Medium","游ゴシック体",YuGothic,"ヒラギノ角ゴ ProN W3", Hiragino Kaku Gothic ProN,sans-serif',
				),
				'meiryo'                => array(
					'label'       => __( 'Meiryo', 'lightning-g3-pro-unit' ),
					'font-family' => '"メイリオ",Meiryo,"ヒラギノ角ゴ ProN W3", Hiragino Kaku Gothic ProN,sans-serif',
				),
				'san-francisco'         => array(
					'label'       => __( 'San Francisco', 'lightning-g3-pro-unit' ),
					'font-family' => '-apple-system,BlinkMacSystemFont,"メイリオ",Meiryo,"ヒラギノ角ゴ ProN W3", Hiragino Kaku Gothic ProN,sans-serif',
				),
				// 'Noto+Sans+JP:100'      => array(
				// 'label'           => 'Noto Sans JP 100 ( Google Fonts )',
				// 'font-family'     => '"Noto Sans JP",sans-serif',
				// 'font-family-key' => 'Noto+Sans+JP',
				// 'font-weight'     => 100,
				// ),
				'Noto+Sans+JP:300'      => array(
					'label'           => 'Noto Sans JP 300 ( Google Fonts )',
					'font-family'     => '"Noto Sans JP",sans-serif',
					'font-family-key' => 'Noto+Sans+JP',
					'font-weight'     => 300,
				),
				'Noto+Sans+JP:400'      => array(
					'label'           => 'Noto Sans JP 400 ( Google Fonts )',
					'font-family'     => '"Noto Sans JP",sans-serif',
					'font-family-key' => 'Noto+Sans+JP',
					'font-weight'     => 400,
				),
				'Noto+Sans+JP:500'      => array(
					'label'           => 'Noto Sans JP 500 ( Google Fonts )',
					'font-family'     => '"Noto Sans JP",sans-serif',
					'font-family-key' => 'Noto+Sans+JP',
					'font-weight'     => 500,
				),
				'Noto+Sans+JP:700'      => array(
					'label'           => 'Noto Sans JP 700 ( Google Fonts )',
					'font-family'     => '"Noto Sans JP",sans-serif',
					'font-family-key' => 'Noto+Sans+JP',
					'font-weight'     => 700,
				),
				'Noto+Sans+JP:900'      => array(
					'label'           => 'Noto Sans JP 900 ( Google Fonts )',
					'font-family'     => '"Noto Sans JP",sans-serif',
					'font-family-key' => 'Noto+Sans+JP',
					'font-weight'     => 900,
				),
				'Noto+Serif+JP:200'     => array(
					'label'           => 'Noto Serif JP 200 ( Google Fonts )',
					'font-family'     => '"Noto Serif JP",sans-serif',
					'font-family-key' => 'Noto+Serif+JP',
					'font-weight'     => 200,
				),
				'Noto+Serif+JP:300'     => array(
					'label'           => 'Noto Serif JP 300 ( Google Fonts )',
					'font-family'     => '"Noto Serif JP",sans-serif',
					'font-family-key' => 'Noto+Serif+JP',
					'font-weight'     => 300,
				),
				'Noto+Serif+JP:400'     => array(
					'label'           => 'Noto Serif JP 400 ( Google Fonts )',
					'font-family'     => '"Noto Serif JP",sans-serif',
					'font-family-key' => 'Noto+Serif+JP',
					'font-weight'     => 400,
				),
				'Noto+Serif+JP:500'     => array(
					'label'           => 'Noto Serif JP 500 ( Google Fonts )',
					'font-family'     => '"Noto Serif JP",sans-serif',
					'font-family-key' => 'Noto+Serif+JP',
					'font-weight'     => 500,
				),
				'Noto+Serif+JP:600'     => array(
					'label'           => 'Noto Serif JP 600 ( Google Fonts )',
					'font-family'     => '"Noto Serif JP",sans-serif',
					'font-family-key' => 'Noto+Serif+JP',
					'font-weight'     => 600,
				),
				'Noto+Serif+JP:700'     => array(
					'label'           => 'Noto Serif JP 700 ( Google Fonts )',
					'font-family'     => '"Noto Serif JP",sans-serif',
					'font-family-key' => 'Noto+Serif+JP',
					'font-weight'     => 700,
				),
				'Noto+Serif+JP:900'     => array(
					'label'           => 'Noto Serif JP 900 ( Google Fonts )',
					'font-family'     => '"Noto Serif JP",sans-serif',
					'font-family-key' => 'Noto+Serif+JP',
					'font-weight'     => 900,
				),
				// 'M+PLUS+1p:100'         => array(
				// 'label'           => 'M PLUS 1p 100 ( Google Fonts )',
				// 'font-family'     => '"M PLUS 1p",sans-serif',
				// 'font-family-key' => 'M+PLUS+1p',
				// 'font-weight'     => 100,
				// ),
				'M+PLUS+1p:300'         => array(
					'label'           => 'M PLUS 1p 300 ( Google Fonts )',
					'font-family'     => '"M PLUS 1p",sans-serif',
					'font-family-key' => 'M+PLUS+1p',
					'font-weight'     => 300,
				),
				'M+PLUS+1p:400'         => array(
					'label'           => 'M PLUS 1p 400 ( Google Fonts )',
					'font-family'     => '"M PLUS 1p",sans-serif',
					'font-family-key' => 'M+PLUS+1p',
					'font-weight'     => 400,
				),
				'M+PLUS+1p:500'         => array(
					'label'           => 'M PLUS 1p 500 ( Google Fonts )',
					'font-family'     => '"M PLUS 1p",sans-serif',
					'font-family-key' => 'M+PLUS+1p',
					'font-weight'     => 500,
				),
				'M+PLUS+1p:700'         => array(
					'label'           => 'M PLUS 1p 700 ( Google Fonts )',
					'font-family'     => '"M PLUS 1p",sans-serif',
					'font-family-key' => 'M+PLUS+1p',
					'font-weight'     => 700,
				),
				// 'M+PLUS+1p:800'         => array(
				// 'label'           => 'M PLUS 1p 800 ( Google Fonts )',
				// 'font-family'     => '"M PLUS 1p",sans-serif',
				// 'font-family-key' => 'M+PLUS+1p',
				// 'font-weight'     => 800,
				// ),
				// 'M+PLUS+1p:900'         => array(
				// 'label'           => 'M PLUS 1p 900 ( Google Fonts )',
				// 'font-family'     => '"M PLUS 1p",sans-serif',
				// 'font-family-key' => 'M+PLUS+1p',
				// 'font-weight'     => 900,
				// ),
				// 'M+PLUS+Rounded+1c:100' => array(
				// 'label'           => 'M PLUS Rounded 1c 100 ( Google Fonts )',
				// 'font-family'     => '"M PLUS Rounded 1c",sans-serif',
				// 'font-family-key' => 'M+PLUS+Rounded+1c',
				// 'font-weight'     => 100,
				// ),
				'M+PLUS+Rounded+1c:300' => array(
					'label'           => 'M PLUS Rounded 1c 300 ( Google Fonts )',
					'font-family'     => '"M PLUS Rounded 1c",sans-serif',
					'font-family-key' => 'M+PLUS+Rounded+1c',
					'font-weight'     => 300,
				),
				'M+PLUS+Rounded+1c:400' => array(
					'label'           => 'M PLUS Rounded 1c 400 ( Google Fonts )',
					'font-family'     => '"M PLUS Rounded 1c",sans-serif',
					'font-family-key' => 'M+PLUS+Rounded+1c',
					'font-weight'     => 400,
				),
				'M+PLUS+Rounded+1c:500' => array(
					'label'           => 'M PLUS Rounded 1c 500 ( Google Fonts )',
					'font-family'     => '"M PLUS Rounded 1c",sans-serif',
					'font-family-key' => 'M+PLUS+Rounded+1c',
					'font-weight'     => 500,
				),
				'M+PLUS+Rounded+1c:700' => array(
					'label'           => 'M PLUS Rounded 1c 700 ( Google Fonts )',
					'font-family'     => '"M PLUS Rounded 1c",sans-serif',
					'font-family-key' => 'M+PLUS+Rounded+1c',
					'font-weight'     => 700,
				),
				// 'M+PLUS+Rounded+1c:800' => array(
				// 'label'           => 'M PLUS Rounded 1c 800 ( Google Fonts )',
				// 'font-family'     => '"M PLUS Rounded 1c",sans-serif',
				// 'font-family-key' => 'M+PLUS+Rounded+1c',
				// 'font-weight'     => 800,
				// ),
				// 'M+PLUS+Rounded+1c:900' => array(
				// 'label'           => 'M PLUS Rounded 1c 900 ( Google Fonts )',
				// 'font-family'     => '"M PLUS Rounded 1c",sans-serif',
				// 'font-family-key' => 'M+PLUS+Rounded+1c',
				// 'font-weight'     => 900,
				// ),
				'Sawarabi+Mincho'       => array(
					'label'           => 'Sawarabi Mincho ( Google Fonts )',
					'font-family'     => '"Sawarabi Mincho",sans-serif',
					'font-family-key' => 'Sawarabi+Mincho',
				),
				'Sawarabi+Gothic'       => array(
					'label'           => 'Sawarabi Gothic ( Google Fonts )',
					'font-family'     => '"Sawarabi Gothic",sans-serif',
					'font-family-key' => 'Sawarabi+Gothic',
				),
				'Kosugi+Maru'           => array(
					'label'           => 'Kosugi Maru ( Google Fonts )',
					'font-family'     => '"Kosugi Maru",sans-serif',
					'font-family-key' => 'Kosugi+Maru',
				),
				'Kosugi'                => array(
					'label'           => 'Kosugi ( Google Fonts )',
					'font-family'     => '"Kosugi",sans-serif',
					'font-family-key' => 'Kosugi',
				),
			);
			return apply_filters( 'vk_font_family_array', $fonts_array );
		}

		public static function target_array() {
			$target_array = array(
				'hlogo' => array(
					'label'    => __( 'Header Logo', 'lightning-g3-pro-unit' ),
					'selector' => '.navbar-brand.siteHeader_logo',
				),
				'menu'  => array(
					'label'    => __( 'Global Menu', 'lightning-g3-pro-unit' ),
					'selector' => '.gMenu',
				),
				'title' => array(
					'label'    => __( 'Title', 'lightning-g3-pro-unit' ),
					'selector' => 'h1,h2,h3,h4,h5,h6',
				),
				'text'  => array(
					'label'    => __( 'Text', 'lightning-g3-pro-unit' ),
					'selector' => 'body,html',
				),
			);
			return apply_filters( 'vk_font_target_array', $target_array );
		}

		public static function editor_target_array() {
			$editor_target_array = array(
				'title' => array(
					'label'    => __( 'Title', 'lightning-g3-pro-unit' ),
					'selector' => 'h1,h2,h3,h4,h5,h6',
				),
				'text'  => array(
					'label'    => __( 'Text', 'lightning-g3-pro-unit' ),
					'selector' => 'body',
				),
			);
			return apply_filters( 'vk_font_editor_target_array', $editor_target_array );
		}

		public static function register( $wp_customize ) {

			// セクション、テーマ設定、コントロールを追加.

			global $vk_font_selector_prefix;
			global $vk_font_selector_priority;

			if ( ! $vk_font_selector_priority ) {
				$vk_font_selector_priority = 900;
			}

			// セクション追加.
			$wp_customize->add_section(
				'vk_font_selector_related_setting',
				array(
					'title'    => $vk_font_selector_prefix . __( 'Font Setting', 'lightning-g3-pro-unit' ),
					'priority' => $vk_font_selector_priority,
				)
			);

			$wp_customize->add_setting( 'font_mobile_caution', array( 'sanitize_callback' => 'sanitize_text_field' ) );
			$html  = '<ul>';
			$html .= '<li>' . __( 'If you want to apply the same font on mobile devices, please select web font (Google Fonts).', 'lightning-g3-pro-unit' ) . '</li>';
			$html .= '<li>' . __( 'The web font (Google Fonts) loads the font data, so the display will be slightly late.', 'lightning-g3-pro-unit' ) . '</li>';
			$html .= '</ul>';
			$wp_customize->add_control(
				new Vk_Font_Selector_Custom_Html(
					$wp_customize,
					'font_mobile_caution',
					array(
						'label'            => '',
						'section'          => 'vk_font_selector_related_setting',
						'type'             => 'text',
						'custom_title_sub' => '',
						'custom_html'      => $html,
					)
				)
			);

			// フォントセット読み込み.
			$fonts_array = self::fonts_array();
			// プルダウン用の項目.
			$choices = array();
			foreach ( $fonts_array as $key => $value ) {
				$choices[ $key ] = $value['label'];
			}

			// フォント対象読み込み.
			$target_arry = self::target_array();
			$targets     = array();
			foreach ( $target_arry as $key => $value ) {
				$targets[ $key ] = $value['label'];
			}

			// $targets = array(
			// 'title' => 'Title',
			// 'text'  => 'Text',
			// );

			foreach ( $targets as $key => $label ) {
				$wp_customize->add_setting(
					'vk_font_selector[' . $key . ']',
					array(
						'default'           => '',
						'type'              => 'option',
						'capability'        => 'edit_theme_options',
						'sanitize_callback' => 'sanitize_text_field',
					)
				);
				$wp_customize->add_control(
					'vk_font_selector[' . $key . ']',
					array(
						'label'    => __( $label . ':', 'lightning-g3-pro-unit' ),
						'section'  => 'vk_font_selector_related_setting',
						'settings' => 'vk_font_selector[' . $key . ']',
						'type'     => 'select',
						'choices'  => $choices,
					// 'choices'  => array(
					// 'mincho' => __( 'Mincho', 'lightning-g3-pro-unit' ),
					// 'gothic' => __( 'Gothic', 'lightning-g3-pro-unit' ),
					// ),
					)
				);
			}
		} // public function vk_font_selector_function_customize_register( $wp_customize )

		/**
		 * Selected font information
		 *
		 * @return array $selected_fonts_info
		 */
		public static function get_selected_fonts_info() {
			// どの場所にどのフォント指定をするのかが格納されている.
			$options = get_option( 'vk_font_selector' );
			// $options = array(
			// [title] => gothic,
			// [menu] => gothic,
			// [text] => gothic,
			// );

			// フォントリストの情報を読み込み.
			$fonts_array = self::fonts_array();
			// $fonts_array = array(
			// 'mincho' => array(
			// 'label' => __( 'Mincho','lightning-g3-pro-unit'),
			// 'font-family' => 'serif',
			// ),
			// 'gothic' => array(
			// 'label' => __( 'Gothic','lightning-g3-pro-unit'),
			// 'font-family' => 'sans-serif',
			// ),
			// );
			$target_array = self::target_array();
			// $target_array = array(
			// 'text' => array(
			// 'label' => __('Text', 'lightning-g3-pro-unit'),
			// 'selector' => 'body',
			// ),
			// 'title' => array(
			// 'label' => __('Title', 'lightning-g3-pro-unit'),
			// 'selector' => 'h1,h2,h3,h4,h5,h6',
			// ),
			// 'menu' => array(
			// 'label' => __('Global Menu', 'lightning-g3-pro-unit'),
			// 'selector' => '.gMenu',
			// ),
			// );

			$dynamic_css        = '';
			$selected_web_fonts = array();

			// フォントを指定するターゲット項目をループする.
			foreach ( $target_array as $target_key => $target_value ) {

				// そのターゲットに対して、どのフォントが指定されているのかを取得
				// フォント指定先である $target_key（ title とか body とか） にフォント指定情報が保存されていたら.
				if ( ! empty( $options[ $target_key ] ) ) {
					// 指定されているフォントのキーを$font_keyに格納.
					$font_key = $options[ $target_key ];

					// 指定されたフォントキーの実際のフォントファミリーの取得 と CSSの登録
					// そのフォントキーがフォントの配列に登録されていたら.
					if ( isset( $fonts_array[ $font_key ] ) ) {
						// 配列の中から実際のフォントファミリーを代入.
						$font_family = 'font-family:' . $fonts_array[ $font_key ]['font-family'] . ';';

						// Google Fonts など weight指定があるものは追加.
						$font_weight = '';
						if ( isset( $fonts_array[ $font_key ]['font-weight'] ) ) {
							$font_weight = 'font-weight:' . $fonts_array[ $font_key ]['font-weight'] . ';';
						}
						// 出力するCSSに登録.
						$dynamic_css .= $target_value['selector'] . '{ ';
						$dynamic_css .= $font_family . $font_weight;
						$dynamic_css .= 'font-display: swap;';
						$dynamic_css .= '}';
					}

					// ウェブフォントを使用していたらウェブフォント情報を取得.
					if ( isset( $fonts_array[ $font_key ]['font-family-key'] ) ) {
						$selected_web_fonts[ $font_key ] = $fonts_array[ $font_key ];
					}
				} // if ( ! empty( $options[ $target_key ] ) ) {
			}

			// 動的に書き出すCSS情報.
			$selected_fonts_info['dynamic_css'] = $dynamic_css;

			// ウェブフォントが使用されていた場合のウェブフォント情報（ウェブフォントを取得するため）.
			$selected_fonts_info['selected_webFonts'] = $selected_web_fonts;
			return $selected_fonts_info;
		}

		/**
		 * Print inline css to Editor
		 *
		 * @return void
		 */
		public static function dynamic_editor_css() {

			global $vk_font_selector_editor_style;
			$options = get_option( 'vk_font_selector' );

			$fonts_array         = self::fonts_array();
			$editor_target_array = self::editor_target_array();

			$dynamic_css = '';

			// フォントを指定するターゲット項目をループする.
			foreach ( $editor_target_array as $target_key => $target_value ) {

				// そのターゲットに対して、どのフォントが指定されているのかを取得
				// フォント指定先である $target_key（ title とか body とか） にフォント指定情報が保存されていたら.
				if ( ! empty( $options[ $target_key ] ) ) {
					// 指定されているフォントのキーを$font_keyに格納.
					$font_key = $options[ $target_key ];

					// 指定されたフォントキーの実際のフォントファミリーの取得 と CSSの登録
					// そのフォントキーがフォントの配列に登録されていたら.
					if ( isset( $fonts_array[ $font_key ] ) ) {
						// 配列の中から実際のフォントファミリーを代入.
						$font_family = 'font-family:' . $fonts_array[ $font_key ]['font-family'] . ';';

						// Google Fonts など weight指定があるものは追加.
						$font_weight = '';
						if ( isset( $fonts_array[ $font_key ]['font-weight'] ) ) {
							$font_weight = 'font-weight:' . $fonts_array[ $font_key ]['font-weight'] . ';';
						}
						// 出力するCSSに登録.
						$dynamic_css .= $target_value['selector'] . '{ ' . $font_family . $font_weight . '}';
					}
				} // if ( ! empty( $options[ $target_key ] ) ) {
			}

			$dynamic_css = '/* Font switch */' . $dynamic_css;

			// delete before after space.
			$dynamic_css = trim( $dynamic_css );
			// convert tab and br to space.
			$dynamic_css = preg_replace( '/[\n\r\t]/', '', $dynamic_css );
			// Change multiple spaces to single space.
			$dynamic_css = preg_replace( '/\s(?=\s)/', '', $dynamic_css );
			// 出力を実行.
			wp_add_inline_style( $vk_font_selector_editor_style, $dynamic_css );
		}

		/**
		 * Print inline css to Front
		 *
		 * @return void
		 */
		public static function dynamic_header_css() {

			$selected_fonts_info = self::get_selected_fonts_info();
			$dynamic_css         = $selected_fonts_info['dynamic_css'];

			// 出力するインラインスタイルが存在していたら.
			if ( $dynamic_css ) {

				$dynamic_css = '/* Font switch */' . $dynamic_css;

				// delete before after space.
				$dynamic_css = trim( $dynamic_css );
				// convert tab and br to space.
				$dynamic_css = preg_replace( '/[\n\r\t]/', '', $dynamic_css );
				// Change multiple spaces to single space.
				$dynamic_css = preg_replace( '/\s(?=\s)/', '', $dynamic_css );

				// 出力を実行.
				global $vk_font_selector_enqueue_handle_style;
				wp_add_inline_style( $vk_font_selector_enqueue_handle_style, $dynamic_css );
			}

		} // public function skin_dynamic_css(){

		/**
		 * Load Web Font
		 *
		 * @return void
		 */
		public static function load_web_fonts() {
			$selected_fonts_info = self::get_selected_fonts_info();
			if ( ! empty( $selected_fonts_info['selected_webFonts'] ) ) {

				// 同じフォントでウェイト違いが入ってくるので、フォントごとにまとめた配列を生成する.
				foreach ( $selected_fonts_info['selected_webFonts'] as $key => $value ) {

					$family = $value['font-family-key'];
					if ( isset( $value['font-weight'] ) ) {
						$fonts[ $family ]['weight'][] = $value['font-weight'];
					} else {
						$fonts[ $family ] = '';
					}
				} // foreach ( $selected_fonts_info['selected_webFonts'] as $key => $value ) {

				// Googleに投げるパラメーターの生成.
				$family_parameter = '';
				$before_family    = '';
				$count_family     = 0;
				foreach ( $fonts as $family => $family_info ) {

					// font-familyが2つ目以降はセパレーターを追加.
					if ( $count_family ) {
						$family_parameter .= '|';
					}
					$family_parameter .= $family;

					// font-weight 指定がある場合.
					if ( isset( $family_info['weight'] ) && is_array( $family_info['weight'] ) ) {
						$count_weight      = 0;
						$family_parameter .= ':';
						foreach ( $family_info['weight'] as $key => $value ) {
									// font-weightが2つ目以降はセパレーターを追加.
							if ( $count_weight ) {
								$family_parameter .= ',';
							}
							$family_parameter .= $value;
							$count_weight++;
						}
					}

					$count_family++;
				}
				echo '<link href="https://fonts.googleapis.com/css?family=' . $family_parameter . '&display=swap" rel="stylesheet">';
			} // if ( ! empty( $selected_fonts_info['selected_webFonts'] ) ) {
		} // public function load_web_fonts() {

	} // class Vk_Font_Selector_Customize

	Vk_Font_Selector_Customize::init();

	// 外す時
	// add_action(
	// 'after_setup_theme', function() {
	// remove_action( 'customize_register', array( 'Vk_Font_Selector_Customize', 'register' ) );
	// remove_action( 'wp_head', array( 'Vk_Font_Selector_Customize', 'dynamic_header_css' ), 5 );
	// remove_action( 'wp_footer', array( 'Vk_Font_Selector_Customize', 'load_web_fonts' ) );
	// }
	// );

} // if ( ! class_exists( 'Vk_Font_Selector_Customize' ) ) {
