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

/***** ブロックパターンカテゴリーの登録 *****/
/* コンテンツ作成ショートコードカテゴリー */
function haup_sc_pattern_cat_create_content_init(){
	register_block_pattern_category(
		'hima-art-utility/cat-create_content',
		['label' => __('HAU Add Content Shortcode','hima-art-utility')]
	);
}
add_action('init','haup_sc_pattern_cat_create_content_init');

/* 閲覧制限ショートコードカテゴリー */
function haup_sc_pattern_cat_restrict_display_init(){
	register_block_pattern_category(
		'hima-art-utility/cat-restrict_display',
		['label' => __('HAU Restrict Content Shortcode','hima-art-utility')]
	);
}
add_action('init','haup_sc_pattern_cat_restrict_display_init');

/* テーマショートコードカテゴリー */
function haup_sc_pattern_cat_for_theme_template_init(){
	register_block_pattern_category(
		'hima-art-utility/cat-for_theme_template',
		['label' => __('HAU For Theme Shortcode','hima-art-utility')]
	);
}
add_action('init','haup_sc_pattern_cat_for_theme_template_init');

/* リンク・シェアボタンショートコードカテゴリー */
function haup_sc_pattern_cat_link_share_init(){
	register_block_pattern_category(
		'hima-art-utility/cat-link_share',
		['label' => __('HAU Link and Share Shortcode','hima-art-utility')]
	);
}
add_action('init','haup_sc_pattern_cat_link_share_init');

/***** ブロックパターンの登録 *****/
/*** コンテンツ作成ショートコードカテゴリー hau-sc-pattern-cat-create_content ***/
/* 内包したコンテンツ全体をクリック可能にする */
function haup_wide_cover_link_sc_block_patterns_init(){
	$slug = 'hima-art-utility/wide-cover-link-sc-pattern';
	$title = __('A shortcode that makes the entire enclosed block clickable','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-create_content"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-cover-link url="https://example.com" target="_blank"]
			<!-- /wp:shortcode -->
			<!-- wp:shortcode -->
				[/ha-cover-link]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($slug, $pattern);
}
add_action('admin_init', 'haup_wide_cover_link_sc_block_patterns_init');

/* 囲み型ショートコードを使ったポップアップ */
function haup_enclose_popup_sc_block_patterns_init(){
	$slug = 'hima-art-utility/enclose-popup-sc-pattern';
	$title = __('Popup Use Enclosing shortcode','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-create_content"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-inline-popup title="" width=""]
			<!-- /wp:shortcode -->
			<!-- wp:shortcode -->
				[/ha-inline-popup]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($slug, $pattern);
}
add_action('admin_init', 'haup_enclose_popup_sc_block_patterns_init');

/* フリーワード検索 */
function haup_ajax_text_search_sc_block_patterns_init(){
	$title = __('Ajax Text Search Form','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-create_content"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-ajax-text-search]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_ajax_text_search_sc_block_patterns_init');

/* 投稿スライダー */
function haup_post_slider_sc_block_patterns_init(){
	$title = __('Post list Slider','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-create_content"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-post-slider post_type="" category="" speed="" delay="" per_page="" slides_768="" slides_1024="" slides_1200="" slides_1900="" orderby="" order="" class=""]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_post_slider_sc_block_patterns_init');

/*** 閲覧制限ショートコードカテゴリー hau-sc-pattern-cat-restrict_display ***/
/* ログインユーザーのみにコンテンツを表示 */
function haup_if_login_sc_block_patterns_init(){
	$title = __('Login user only','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-restrict_display"],
		"content" => '
			<!-- wp:shortcode -->
				[if-login]
			<!-- /wp:shortcode -->
			<!-- wp:shortcode -->
				[/if-login]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_if_login_sc_block_patterns_init');

/* 管理ユーザーのみにコンテンツを表示 */
function haup_if_admin_sc_block_patterns_init(){
	$title = __('Admin user only','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-restrict_display"],
		"content" => '
			<!-- wp:shortcode -->
				[if-admin]
			<!-- /wp:shortcode -->
			<!-- wp:shortcode -->
				[/if-admin]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_if_admin_sc_block_patterns_init');

/* モバイル表示時のみにコンテンツを表示 */
function haup_hab_mobile_sc_block_patterns_init(){
	$title = __('Mobile show only','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-restrict_display"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-mobile]
			<!-- /wp:shortcode -->
			<!-- wp:shortcode -->
				[/ha-mobile]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_hab_mobile_sc_block_patterns_init');

/* パソコン表示時のみコンテンツを表示 */
function haup_hab_pc_sc_block_patterns_init(){
	$title = __('PC show only','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-restrict_display"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-pc]
			<!-- /wp:shortcode -->
			<!-- wp:shortcode -->
				[/ha-pc]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_hab_pc_sc_block_patterns_init');

/* 投稿タイプによって制限 */
function haup_restrict_posttype_sc_block_patterns_init(){
	$title = __('Display only on specific post types (for block templates)','hima-art-utility');

	$pattern = [
		"title" =>$title,
		"categories" => ["hima-art-utility/cat-restrict_display"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-ptype posttype=""]
			<!-- /wp:shortcode -->
			<!-- wp:shortcode -->
				[/ha-ptype]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_restrict_posttype_sc_block_patterns_init');

/*** テーマショートコードカテゴリー hau-sc-pattern-cat-for_theme_template ***/
/* 画像スライダー */
function haup_image_slider_sc_block_patterns_init(){
	$title = __('Show Image Slider','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-for_theme_template"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-slide-image]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_image_slider_sc_block_patterns_init');

/* 景品表示法対応 */
function haup_ad_info_sc_block_patterns_init(){
	$title = __('Indicate that there is an advertisement in the content','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-for_theme_template"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-ad-info]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_ad_info_sc_block_patterns_init');

/* IEアクセス時の警告 */
function haup_ie_warning_sc_block_patterns_init(){
	$title = __('Warning when accessing IE','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-for_theme_template"],
		"content" => "
			<!-- wp:shortcode -->
				[ha-iew mes='']
			<!-- /wp:shortcode -->
		",
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_ie_warning_sc_block_patterns_init');

/* 年範囲でのクレジット表示 */
function haup_footer_credit_sc_block_patterns_init(){
	$title = __('Show Credit Content','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-for_theme_template"],
		"content" => '
			<!-- wp:shortcode -->
				[footer-credit textcolor=""]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_footer_credit_sc_block_patterns_init');

/* パンくずリスト */
function haup_hab_breadcrumb_sc_block_patterns_init(){
	$title = __('Breadcrumb List','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-for_theme_template"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-bread]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_hab_breadcrumb_sc_block_patterns_init');

/***** 前の投稿リンク *****/
function haup_prev_post_link_sc_block_patterns_init(){
	$title = __('Link to previous page (based on update date)','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-for_theme_template"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-prev-post]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_prev_post_link_sc_block_patterns_init');

/***** 次の投稿リンク *****/
function haup_next_post_link_sc_block_patterns_init(){
	$title = __('Link to next page (based on update date)','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-for_theme_template"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-next-post]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_next_post_link_sc_block_patterns_init');

/***** 子カテゴリーの一覧 *****/
function haup_category_by_parent_sc_block_patterns_init(){
	$title = __('Category List by Parent','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-for_theme_template"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-cat-list parentid="" hideparent="" hidenull=""]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_category_by_parent_sc_block_patterns_init');

/* 前ページへ戻るリンクを表示 */
function haup_return_page_sc_block_patterns_init(){
	$title = __('Show Previous Page Link','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-for_theme_template"],
		"content" => '
			<!-- wp:shortcode -->
				[return-page]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_return_page_sc_block_patterns_init');

/*** リンク・シェアボタンショートコードカテゴリー hau-sc-pattern-cat-link_share ***/
/* OGPリンクカード */
function haup_ogp_linkcard_sc_block_patterns_init(){
	$title = __('External Link Card','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-link_share"],
		"content" => "
		<!-- wp:shortcode -->
			[ha-linkcard url='' title='' excerpt='' alt='' load='']
		<!-- /wp:shortcode -->
		",
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_ogp_linkcard_sc_block_patterns_init');

/* URLのスクリーンショット表示 */
function haup_ha_sshot_sc_block_patterns_init(){
	$title = __('Take screenshot','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-link_share"],
		"content" => "
			<!-- wp:shortcode -->
				[ha-sshot url='' alt='' title = '' w='' h='' load='']
			<!-- /wp:shortcode -->
		",
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_ha_sshot_sc_block_patterns_init');


/* REST APIを使ったリストカード（複数サイト対応） */
function haup_api_multisite_post_list_card_sc_block_patterns_init(){
	$title = __('REST API Post List (Multiple Site & Card Type)','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-link_share"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-latest-posts-with-thumbnails sites="" number="" order_by="" display_count="" cache_time="" datetext="" des="" offset="" size="" column=""]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_api_multisite_post_list_card_sc_block_patterns_init');

/* REST APIを使ったリスト シンプル（複数サイト対応） */
function haup_api_multisite_post_list_simple_sc_block_patterns_init(){
	$title = __('REST API Post List (Multiple Site & Simple List)','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-link_share"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-latest-posts-simple sites="" number="" order_by="" display_count="" cache_time="" datetext="" des="" offset=""]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_api_multisite_post_list_simple_sc_block_patterns_init');


/* REST APIを使ったリストカード */
function haup_api_post_list_card_sc_block_patterns_init(){
	$title = __('REST API Post List (Card Type)','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-link_share"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-apipostlist-card home_url="" posttype="" num="" offset="" cache-second="0" orderby="modified" type="" des="" datetext=""]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_api_post_list_card_sc_block_patterns_init');

/* REST APIを使ったリスト シンプル */
function haup_api_post_list_simple_sc_block_patterns_init(){
	$title = __('REST API Post List (Simple List)','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-link_share"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-apipostlist-simple home_url="" posttype="" num="" offset="" cache-second="0" orderby="modified" datetext=""]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_api_post_list_simple_sc_block_patterns_init');

/* プライバシーポリシーページリンク */
function haup_pp_link_sc_block_patterns_init(){
	$title = __('Link to privacy policy page','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-link_share"],
		"content" => "
			<!-- wp:shortcode -->
				[ha-pplink]
			<!-- /wp:shortcode -->
		",
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_pp_link_sc_block_patterns_init');

/* シェアボタンを表示 */
function haup_hab_share_button_sc_block_patterns_init(){
	$title = __('Show share content','hima-art-utility');

	$pattern = [
		"title" => $title,
		"categories" => ["hima-art-utility/cat-link_share"],
		"content" => '
			<!-- wp:shortcode -->
				[ha-share type="" width="" margin="" lm="" rm=""]
			<!-- /wp:shortcode -->
		',
	];

	register_block_pattern($pattern["title"], $pattern);
}
add_action('admin_init', 'haup_hab_share_button_sc_block_patterns_init');


/*** その他ショートコードカテゴリー hau-sc-pattern-cat-others ***/

