<?php

if ( ! defined( 'ABSPATH' ) ) exit;

function docuchat_plugin_document_uploaded_status(){ 
echo wp_json_encode( docuchat_process_document() ); 
wp_die();
}
function docuchat_process_document(){
    try {
        if(isset($_POST["status"]) && !empty($_POST["status"]) && 
        $_POST["status"] == 200 && isset($_POST["nonce"]) && !empty($_POST["nonce"]) && 
        wp_verify_nonce( wp_unslash( $_POST["nonce"])  , 'upload' ) ){
         
                $getOptions = unserialize( get_option( DOCUCHAT_ACTIVATION_SERIALIZACION ) ); 
                $getOptions[2] = false;
                $getOptions[3] = "active";

                update_option( DOCUCHAT_ACTIVATION_SERIALIZACION, serialize($getOptions) );
               
            return array("status" => 200, "message" => "plugin registered successfully"); 
        } else {
            return array("status" => 400, "message" => "plugin registration failed");
        }
    } catch (\Throwable $th) {
        return array("status" => 400, "message" => "Error registering data: " . $th->getMessage());
    }
 
}