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

class SS_Glossary_Frontend {

    public static function init() {
        add_action('wp_enqueue_scripts', [self::class, 'styles']);
        add_filter('single_template', [self::class, 'single_template']);
    }

    public static function styles() {

        $glossary_id = (int) get_option('ss_glossary_page_id');

        if ($glossary_id && is_page($glossary_id)) {
            wp_enqueue_style(
                'searchshifter-glossary',
                SEARCHSHIFTER_PLUGIN_URL . 'assets/css/searchshifter.css',
                [],
                SEARCHSHIFTER_VERSION
            );
        }

        if (is_singular('ss_glossary')) {
            wp_enqueue_style(
                'ss-glossary-style',
                SEARCHSHIFTER_PLUGIN_URL . 'assets/css/searchshifter.css',
                [],
                SEARCHSHIFTER_VERSION
            );
        }
    }

    public static function single_template($template) {

        if (is_singular('ss_glossary')) {
            $custom = SEARCHSHIFTER_PLUGIN_DIR . 'includes/glossary-single.php';
            if (file_exists($custom)) return $custom;
        }

        return $template;
    }


}
         // Disable RankMath schema for glossary terms
        add_filter( 'rank_math/json_ld', function( $data, $jsonld ) {
            if (is_singular('ss_glossary')) {
                return [];
            }
            return $data;
        }, 99, 2);

                add_filter('the_content', function($content) {
            if ( ! searchshifter_has_plan('authority') ) return $content;
            if (get_post_type() !== 'ss_glossary') return $content;

            $brand = get_option('ss_brand_name', 'Your Brand');

            $reinforcement = "<p class='ss-brand-reinforce'>
                This term is part of {$brand}'s AI Visibility reinforcement system.
            </p>";

            return $content . $reinforcement;
        });