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

function haup_register_add_custom_block_design_styles(){
/* 段落 */
if(isset( GetOP02_blockoption()['paragraph-tag-style'] ) && !empty( GetOP02_blockoption()['paragraph-tag-style'] )){
	register_block_style('core/paragraph', array(
	'name' =>  'paragraph-custom',
	'label' => __( 'Custom','hima-art-utility'),
  ));
}

/* 見出し */
if(isset( GetOP01_blockoption()['headline-tag-style'] ) && !empty( GetOP01_blockoption()['headline-tag-style'] )){
	register_block_style('core/heading', array(
	'name' =>  'head-custom',
	'label' => __( 'Custom','hima-art-utility'),
  ));
}
}
add_action('init','haup_register_add_custom_block_design_styles');

function haup_custom_header_design_style_init(){

/* ヘッダー用 */
if(isset( GetOP01_blockoption()['headline-tag-style'] )){
	$option_header = GetOP01_blockoption()['headline-tag-style'];
}else{
	$option_header = '';
}

//タブを除去
$custom_css_deltab_header = preg_replace('/\t+/', '', $option_header);
//改行を除去
$custom_css_header_pre = str_replace("\r\n", '', $custom_css_deltab_header); 

$custom_css_header ='/* HAUP Custom Heading */'.$custom_css_header_pre;

if(!empty( $option_header )){
//追加したスタイルコードをインライン出力
	wp_add_inline_style( 'haup-front-and-blocks-style', $custom_css_header );
//追加したスタイルコードをサイトエディタ側へインライン出力
	if(is_admin()){
		wp_add_inline_style( 'wp-edit-blocks', $custom_css_header );
	}
}
}
add_action( 'init', 'haup_custom_header_design_style_init');
add_action( 'wp_enqueue_scripts', 'haup_custom_header_design_style_init');

function haup_custom_paragraph_design_style_init(){
/* 段落用 */
if(isset( GetOP02_blockoption()['paragraph-tag-style'] )){
	$option_paragraph = GetOP02_blockoption()['paragraph-tag-style'];
}else{
	$option_paragraph = '';
}

//タブを除去
$custom_css_deltab_paragraph = preg_replace('/\t+/', '', $option_paragraph);
//改行を除去
$custom_css_paragraph_pre = str_replace("\r\n", '', $custom_css_deltab_paragraph);

$custom_css_paragraph ='/* HAUP Custom Paragraph */'.$custom_css_paragraph_pre;
if(!empty( $option_paragraph )){
//追加したスタイルコードをインライン出力
	wp_add_inline_style( 'haup-front-and-blocks-style', $custom_css_paragraph );
//追加したスタイルコードをサイトエディタ側へインライン出力
	if(is_admin()){
		wp_add_inline_style( 'wp-edit-blocks', $custom_css_paragraph );
	}
}

}
add_action( 'init', 'haup_custom_paragraph_design_style_init');
add_action( 'wp_enqueue_scripts', 'haup_custom_paragraph_design_style_init');