<?php
if (!defined('ABSPATH')) {
    exit;
}
/**
 * Removes specific plugin data associated with the PAC DRH plugin.
 * This function retrieves the 'et_divi' options and removes specific data related to the PAC DRH plugin
 * if the option to remove plugin data is enabled.
 * @return void
 */
if (!function_exists('pac_drh_remove_plugin_data')):
    function pac_drh_remove_plugin_data()
    {
        $options = get_option('et_divi');
        if (!empty($options)
            && isset($options['pac_drh_remove_plugin_data'])
            && 'on' === $options['pac_drh_remove_plugin_data']) {
            $filtered_options = array_filter($options, static function ($key) {
                return !str_starts_with($key, 'pac_drh_');
            }, ARRAY_FILTER_USE_KEY);
            if (!empty($filtered_options)) {
                update_option('et_divi', $filtered_options);
            }
        }
    }

    pac_drh_remove_plugin_data();
endif;