<?php
/**
 * Register theme specific block pattern categories.
 *
 * @package Abc Studio
 * @since 1.0.0
 */
function abc_studio_register_block_patterns() {

	register_block_pattern_category(
		'abc_studio_pattern',
		array(
			'label'       => _x( 'Design Lab Patterns', 'Block pattern category', 'abc-studio' ),
			'description' => __ ( 'A collection of professionally designed patterns.', 'abc-studio'),
		)
	);

	register_block_pattern_category(
		'abc_studio_hero_pattern',
		array(
			'label'       => _x( 'Hero', 'Block pattern category', 'abc-studio' ),
			'description' => __( 'A collection of Hero Sections, the first part of your website under your logo and menu.', 'abc-studio' ),
		)
	);

	register_block_pattern_category(
		'abc_studio_page',
		array(
			'label'       => _x( 'Design Lab Page Layouts', 'Block pattern category', 'abc-studio' ),
			'description' => __( 'A collection of full page layouts.', 'abc-studio' ),
		)
	);

}
add_action( 'init', 'abc_studio_register_block_patterns' );


/**
 * Register block styles.
 *
 * @package Abc Studio
 * @since 1.0.0
 */
if ( function_exists( 'register_block_style' ) ) {

	function abc_studio_register_block_styles() {

		// Post Terms
		register_block_style( 'core/post-terms', array(
			'name'  	=> 'dl-pill-shape',
			'label' 	=> esc_html__( 'Pill shape', 'abc-studio' ),
			'inline_style' => '
			.wp-block-post-terms.is-style-dl-pill-shape a {
				display: inline-flex;
				position: relative;
				padding: 0.25em 1em;
				text-decoration: none;
			}
			.wp-block-post-terms.is-style-dl-pill-shape a:before {
				content: "";
				background: var(--wp--preset--color--contrast);
				width: 100%;
				height: 100%;
				position: absolute;
				left: 0;
				top: 0;
				border-radius: 32px;
				opacity: 0.07;
				transition: opacity .25s ease;
			}
			.wp-block-post-terms.is-style-dl-pill-shape a:hover {
				opacity: 0.8;
			}
			.wp-block-post-terms.is-style-dl-pill-shape .wp-block-post-terms__separator {
				visibility: hidden;
			}',
		) );

		// Post Terms
		register_block_style( 'core/post-terms', array(
			'name'  	=> 'dl-outline-pill-shape',
			'label' 	=> esc_html__( 'Outline Pill shape', 'abc-studio' ),
			'inline_style' => '
			.wp-block-post-terms.is-style-dl-outline-pill-shape a {
				display: inline-flex;
				position: relative;
				padding: 0.25em 1em;
				text-decoration: none;
				border: 1px solid currentColor;
				border-radius: 32px;
				opacity: 1;
				transition: opacity .25s ease;
			}
			.wp-block-post-terms.is-style-dl-outline-pill-shape a:hover {
				opacity: .8;
				text-decoration: none;
			}
			.wp-block-post-terms.is-style-dl-outline-pill-shape .wp-block-post-terms__separator {
				visibility: hidden;
			}',
		) );

		// List
		register_block_style(
			'core/list',
			array(
				'name'  => 'dl-check-list',
				'label' => esc_html__( 'Check list', 'abc-studio' ),
				'inline_style' => '
				html {
					--dl-check-icon: url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 64 64"><path d="M43.4,24.6c.8.8.8,2,0,2.8,0,0,0,0,0,0l-14,14c-.8.8-2,.8-2.8,0,0,0,0,0,0,0l-6-6c-.8-.8-.8-2,0-2.8.8-.8,2-.8,2.8,0l4.6,4.6,12.6-12.6c.8-.8,2-.8,2.8,0,0,0,0,0,0,0ZM58,32c0,14.4-11.6,26-26,26S6,46.4,6,32,17.6,6,32,6c14.4,0,26,11.6,26,26ZM54,32c0-12.2-9.8-22-22-22s-22,9.8-22,22,9.8,22,22,22c12.1,0,22-9.9,22-22Z"/></svg>\')
				}
				.is-style-dl-check-list {
					list-style-type: none;
					line-height: var(--wp--custom--typography--line-height--medium);
					padding: 0 0 0 1em;
				}
				.is-style-dl-check-list li {
					position: relative;
					padding-left: 2em;
				}
				.is-style-dl-check-list li:not(:first-child) {
					margin-top: 0.5em;
				}
				.is-style-dl-check-list li:before {
					content: " ";
					display: block;
					width: 24px;
					height: 24px;
					position: absolute;
					left: 0;
					top: 2px;
					-webkit-mask-position: center;
					mask-position: center;
					-webkit-mask-repeat: no-repeat;
					mask-repeat: no-repeat;
					background-color: currentColor;
					-webkit-mask-image: var(--dl-check-icon);
					mask-image: var(--dl-check-icon);
				}',
			)
		);

		register_block_style(
			'core/list',
			array(
				'name'  => 'dl-arrow-list',
				'label' => esc_html__( 'Arrow list', 'abc-studio' ),
				'inline_style' => '
				html {
					--dl-arrow-icon: url(\'data:image/svg+xml,<svg version="1.0" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 44 22"><path fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" d="M34.6,3.2l7.8,7.8l-7.8,7.8"/><path fill="none" stroke="currentColor" stroke-width="2" stroke-linejoin="round" d="M1.6,11h39.5"/></svg>\')
				}
				.is-style-dl-arrow-list {
					list-style-type: none;
					line-height: var(--wp--custom--typography--line-height--medium);
					padding: 0;
				}
				.is-style-dl-arrow-list li {
					position: relative;
					padding-left: 2.5em;
				}
				.is-style-dl-arrow-list li:not(:first-child) {
					margin-top: .5em;
				}
				.is-style-dl-arrow-list li:before {
					content: " ";
					display: block;
					width: 32px;
					height: 16px;
					position: absolute;
					left: 0;
					top: 8px;
					-webkit-mask-position: center;
					mask-position: center;
					-webkit-mask-repeat: no-repeat;
					mask-repeat: no-repeat;
					background-color: currentColor;
					-webkit-mask-image: var(--dl-arrow-icon);
					mask-image: var(--dl-arrow-icon);
				}',
			)
		);

		// Details
		register_block_style(
			'core/details',
			array(
				'name'         => 'dl-plus-icon-details',
				'label'        => __( 'Plus icon', 'abc-studio' ),
				'inline_style' => '
				.is-style-dl-plus-icon-details {
					padding: var(--wp--preset--spacing--20);
				}
				.is-style-dl-plus-icon-details summary {
					outline: 0;
					list-style-type: "\002B\00a0\00a0";
				}
				.is-style-dl-plus-icon-details[open] > summary {
					list-style-type: "\2212\00a0\00a0";
				}
				.is-style-dl-plus-icon-details summary::marker {
					font-size: 1.5em;
					line-height: 1;
				}',
			)
		);

		// Separator
		register_block_style(
			'core/separator',
			array(
				'name'  => 'dl-small-dots',
				'label' => esc_html__( 'Grid of dots x1', 'abc-studio' ),
				'inline_style' => '
				html {
					--dl-dots-small: url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 52 52"><circle cx="2" cy="2" r="2"></circle> <circle cx="2" cy="18" r="2"></circle> <circle cx="2" cy="34" r="2"></circle> <circle cx="2" cy="50" r="2"></circle> <circle cx="18" cy="50" r="2"></circle> <circle cx="34" cy="50" r="2"></circle> <circle cx="50" cy="50" r="2"></circle> <circle cx="18" cy="34" r="2"></circle> <circle cx="34" cy="34" r="2"></circle> <circle cx="50" cy="34" r="2"></circle> <circle cx="18" cy="18" r="2"></circle> <circle cx="34" cy="18" r="2"></circle> <circle cx="50" cy="18" r="2"></circle> <circle cx="18" cy="2" r="2"></circle> <circle cx="34" cy="2" r="2"></circle> <circle cx="50" cy="2" r="2"></circle></svg>\');
				}
				hr.wp-block-separator.is-style-dl-small-dots {
					width: 52px !important;
					height: 52px !important;
					background-color: unset !important;
					border: 0;
					color: inherit;
					margin-left: 0;
					margin-right: 0;
					transform: none;
				}
				hr.wp-block-separator.is-style-dl-small-dots:before {
					content: "";
					display: block;
					height: inherit;
					width: inherit;
					mask-image: var(--dl-dots-small);
					mask-repeat: no-repeat;
					background-color: currentColor;
				}',
			)
		);

		register_block_style(
			'core/separator',
			array(
				'name'  => 'dl-medium-dots',
				'label' => esc_html__( 'Grid of dots x3', 'abc-studio' ),
				'inline_style' => '
				html {
					--dl-dots-medium: url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 180 52"><circle cx="2" cy="2" r="2"></circle> <circle cx="66" cy="2" r="2"></circle> <circle cx="130" cy="2" r="2"></circle> <circle cx="2" cy="18" r="2"></circle> <circle cx="66" cy="18" r="2"></circle> <circle cx="130" cy="18" r="2"></circle> <circle cx="2" cy="34" r="2"></circle> <circle cx="66" cy="34" r="2"></circle> <circle cx="130" cy="34" r="2"></circle> <circle cx="2" cy="50" r="2"></circle> <circle cx="66" cy="50" r="2"></circle> <circle cx="130" cy="50" r="2"></circle> <circle cx="18" cy="50" r="2"></circle> <circle cx="82" cy="50" r="2"></circle> <circle cx="146" cy="50" r="2"></circle> <circle cx="34" cy="50" r="2"></circle> <circle cx="98" cy="50" r="2"></circle> <circle cx="162" cy="50" r="2"></circle> <circle cx="50" cy="50" r="2"></circle> <circle cx="114" cy="50" r="2"></circle> <circle cx="178" cy="50" r="2"></circle> <circle cx="18" cy="34" r="2"></circle> <circle cx="82" cy="34" r="2"></circle> <circle cx="146" cy="34" r="2"></circle> <circle cx="34" cy="34" r="2"></circle> <circle cx="98" cy="34" r="2"></circle> <circle cx="162" cy="34" r="2"></circle> <circle cx="50" cy="34" r="2"></circle> <circle cx="114" cy="34" r="2"></circle> <circle cx="178" cy="34" r="2"></circle> <circle cx="18" cy="18" r="2"></circle> <circle cx="82" cy="18" r="2"></circle> <circle cx="146" cy="18" r="2"></circle> <circle cx="34" cy="18" r="2"></circle> <circle cx="98" cy="18" r="2"></circle> <circle cx="162" cy="18" r="2"></circle> <circle cx="50" cy="18" r="2"></circle> <circle cx="114" cy="18" r="2"></circle> <circle cx="178" cy="18" r="2"></circle> <circle cx="18" cy="2" r="2"></circle> <circle cx="82" cy="2" r="2"></circle> <circle cx="146" cy="2" r="2"></circle> <circle cx="34" cy="2" r="2"></circle> <circle cx="98" cy="2" r="2"></circle> <circle cx="162" cy="2" r="2"></circle> <circle cx="50" cy="2" r="2"></circle> <circle cx="114" cy="2" r="2"></circle> <circle cx="178" cy="2" r="2"></circle></svg>\');
				}
				hr.wp-block-separator.is-style-dl-medium-dots {
					width: 180px !important;
					height: 52px !important;
					background-color: unset !important;
					border: 0;
					color: inherit;
					margin-left: 0;
					margin-right: 0;
					transform: none;
				}
				hr.wp-block-separator.is-style-dl-medium-dots:before {
					content: "";
					display: block;
					height: inherit;
					width: inherit;
					mask-image: var(--dl-dots-medium);
					mask-repeat: repeat-x;
					background-color: currentColor;
				}',
			)
		);

		register_block_style(
			'core/separator',
			array(
				'name'  => 'dl-arrows',
				'label' => esc_html__( 'Three Arrows', 'abc-studio' ),
				'inline_style' => '
				html {
					--dl-arrows: url(\'data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 52 24"><path d="M19.9839,23.9791c.0996.0399.1878.0228.2646-.0512l11.8416-11.7591c.0484-.0483.0711-.1052.0711-.1707,0-.0655-.0228-.1224-.0711-.1707L20.2513.0683c-.0484-.0455-.1024-.0683-.1707-.0683-.0313,0-.0626.0057-.091.0171-.0996.0398-.1508.1138-.1508.2219v23.5181c0,.1053.0484.1793.1451.2219ZM.6111,23.7571V.239c0-.1082.0484-.1821.1479-.2219.0285-.0114.0597-.0171.0939-.0171.0654,0,.1223.0228.1679.0683l11.8416,11.7591c.0455.0483.0683.1052.0683.1707,0,.0654-.0228.1223-.0683.1707L1.018,23.9279c-.0768.0712-.1622.0854-.2589.0455-.0967-.0398-.1451-.111-.1479-.2162ZM39.0664,23.7571V.239c0-.1082.0512-.1821.1508-.2219.0284-.0114.0597-.0171.091-.0171.0683,0,.1252.0228.1707.0683l11.8387,11.7591c.0484.0483.0711.1052.0711.1707,0,.0654-.0228.1223-.0711.1707l-11.8387,11.7591c-.074.074-.1622.0911-.2617.0512-.0996-.0398-.1508-.1138-.1508-.2219Z"/></svg>\');
				}
				hr.wp-block-separator.is-style-dl-arrows {
					width: 52px !important;
					height: 24px !important;
					background-color: unset !important;
					border: 0;
					color: inherit;
					margin-left: 0;
					margin-right: 0;
					transform: none;
				}
				hr.wp-block-separator.is-style-dl-arrows:before {
					content: "";
					display: block;
					height: inherit;
					width: inherit;
					mask-image: var(--dl-arrows);
					mask-repeat: repeat-x;
					background-color: currentColor;
				}',
			)
		);

	}
	add_action( 'init', 'abc_studio_register_block_styles' );
}


/**
 * Add About Page
 * @package Abc Studio
 * @since 1.0.0
 */
require_once get_template_directory() . '/inc/about-page/about-abc-studio.php';


/**
 * Add Upsell notice
 * @package Abc Studio
 * @since 1.0.0
 */
function abc_studio_notice() {
	$user_id = get_current_user_id();
	if ( ! get_user_meta( $user_id, 'abc_studio_notice_dismissed' ) ) {
	?>
	<div class="updated notice notice-success is-dismissible abc-studio-admin-notice">
		<h2 class="welcome-title">
			<?php esc_html_e( 'Welcome! Thank you for choosing ABC Studio WordPress Theme', 'abc-studio' ); ?>
		</h2>
		<p>
			<?php echo wp_kses_post( __( '<strong>To fully take advantage</strong> of the best our theme can offer, please visit our', 'abc-studio' ) ); ?> <a href="<?php echo esc_url( admin_url( 'themes.php?page=about_abc_studio' ) ); ?>"><strong><?php esc_html_e( 'Welcome Page', 'abc-studio' ); ?></strong></a>
		</p>
		<p>
			<a class="button button-primary" href="<?php echo esc_url( 'https://www.designlabthemes.com/abc-studio-pro-wordpress-theme/?utm_source=WordPress&utm_medium=notice&utm_campaign=abc_studio_upsell' ); ?>" target="_blank">
				<?php esc_html_e( 'View ABC Studio Pro', 'abc-studio' ); ?>
			</a>
			<a style="color: #646970;margin-left: 0.5em;" href="<?php echo esc_url( '?abc-studio-dismissed' ); ?>">
				<?php esc_html_e( 'Dismiss', 'abc-studio' ); ?>
			</a>
		</p>
	</div>
	<?php
	}
}
add_action( 'admin_notices', 'abc_studio_notice' );

function abc_studio_notice_dismissed() {
	$user_id = get_current_user_id();
	if ( isset( $_GET['abc-studio-dismissed'] ) ) {
		add_user_meta( $user_id, 'abc_studio_notice_dismissed', 'true', true );
	}
}
add_action( 'admin_init', 'abc_studio_notice_dismissed' );
