<?php
/**
 * @package embed-sharepoint-onedrive-documents
 * @author miniOrange
 * @link https://plugins.miniorange.com
 */


namespace MoSharePointObjectSync\Observer;

use MoSharePointObjectSync\Wrappers\pluginConstants;
use MoSharePointObjectSync\Wrappers\wpWrapper;
class taxonomyObserver
{
    private static $obj;
    public static function getObserver()
    {
        if (isset(self::$obj)) {
            goto kQ;
        }
        self::$obj = new taxonomyObserver();
        kQ:
        return self::$obj;
    }
    public static function mo_sps_register_taxonomy()
    {
        if (!taxonomy_exists("\155\157\x65\x73\150\x70\55\143\141\164\x65\x67\x6f\x72\x79")) {
            goto g0;
        }
        return;
        g0:
        register_taxonomy(MOESHP_TAXONOMY, "\163\150\160\137\x61\x74\x74\x61\x63\x68\x6d\x65\x6e\x74", array("\x68\x69\x65\162\x61\162\143\150\151\x63\x61\154" => true, "\x73\x68\x6f\167\x5f\151\156\137\x6e\x61\166\137\155\145\156\x75\163" => false, "\x73\x68\157\167\x5f\x75\x69" => false, "\160\x75\x62\x6c\x69\x63" => false, "\x75\160\x64\141\164\145\x5f\143\157\165\x6e\x74\137\x63\x61\x6c\x6c\x62\141\x63\x6b" => "\137\165\x70\x64\141\x74\x65\x5f\147\x65\x6e\x65\x72\151\x63\137\164\145\x72\x6d\137\x63\x6f\x75\x6e\164", "\154\x61\142\145\154\x73" => array("\x6e\141\155\x65" => __("\115\x4f\105\x53\110\x50\40\103\141\164\145\x67\157\x72\151\145\x73", "\x6d\157\145\163\x68\x70"), "\x73\x69\156\147\165\x6c\x61\x72\137\156\141\x6d\x65" => __("\115\117\105\x53\110\x50\40\x43\141\x74\145\x67\157\162\171", "\x6d\157\x65\x73\150\160"), "\x6d\x65\156\165\x5f\x6e\x61\x6d\145" => __("\x4d\117\x45\123\x48\120\x20\103\x61\x74\145\x67\x6f\162\151\145\163", "\155\157\x65\163\150\160"), "\x61\154\x6c\137\x69\164\145\x6d\163" => __("\x41\154\x6c\40\x4d\117\105\x53\110\120\40\x43\x61\164\145\x67\x6f\x72\x69\x65\x73", "\155\157\145\x73\x68\160"), "\145\144\x69\x74\x5f\x69\164\145\155" => __("\x45\144\151\164\x20\115\x4f\105\123\x48\120\x20\103\x61\164\x65\147\x6f\x72\171", "\x6d\x6f\x65\163\150\160"), "\x76\x69\145\x77\x5f\151\164\145\x6d" => __("\x56\x69\145\x77\40\x4d\117\105\123\x48\x50\x20\103\x61\164\x65\147\157\x72\x79", "\x6d\x6f\145\x73\x68\160"), "\x75\160\144\141\164\x65\x5f\151\164\145\x6d" => __("\x55\x70\x64\x61\164\x65\40\115\x4f\x45\123\110\120\40\103\x61\164\145\x67\157\x72\x79", "\155\x6f\145\163\x68\x70"), "\x61\144\x64\137\x6e\145\167\x5f\151\x74\x65\155" => __("\101\144\144\x20\x4e\145\x77\x20\x4d\x4f\105\x53\x48\120\40\x43\x61\x74\145\147\x6f\x72\x79", "\x6d\x6f\x65\x73\150\160"), "\x6e\145\x77\137\151\164\145\x6d\x5f\156\141\155\x65" => __("\x4e\x65\x77\40\x4d\117\x45\123\110\120\x20\x43\141\x74\x65\x67\157\x72\171\x20\x4e\x61\x6d\x65", "\x6d\157\x65\163\150\x70"), "\x70\141\x72\145\156\x74\x5f\151\164\145\155" => __("\x50\x61\x72\145\x6e\164\40\x4d\x4f\x45\x53\110\120\x20\103\141\164\145\147\x6f\162\171", "\x6d\x6f\x65\x73\150\x70"), "\x70\141\162\145\x6e\x74\x5f\x69\x74\145\x6d\137\x63\x6f\x6c\x6f\156" => __("\120\141\162\x65\x6e\x74\x20\115\x4f\x45\123\110\120\x20\103\x61\x74\145\147\x6f\x72\171\72", "\x6d\x6f\145\163\x68\x70"), "\x73\x65\141\162\x63\x68\137\151\164\145\x6d\x73" => __("\x53\x65\x61\162\143\150\40\x4d\117\105\x53\110\120\x20\103\x61\164\x65\x67\157\162\x69\x65\163", "\x6d\x6f\x65\x73\150\x70"))));
        $mP = wpWrapper::mo_sps_get_option(pluginConstants::MOESHP_ROOT_ID, false);
        if (!$mP) {
            goto SM;
        }
        $e6 = get_term_by("\x69\x64", (int) $mP, MOESHP_TAXONOMY);
        if ($e6) {
            goto je;
        }
        $F3 = wp_insert_term("\x53\x68\x61\162\x65\160\157\151\156\x74\x20\106\157\x6c\144\145\x72", MOESHP_TAXONOMY, array("\x70\141\x72\x65\156\164" => 0));
        if (!is_wp_error($F3)) {
            goto fR;
        }
        if (!is_numeric($F3->error_data["\164\x65\x72\155\137\145\170\151\x73\164\163"])) {
            goto MC;
        }
        update_option(pluginConstants::MOESHP_ROOT_ID, $F3->error_data["\x74\145\x72\x6d\x5f\x65\170\151\163\x74\x73"]);
        MC:
        goto ka;
        fR:
        update_option(pluginConstants::MOESHP_ROOT_ID, (int) $F3["\x74\x65\162\x6d\137\151\144"]);
        ka:
        je:
        goto B8;
        SM:
        $MR = get_term_by("\156\141\x6d\145", "\123\x68\141\162\145\x70\x6f\x69\x6e\x74\40\106\157\154\x64\x65\x72", MOESHP_TAXONOMY);
        if (empty($MR)) {
            goto SW;
        }
        if (wpWrapper::mo_sps_get_option(pluginConstants::MOESHP_ROOT_ID, false)) {
            goto nV;
        }
        wpWrapper::mo_sps_set_option(pluginConstants::MOESHP_ROOT_ID, $MR->term_id, '', "\171\x65\x73");
        nV:
        goto ii;
        SW:
        $F3 = wp_insert_term("\123\150\141\x72\x65\160\x6f\151\x6e\164\x20\x46\157\x6c\144\145\162", MOESHP_TAXONOMY, array("\160\x61\162\x65\x6e\164" => 0));
        if (wpWrapper::mo_sps_get_option(pluginConstants::MOESHP_ROOT_ID, false)) {
            goto Pq;
        }
        wpWrapper::mo_sps_set_option(pluginConstants::MOESHP_ROOT_ID, $F3["\x74\145\162\155\x5f\151\x64"], '', "\x79\145\x73");
        Pq:
        ii:
        B8:
    }
}
