<?php

/*PATTERNS CATEGORY*/
add_action( 'init', 'monowp_register_pattern_category' );
function monowp_register_pattern_category() {
	register_block_pattern_category(
		'monowp/theme',
		array(
			'label'       => __( 'Theme', 'monowp' ),
			'description' => __( 'MonoWP Theme Patterns', 'monowp' ),
		)
	);
}

/*PATTERNS CONTENTS*/
function monowp_get_pattern_content( $pattern ) {
	$pattern = basename( $pattern );
	ob_start();
	include get_parent_theme_file_path( "patterns/contents/{$pattern}.php" );
	return ob_get_clean();
}

/*BLOCK PATTERNS*/
add_action( 'init', 'monowp_register_patterns' );
function monowp_register_patterns() {

	/*Cover*/
	register_block_pattern(
		'monowp/cover',
		array(
			'title'       => __( 'Cover', 'monowp' ),
			'categories'  => array( 'monowp/theme', 'featured', 'banner', 'call-to-action', 'header', 'text', 'media', 'buttons', 'columns' ),
			'description' => 'Cover image section that covers the entire width, with a title, a paragraph, and a CTA button.',
			'source'      => 'theme',
			'content'     => monowp_get_pattern_content( 'cover' ),
		)
	);

	/*CTA*/
	register_block_pattern(
		'monowp/call-to-action',
		array(
			'title'       => __( 'Call To Action', 'monowp' ),
			'categories'  => array( 'monowp/theme', 'featured', 'banner', 'call-to-action', 'header', 'text', 'media', 'buttons', 'columns' ),
			'description' => 'Title, paragraph, two CTA buttons, and an image for a general CTA section.',
			'source'      => 'theme',
			'content'     => monowp_get_pattern_content( 'call-to-action' ),
		)
	);

	/*Banner*/
	register_block_pattern(
		'monowp/banner',
		array(
			'title'       => __( 'Banner', 'monowp' ),
			'categories'  => array( 'monowp/theme', 'featured', 'text', 'media', 'columns', 'banner', 'about', 'portfolio' ),
			'description' => 'Banner section with title, paragraph, and an image.',
			'source'      => 'theme',
			'content'     => monowp_get_pattern_content( 'banner' ),
		)
	);

	/*RSVP*/
	register_block_pattern(
		'monowp/rsvp',
		array(
			'title'       => __( 'RSVP', 'monowp' ),
			'categories'  => array( 'monowp/theme', 'featured', 'text', 'media', 'columns', 'video', 'call-to-action', 'header' ),
			'description' => 'Large RSVP heading sideways, a description, a CTA button and a video.',
			'source'      => 'theme',
			'content'     => monowp_get_pattern_content( 'rsvp' ),
		)
	);

	/*Gallery*/
	register_block_pattern(
		'monowp/gallery',
		array(
			'title'       => __( 'Gallery', 'monowp' ),
			'categories'  => array( 'monowp/theme', 'featured', 'text', 'media', 'columns', 'gallery', 'portfolio' ),
			'description' => 'Gallery section with a grid layout with 2 images.',
			'source'      => 'theme',
			'content'     => monowp_get_pattern_content( 'gallery' ),
		)
	);

	/*Pricing*/
	register_block_pattern(
		'monowp/pricing',
		array(
			'title'       => __( 'Pricing', 'monowp' ),
			'categories'  => array( 'monowp/theme', 'call-to-action', 'services' ),
			'description' => 'Pricing section with a title, a paragraph and three pricing levels.',
			'source'      => 'theme',
			'content'     => monowp_get_pattern_content( 'pricing' ),
		)
	);

	/*Testimonial*/
	register_block_pattern(
		'monowp/testimonial',
		array(
			'title'       => __( 'Testimonial', 'monowp' ),
			'categories'  => array( 'monowp/theme', 'testimonials', 'text' ),
			'description' => 'Centered testimonial section with a avatar, name, and job title.',
			'source'      => 'theme',
			'content'     => monowp_get_pattern_content( 'testimonial' ),
		)
	);

	/*FAQs*/
	register_block_pattern(
		'monowp/faqs',
		array(
			'title'       => __( 'FAQs', 'monowp' ),
			'categories'  => array( 'monowp/theme', 'text', 'about', 'featured' ),
			'description' => 'FAQs section with a large FAQ heading and list of toggle questions and answers.',
			'source'      => 'theme',
			'content'     => monowp_get_pattern_content( 'faqs' ),
		)
	);
}
