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

class SS_Schema_Governor {
    public static function init() {
        add_action('wp', [__CLASS__, 'disable_external_schema'], 1);
    }

    public static function disable_external_schema() {
        $glossary_id = (int) get_option('ss_glossary_page_id');
        $govern = (bool) get_option(SS_Settings::OPT_SCHEMA_GOVERNOR, true);

        if ($glossary_id && is_page($glossary_id) && $govern) {
            add_filter('wpseo_schema_needs_to_output', '__return_false', 9999);
            remove_all_actions('wpseo_json_ld');
        }
    }
}