HEX
Server: LiteSpeed
System: Linux srv158.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: u1694298 (3732)
PHP: 7.4.33
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: /home/u1694298/www/wp-content/plugins/yop-poll/uninstall.php
<?php
/**
 * Fired when the plugin is uninstalled.
 */

if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
	exit;
}

( function () {
	// Respect the "Remove Plugin Data When Uninstalling" setting.
	$settings_raw = get_option( 'yop_poll_settings', '' );
	$settings     = json_decode( $settings_raw, true );
	$remove_data  = $settings['general']['remove-data'] ?? 'no';

	if ( 'yes' !== $remove_data ) {
		return;
	}

	require_once __DIR__ . '/includes/Helpers/class-capabilities.php';
	\YopPoll\Helpers\Capabilities::uninstall();

	global $wpdb;

	$prefix = $wpdb->prefix . 'yoppoll_';

	$tables = array(
		'votes',
		'other_answers',
		'logs',
		'subelements',
		'elements',
		'bans',
		'templates',
		'skins',
		'anonymous_users_votes',
		'polls',
	);

	foreach ( $tables as $table ) {
		$wpdb->query( "DROP TABLE IF EXISTS {$prefix}{$table}" ); // phpcs:ignore WordPress.DB.PreparedSQL, WordPress.DB.DirectDatabaseQuery, WordPress.DB.DirectDatabaseQuery.SchemaChange, PluginCheck.Security.DirectDB.UnescapedDBParameter -- $prefix is $wpdb->prefix . 'yoppoll_' and $table is a hardcoded whitelist; plugin uninstall drops its own tables; no cache layer applicable.
	}

	delete_option( 'yop_poll_version' );
	delete_option( 'yop_poll_db_version' );
	delete_option( 'yop_poll_caps_version' );
	delete_option( 'yop_poll_settings' );
	delete_option( 'yop_poll_migration_status' );
	delete_option( 'yop_poll_migration_offset' );
} )();