<?php

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

require_once(ABSPATH . 'wp-admin/includes/file.php');
require_once(ABSPATH . 'wp-admin/includes/image.php');
require_once(ABSPATH . 'wp-admin/includes/media.php');
 


function docuchat_remove_images_and_resources()
        {
            try {

                $imagesIds = unserialize(get_option('docuchat_images_ids'));

                foreach ($imagesIds as $value) {
                    wp_delete_attachment($value, true);
                }
            
                $array_of_local_options = array('docuchat_images_ids', 'docuchat_activation_serializacion', 'docuchat_token', 'docuchat_email_registred');
                                                                     
                 foreach ($array_of_local_options as $value) {
                    if( get_option($value) ){
                        delete_option($value);
                    }
                }

               
            } catch (\Throwable $th) {
                wp_die('Try to add images when activate', 400);
            }
        }
 