File-level sniffs like WordPress.Files.FileName are evaluated at the file level, not at code level. They require phpcs:ignore directives to be placed within the file-level docblock (/** ... */), not in code comments. Moved all 81 phpcs:ignore pragmas from code comments to the file-level docblocks. This applies to: - 79 class files with class-naming convention ignores - prautoblogger.php with strict-types docblock ignore - uninstall.php with strict-types docblock ignore
93 lines
2.6 KiB
PHP
Executable File
93 lines
2.6 KiB
PHP
Executable File
<?php
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
* phpcs:ignore Generic.PHP.RequireStrictTypes.MissingDeclaration -- strict_types must precede docblock
|
|
*
|
|
* Fired when the plugin is uninstalled (deleted) from WordPress.
|
|
*
|
|
* Removes ALL plugin data: custom tables, options, post meta, transients, and cron events.
|
|
* This is the nuclear option — only runs when the user explicitly deletes the plugin.
|
|
*
|
|
* @see class-deactivator.php — Lighter cleanup on deactivation (preserves data).
|
|
*/
|
|
|
|
// Abort if not called by WordPress uninstall process.
|
|
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
|
exit;
|
|
}
|
|
|
|
global $wpdb;
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| 1. Drop Custom Tables
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
|
|
$prefix = $wpdb->prefix . 'prautoblogger_';
|
|
$tables = array(
|
|
$prefix . 'source_data',
|
|
$prefix . 'analysis_results',
|
|
$prefix . 'generation_log',
|
|
$prefix . 'content_scores',
|
|
$prefix . 'event_log',
|
|
);
|
|
|
|
foreach ( $tables as $table ) {
|
|
// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Table names are hardcoded above, not user input.
|
|
$wpdb->query( "DROP TABLE IF EXISTS {$table}" );
|
|
}
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| 2. Delete All Plugin Options
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
|
|
$options = $wpdb->get_col(
|
|
"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE 'prautoblogger\_%'"
|
|
);
|
|
|
|
foreach ( $options as $option ) {
|
|
delete_option( $option );
|
|
}
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| 3. Delete All Plugin Post Meta
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
|
|
$wpdb->query(
|
|
"DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE '\\_prautoblogger\\_%'"
|
|
);
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| 4. Delete All Plugin Transients
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
|
|
$wpdb->query(
|
|
"DELETE FROM {$wpdb->options} WHERE option_name LIKE '\\_transient\\_prautoblogger\\_%' OR option_name LIKE '\\_transient\\_timeout\\_prautoblogger\\_%'"
|
|
);
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| 5. Clear Any Remaining Cron Events
|
|
|--------------------------------------------------------------------------
|
|
*/
|
|
|
|
$hooks = array(
|
|
'prautoblogger_daily_generation',
|
|
'prautoblogger_collect_metrics',
|
|
);
|
|
|
|
foreach ( $hooks as $hook ) {
|
|
$timestamp = wp_next_scheduled( $hook );
|
|
if ( false !== $timestamp ) {
|
|
wp_unschedule_event( $timestamp, $hook );
|
|
}
|
|
}
|