<?php

/**
 * Register Block Pattern Category
 */

// Hook
add_action('init', 'soledad_blog_lite_block_pattern_category');

// Callback
if (! function_exists('soledad_blog_lite_block_pattern_category')) :
  function soledad_blog_lite_block_pattern_category()
  {

    register_block_pattern_category(
      'soledad-blog-lite-patterns',
      array(
        'label'       => __('soledad Blog Lite Patterns', 'soledad-blog-lite'),
        'description' => __('Patterns for soledad Blog Lite', 'soledad-blog-lite'),
      )
    );
  }
endif;



if ( ! function_exists( 'soledad_blog_lite_setup' ) ) :
	/**
	 * Sets up theme defaults and registers support for various WordPress features.
	 *
	 * Note that this function is hooked into the after_setup_theme hook, which
	 * runs before the init hook. The init hook is too late for some features, such
	 * as indicating support for post thumbnails.
	 */
	function soledad_blog_lite_setup() {
		/*
		 * Make theme available for translation.
		 * Translations can be filed in the /languages/ directory.
		 * If you're building a theme based on Kortez Agency FSE, use a find and replace
		 * to change 'kortez-agency-fse' to the name of your theme in all the template files.
		 */
		load_theme_textdomain( 'soledad-blog-lite', get_template_directory() . '/languages' );

		// Add default posts and comments RSS feed links to head.
		add_theme_support( 'automatic-feed-links' );

		add_theme_support( 'align-wide' );

		// Add support for block styles.
		add_theme_support( 'wp-block-styles' );
	}
endif;
add_action( 'after_setup_theme', 'soledad_blog_lite_setup' );

/**
 * Register Block Styles
 */

// Hook
add_action('init', 'soledad_blog_lite_block_styles');

// Callback
if (! function_exists('soledad_blog_lite_block_styles')) :
  function soledad_blog_lite_block_styles()
  {
    // Block: core/details
    // Style: Primary
    // Via: Block Style
    register_block_style(
      'core/details',
      array(
        'name'  => 'details-1',
        'label' => __('Plus', 'soledad-blog-lite'),
      )
    );

    // Block: core/image, core/post-featured-image
    // Style: Shine
    // Via: Block Style
    register_block_style(
      ['core/image', 'core/post-featured-image'],
      array(
        'name'  => 'image-shine',
        'label' => __('Shine', 'soledad-blog-lite'),
      )
    );
  }
endif;

/**
 * Enqueue Block Stylesheets.
 */

// Hook
add_action('init', 'soledad_blog_lite_block_stylesheets');

// Callback
if (! function_exists('soledad_blog_lite_block_stylesheets')) :
  function soledad_blog_lite_block_stylesheets()
  {

    // Block: core/button
    $asset = include get_parent_theme_file_path('public/css/button.asset.php');
    wp_enqueue_block_style(
      'core/button',
      array(
        'handle' => 'soledad-blog-lite-button-style',
        'src'    => get_parent_theme_file_uri('public/css/button.css'),
        'deps'   => $asset['dependencies'],
        'ver'    => $asset['version'],
        'path'   => get_parent_theme_file_path('public/css/button.css'),
      )
    );

    // Block: core/columns
    $asset = include get_parent_theme_file_path('public/css/columns.asset.php');
    wp_enqueue_block_style(
      'core/columns',
      array(
        'handle' => 'soledad-blog-lite-columns-style',
        'src'    => get_parent_theme_file_uri('public/css/columns.css'),
        'deps'   => $asset['dependencies'],
        'ver'    => $asset['version'],
        'path'   => get_parent_theme_file_path('public/css/columns.css'),
      )
    );

    // Block: core/cover
    $asset = include get_parent_theme_file_path('public/css/cover.asset.php');
    wp_enqueue_block_style(
      'core/cover',
      array(
        'handle' => 'soledad-blog-lite-cover-style',
        'src'    => get_parent_theme_file_uri('public/css/cover.css'),
        'deps'   => $asset['dependencies'],
        'ver'    => $asset['version'],
        'path'   => get_parent_theme_file_path('public/css/cover.css'),
      )
    );

    // Block: core/group
    $asset = include get_parent_theme_file_path('public/css/group.asset.php');
    wp_enqueue_block_style(
      'core/group',
      array(
        'handle' => 'soledad-blog-lite-group-style',
        'src'    => get_parent_theme_file_uri('public/css/group.css'),
        'deps'   => $asset['dependencies'],
        'ver'    => $asset['version'],
        'path'   => get_parent_theme_file_path('public/css/group.css'),
      )
    );

    // Block: core/image
    $asset = include get_parent_theme_file_path('public/css/image.asset.php');
    wp_enqueue_block_style(
      'core/image',
      array(
        'handle' => 'soledad-blog-lite-image-style',
        'src'    => get_parent_theme_file_uri('public/css/image.css'),
        'deps'   => $asset['dependencies'],
        'ver'    => $asset['version'],
        'path'   => get_parent_theme_file_path('public/css/image.css'),
      )
    );

    // Block: core/navigation
    $asset = include get_parent_theme_file_path('public/css/navigation.asset.php');
    wp_enqueue_block_style(
      'core/navigation',
      array(
        'handle' => 'soledad-blog-lite-navigation-style',
        'src'    => get_parent_theme_file_uri('public/css/navigation.css'),
        'deps'   => $asset['dependencies'],
        'ver'    => $asset['version'],
        'path'   => get_parent_theme_file_path('public/css/navigation.css'),
      )
    );

    // Block: core/paragraph
    $asset = include get_parent_theme_file_path('public/css/paragraph.asset.php');
    wp_enqueue_block_style(
      'core/paragraph',
      array(
        'handle' => 'soledad-blog-lite-paragraph-style',
        'src'    => get_parent_theme_file_uri('public/css/paragraph.css'),
        'deps'   => $asset['dependencies'],
        'ver'    => $asset['version'],
        'path'   => get_parent_theme_file_path('public/css/paragraph.css'),
      )
    );

    // Block: core/post-featured-image
    $asset = include get_parent_theme_file_path('public/css/post-featured-image.asset.php');
    wp_enqueue_block_style(
      'core/post-featured-image',
      array(
        'handle' => 'soledad-blog-lite-post-featured-image-style',
        'src'    => get_parent_theme_file_uri('public/css/post-featured-image.css'),
        'deps'   => $asset['dependencies'],
        'ver'    => $asset['version'],
        'path'   => get_parent_theme_file_path('public/css/post-featured-image.css'),
      )
    );
  }
endif;

/**
 * Load front-end assets.
 */

// Hook
add_action('wp_enqueue_scripts', 'soledad_blog_lite_assets');

// Callback
if (! function_exists('soledad_blog_lite_assets')) :
  function soledad_blog_lite_assets()
  {
    $asset = include get_parent_theme_file_path('public/css/screen.asset.php');

    wp_enqueue_style(
      'soledad-blog-lite-style',
      get_parent_theme_file_uri('public/css/screen.css'),
      $asset['dependencies'],
      $asset['version']
    );
  }
endif;

/**
 * Load back-end assets.
 * enqueue_block_editor_assets: Throw Warning in FSE
 */

// Hook
//add_action('enqueue_block_editor_assets', 'soledad_blog_lite_block_editor_assets');
add_action('enqueue_block_assets', 'soledad_blog_lite_block_editor_assets');

// Callback
if (! function_exists('soledadblog_lite_block_editor_assets')) :
  function soledad_blog_lite_block_editor_assets()
  {
    $style_asset = include get_parent_theme_file_path('public/css/editor.asset.php');

    wp_enqueue_style(
      'soledad-blog-lite-editor',
      get_parent_theme_file_uri('public/css/editor.css'),
      $style_asset['dependencies'],
      $style_asset['version']
    );
  }
endif;

/*----------------------------------------------------------------------------------
Enqueue Styles
-----------------------------------------------------------------------------------*/
if (!function_exists('soledad_blog_lite_block_assets')) :
    function soledad_blog_lite_block_assets()
    {
        // registering style for theme
        wp_enqueue_style('nas-autoparts-store-blocks-style', get_template_directory_uri() . '/assets/css/blocks.css');
    }
endif;

add_action('wp_enqueue_scripts', 'soledad_blog_lite_block_assets');


/**
 * Info
 */
require get_theme_file_path( '/inc/admin/info.php' );
require_once get_template_directory() . '/inc/pro-themes.php';

/**
 * Load TGM.
 */
require get_template_directory() . '/inc/tgm/tgm.php';
