Initial commit: AutoBlogger v0.1.0
WordPress plugin that auto-researches topics from Reddit, generates SEO-optimized articles via OpenRouter LLMs, runs them through a chief editor agent, and publishes on a daily schedule. Includes: - Full generation pipeline (collect → analyze → score → generate → review → publish) - Cost tracking and budget enforcement - Admin UI: settings, review queue, metrics, activity log - CI/CD pipeline (GitHub Actions → WordPress REST deploy) - Unit test suite (PHPUnit + Brain Monkey) - Structured logging with configurable verbosity Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
67
includes/class-deactivator.php
Executable file
67
includes/class-deactivator.php
Executable file
@@ -0,0 +1,67 @@
|
||||
<?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 autoblogger.php.
|
||||
* Dependencies: None.
|
||||
*
|
||||
* @see class-activator.php — Sets up what this class tears down.
|
||||
* @see uninstall.php — Permanent data removal on plugin deletion.
|
||||
*/
|
||||
class Autoblogger_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 = [
|
||||
'autoblogger_daily_generation',
|
||||
'autoblogger_collect_metrics',
|
||||
];
|
||||
|
||||
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 = [
|
||||
'autoblogger_reddit_token',
|
||||
'autoblogger_generation_lock',
|
||||
'autoblogger_openrouter_models',
|
||||
];
|
||||
|
||||
foreach ( $transients as $transient ) {
|
||||
delete_transient( $transient );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user