<?php

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
    exit;
}
class Theme_Setup
{

    public function __construct()
    {
        add_action('after_setup_theme', [$this, 'setup']);
    }

    public function setup()
    {
        // Make theme available for translation.
        load_theme_textdomain('pawfect', PAWFECT_THEME_DIR . '/languages');

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

        // Let WordPress manage the document title.
        add_theme_support('title-tag');

        // Enable support for Post Thumbnails on posts and pages.
        add_theme_support('post-thumbnails');

        // Register a navigation menu.
        register_nav_menus([
            'primary' => __('Primary Menu', 'pawfect'),
        ]);

        // Switch default core markup to output valid HTML5.
        add_theme_support(
            'html5',
        [
            'search-form',
            'comment-form',
            'comment-list',
            'gallery',
            'caption',
            'script',
            'style',
            'navigation-widgets',
        ]
        );

        // Custom header support (optional header image).
        add_theme_support('custom-header', apply_filters('pawfect_custom_header_args', array(
            'default-image' => '',
            'default-text-color' => '000000',
            'width' => 1920,
            'height' => 400,
            'flex-height' => true,
            'flex-width' => true,
        )));

        // Custom background color.
        add_theme_support('custom-background', ['default-color' => 'f5efe0']);

        // Add selective refresh for sidebar widget.
        add_theme_support('customize-selective-refresh-widgets');

        // Add support for post formats. 
        add_theme_support('post-formats', ['aside', 'quote', 'status', 'video']);

        // Add support for full and wide align images.
        add_theme_support('align-wide');

        // Add support for responsive embeds.
        add_theme_support('responsive-embeds');

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

        // Add editor styles for the block editor.
        add_editor_style('assets/css/editor-style.css');


        // WooCommerce support (only if WooCommerce is active).
        if (class_exists('WooCommerce')) {
            add_theme_support('woocommerce');
            add_theme_support('wc-product-gallery-zoom');
            add_theme_support('wc-product-gallery-lightbox');
            add_theme_support('wc-product-gallery-slider');
        }

        // Custom logo support.
        add_theme_support('custom-logo', [
            'height' => 90,
            'width' => 120,
            'flex-height' => true,
            'flex-width' => true,
        ]);


        // Image sizes.
        add_image_size('pawfect-blog-grid', '700', '535', true);
        add_image_size('pawfect-portfolio-grid', '700', '535', true);
    }
}