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

function haup_featured_image_height(){
	if(isset( GetOP01_blocktheme()['post-featured-image-height'] )){
		$image_h_preset = absint(GetOP01_blocktheme()['post-featured-image-height']);
	}else{
		$image_h_preset = '';
	}

	if(empty($image_h_preset) || !is_numeric($image_h_preset)){
	$image_height = absint(400);
}else{
	$image_height = absint($image_h_preset);
	}

$custom_css_pre = hau_sanitize_css('
/* HAUP Force Featured Image Height */
.wp-block-post-featured-image img{
	max-height: '.$image_height.'px;
	object-fit: cover;
	object-position: center;
}
');

//タブを除去
$custom_css_deltab = preg_replace('/\t+/', '', $custom_css_pre);
//改行を除去
$custom_css = str_replace(PHP_EOL, '', $custom_css_deltab);

wp_add_inline_style( 'haup-front-and-blocks-style', $custom_css );//frontend-option-styleの後にインラインで出力
wp_add_inline_style( 'wp-edit-blocks', $custom_css );//テーマエディターへインラインでCSS出力

}
add_action('init','haup_featured_image_height');//テーマエディターへ適用
add_action('wp_enqueue_scripts','haup_featured_image_height');//フロントエンドへ適用


