<?php

function presspioneer_magazine_pattern_styles()
{
	wp_enqueue_style('presspioneer-magazine-patterns', get_stylesheet_directory_uri() . '/assets/css/patterns.css', array(), filemtime(get_template_directory() . '/assets/css/patterns.css'));
	if (is_admin()) {
		global $pagenow;
		if ('site-editor.php' === $pagenow) {
			// Do not enqueue editor style in site editor
			return;
		}
		wp_enqueue_style('presspioneer-magazine-editor', get_stylesheet_directory_uri() . '/assets/css/editor.css', array(), filemtime(get_template_directory() . '/assets/css/editor.css'));
	}
}
add_action('enqueue_block_assets', 'presspioneer_magazine_pattern_styles');


add_theme_support('wp-block-styles');

// Removes the default wordpress patterns
add_action('init', function () {
	remove_theme_support('core-block-patterns');
});

// Register customer PressPioneer Magazine pattern categories
function presspioneer_magazine_register_block_pattern_categories()
{
	register_block_pattern_category(
		'layout',
		array(
			'label'       => __('Layout', 'presspioneer-magazine'),
			'description' => __('PressPioneer Magazine layout patterns', 'presspioneer-magazine'),
		)
	);
	register_block_pattern_category(
		'Content',
		array(
			'label'       => __('Content', 'presspioneer-magazine'),
			'description' => __('PressPioneer Magazine content patterns', 'presspioneer-magazine'),
		)
	);
	register_block_pattern_category(
		'Contact',
		array(
			'label'       => __('Contact', 'presspioneer-magazine'),
			'description' => __('PressPioneer Magazine contact patterns', 'presspioneer-magazine'),
		)
	);
}

add_action('init', 'presspioneer_magazine_register_block_pattern_categories');