<?php

/**
 * Bricks & Beam functions and definitions
 *
 * @link https://developer.wordpress.org/themes/basics/theme-functions/
 *
 * @package Brick_Beam
 * @since 1.0
 */


if (!function_exists('brick_beam_support')):

    /**
     * Sets up theme defaults and registers support for various WordPress features.
     *
     * @since Bricks & Beam 1.0
     *
     * @return void
     */
    function brick_beam_support() {
        add_filter('woocommerce_get_image_size_thumbnail', function ($size) {
            return array(
                'width' => 800,
                'height' => 800,
                'crop' => 1,
            );
        });
        // Load theme textdomain for translation-ready strings.
        load_theme_textdomain('brick-beam', get_template_directory() . '/languages');

        // Add support for block styles.
        add_theme_support('wp-block-styles');

        // Enqueue editor styles.
        add_editor_style('style.css');

        // Experimental support for adding blocks inside nav menus
        add_theme_support('block-nav-menus');

        // Add support for experimental link color control.
        add_theme_support('experimental-link-color');
    }

endif;

add_action('after_setup_theme', 'brick_beam_support');

if (!function_exists('brick_beam_styles')):

    /**
     * Enqueue styles.
     *
     * @since Bricks & Beam 1.0
     *
     * @return void
     */
    function brick_beam_styles() {
        // Enqueue theme stylesheet.
        wp_enqueue_style(
            'brick-beam-style',
            get_template_directory_uri() . '/style.css',
            array(),
            brick_beam_file_version('/style.css')
        );
    }

endif;

add_action('wp_enqueue_scripts', 'brick_beam_styles');

/**
 * Get file version with respect to file modified date.
 */
function brick_beam_file_version($file_path) {
    return gmdate('ymd-Gis', filemtime(get_theme_file_path($file_path)));
}

// Add block patterns
require get_theme_file_path('/inc/block-patterns.php');

/**
 * Load Theme About Page
 */
require get_theme_file_path('/inc/about-admin/theme-info.php');
