Files
prautoblogger/includes/class-deactivator.php
peptiderepo f3eacd0d8d style(phpcs): autofix WordPress-Core violations via phpcbf
Run phpcbf --standard=WordPress-Core across includes/, prautoblogger.php,
and uninstall.php. Fixed 1,362 formatting violations in 75 files:
  - Short array syntax: [] → array()
  - Line breaking for long function calls
  - Consistent indentation
  - Function call parameter alignment

No logic changes; purely mechanical formatting.
2026-04-23 02:42:48 +00:00

69 lines
1.6 KiB
PHP
Executable File

<?php
declare(strict_types=1);
/**
* Handles plugin deactivation: clears scheduled cron events and transients.
*
* Note: does NOT delete data or options — that happens in uninstall.php.
* Deactivation should be reversible (user can reactivate and pick up where they left off).
*
* Triggered by: WordPress `register_deactivation_hook` in prautoblogger.php.
* Dependencies: None.
*
* @see class-activator.php — Sets up what this class tears down.
* @see uninstall.php — Permanent data removal on plugin deletion.
*/
class PRAutoBlogger_Deactivator {
/**
* Run deactivation tasks.
*
* Side effects: removes WP-Cron events and deletes transients.
*
* @return void
*/
public static function deactivate(): void {
self::clear_cron();
self::clear_transients();
}
/**
* Remove all scheduled cron events belonging to this plugin.
*
* @return void
*/
private static function clear_cron(): void {
$hooks = array(
'prautoblogger_daily_generation',
'prautoblogger_collect_metrics',
'prautoblogger_reap_orphan_research_rows',
);
foreach ( $hooks as $hook ) {
$timestamp = wp_next_scheduled( $hook );
if ( false !== $timestamp ) {
wp_unschedule_event( $timestamp, $hook );
}
}
}
/**
* Delete all plugin transients.
*
* Side effects: deletes transients from wp_options.
*
* @return void
*/
private static function clear_transients(): void {
$transients = array(
'prautoblogger_reddit_token',
'prautoblogger_generation_lock',
'prautoblogger_openrouter_models',
);
foreach ( $transients as $transient ) {
delete_transient( $transient );
}
}
}