<?php
if (!defined('ABSPATH')) exit;

class IPM_Frontend {

    public static function init() {

        require_once IPM_PLUGIN_DIR . 'includes/frontend/category-view.php';
        require_once IPM_PLUGIN_DIR . 'includes/frontend/product-list.php';
        require_once IPM_PLUGIN_DIR . 'includes/frontend/client-partner-slider.php';
        require_once IPM_PLUGIN_DIR . 'includes/frontend/breadcrumb-fix.php';
    }
}

add_filter('template_include', function ($template) {

    if (is_tax('product_category')) {

        $plugin_template = IPM_PLUGIN_DIR . 'includes/frontend/templates/taxonomy-product-category.php';

        if (file_exists($plugin_template)) {
            return $plugin_template;
        }
    }
    return $template;
});

add_filter('template_include', function ($template) {

    if (is_singular('ipm_product')) {

        $single_template = IPM_PLUGIN_DIR . 'includes/frontend/templates/single-ipm_product.php';

        if (file_exists($single_template)) {
            return $single_template;
        }
    }

    return $template;
});
