<?php
/**
 * Uninstall Plugin.
 * 
 * @package clevernode-related-content
 */
if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
    exit;
}

/**
 * Delete plugin options when cleanup is enabled.
 *
 * Delete all plugin options at plugin uninstall.
 *
 * @since 1.0.0
 */
$settings = get_option( 'clevernode_plugin_settings', array() );

if ( empty( $settings['delete_on_uninstall'] ) ) {
    return;
}

foreach ( wp_load_alloptions() as $option => $value ) {
    if ( strpos( $option, 'clevernode_' ) === 0 ) {
        delete_option( $option );
    }
}

$transients = array(
    'clevernode-admin-notice-connection',
    'clevernode-admin-notice-activation',
    'clevernode-review-notice',
    'clevernode-review-notice-check',
    'clevernode-review-notice-flag',
    'clevenode-admin-notice-warning',
    'clevenode-admin-notice-error',
    'clevenode-admin-notice-success',
);

foreach ( $transients as $transient ) {
    delete_transient( $transient );
}
