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


/*** テーマがウィジェット機能をサポートしていない場合のみウィジェット機能を有効化 ***/
if (!current_theme_supports('widgets')) {
	add_theme_support('widgets');
}

/*** ウィジェットエリア 01 ***/
/* ウィジェットエリアの追加 */
function haup_add_custom_widget_area_01() {
	$id = 'haup_custom_widget_area_01';
	$title = __('HAUP Widget 01','hima-art-utility');
	$description = __('To display the content of this widget area in your block theme, insert the following shortcode into your template:','hima-art-utility');
	$sc_code = '[ha-classic-widget-01]';
	$class = 'ha-cwidgets-wrap-01';

	register_sidebar( array(
		'name' => $title,
		'id' => $id,
		'description' => $description.$sc_code ,
		'class' => $class,
		'before_widget' => '<div class="ha-cwidgets-content">',
		'after_widget' => '</div>',
		'before_title' => '<h4 class="ha-cwidgets-title">',
		'after_title' => '</h4>',
		)
	);
}

if(isset( GetOP03_blocktheme()['add-classic-widget-01'] ) && GetOP03_blocktheme()['add-classic-widget-01'] == 1 ){
add_action( 'widgets_init', 'haup_add_custom_widget_area_01' );
}

/* custom_widgetショートコードでウィジェットの内容を出力 */
function haup_display_custom_widget_area_01() {
	ob_start();
	if (is_active_sidebar('haup_custom_widget_area_01')) {
		dynamic_sidebar('haup_custom_widget_area_01');
	}
	return ob_get_clean();
}

if(isset( GetOP03_blocktheme()['add-classic-widget-01'] ) && GetOP03_blocktheme()['add-classic-widget-01'] == 1 ){
add_shortcode('ha-classic-widget-01', 'haup_display_custom_widget_area_01');
}

/*** ウィジェットエリア 02 ***/
/* ウィジェットエリアの追加 */
function haup_add_custom_widget_area_02() {
	$id = 'haup_custom_widget_area_02';
	$title = __('HAUP Widget 02','hima-art-utility');
	$description = __('To display the content of this widget area in your block theme, insert the following shortcode into your template:','hima-art-utility');
	$sc_code = '[ha-classic-widget-02]';
	$class = 'ha-cwidgets-wrap-02';

	register_sidebar( array(
		'name' => $title,
		'id' => $id,
		'description' => $description.$sc_code ,
		'class' => $class,
		'before_widget' => '<div class="ha-cwidgets-content">',
		'after_widget' => '</div>',
		'before_title' => '<h4 class="ha-cwidgets-title">',
		'after_title' => '</h4>',
		)
	);
}

if(isset( GetOP03_blocktheme()['add-classic-widget-02'] ) && GetOP03_blocktheme()['add-classic-widget-02'] == 1 ){
add_action( 'widgets_init', 'haup_add_custom_widget_area_02' );
}

/* custom_widgetショートコードでウィジェットの内容を出力 */
function haup_display_custom_widget_area_02() {
	ob_start();
	if (is_active_sidebar('haup_custom_widget_area_02')) {
		dynamic_sidebar('haup_custom_widget_area_02');
	}
	return ob_get_clean();
}

if(isset( GetOP03_blocktheme()['add-classic-widget-02'] ) && GetOP03_blocktheme()['add-classic-widget-02'] == 1 ){
add_shortcode('ha-classic-widget-02', 'haup_display_custom_widget_area_02');
}

/*** ウィジェットエリア 03 ***/
/* ウィジェットエリアの追加 */
function haup_add_custom_widget_area_03() {
	$id = 'haup_custom_widget_area_03';
	$title = __('HAUP Widget 03','hima-art-utility');
	$description = __('To display the content of this widget area in your block theme, insert the following shortcode into your template:','hima-art-utility');
	$sc_code = '[ha-classic-widget-03]';
	$class = 'ha-cwidgets-wrap-03';

	register_sidebar( array(
		'name' => $title,
		'id' => $id,
		'description' => $description.$sc_code ,
		'class' => $class,
		'before_widget' => '<div class="ha-cwidgets-content">',
		'after_widget' => '</div>',
		'before_title' => '<h4 class="ha-cwidgets-title">',
		'after_title' => '</h4>',
		)
	);
}

if(isset( GetOP03_blocktheme()['add-classic-widget-03'] ) && GetOP03_blocktheme()['add-classic-widget-03'] == 1 ){
add_action( 'widgets_init', 'haup_add_custom_widget_area_03' );
}

/* custom_widgetショートコードでウィジェットの内容を出力 */
function haup_display_custom_widget_area_03() {
	ob_start();
	if (is_active_sidebar('haup_custom_widget_area_03')) {
		dynamic_sidebar('haup_custom_widget_area_03');
	}
	return ob_get_clean();
}

if(isset( GetOP03_blocktheme()['add-classic-widget-03'] ) && GetOP03_blocktheme()['add-classic-widget-03'] == 1 ){
add_shortcode('ha-classic-widget-03', 'haup_display_custom_widget_area_03');
}