wp-plugin-lifecycle

Guide WordPress plugin activation, deactivation, and uninstall with multisite awareness.

21|1|Updated Apr 29, 2026
One-click install
npx skills add https://github.com/Lonsdale201/wp-agent-skills --skill wp-plugin-lifecycle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wp-plugin-lifecycle
Source: https://github.com/Lonsdale201/wp-agent-skills/tree/main/plugin-scaffold/wp-plugin-lifecycle
Command: npx skills add https://github.com/Lonsdale201/wp-agent-skills --skill wp-plugin-lifecycle

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Provides a guided approach to design and review WordPress plugin lifecycle events — activation, deactivation, and uninstall — including multisite patterns, safe data handling, and isolation of uninstall logic.

Core Features & Use Cases

  • Activation patterns: one-shot setup, initial option seeds, and optional dbDelta migrations.
  • Deactivation guidance: reversible cleanup, cron unscheduling via wp_unschedule_hook, and transient management to avoid stale state.
  • Uninstall guidance: uninstall.php as an isolated cleanup path with multisite support and an optional data-preservation toggle.
  • Multisite considerations: network-wide vs per-site activation/deactivation flows, site switching, and correct usage of WordPress uninstall patterns.

Quick Start

Implement activation, deactivation, and uninstall hooks in a plugin according to this guide to ensure robust lifecycle behavior.

Frequently Asked Questions about wp-plugin-lifecycle

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I properly handle WordPress plugin activation and deactivation cleanup?

WordPress plugin activation and deactivation cleanup requires reversible actions during deactivation, such as unscheduling cron events via wp_unschedule_hook and clearing transients. Activation should handle one-shot setup, initial option seeds, and optional dbDelta migrations safely.

What is the best way to uninstall a WordPress plugin without leaving orphan options?

The best way to uninstall a WordPress plugin without leaving orphan options is using an isolated uninstall.php file. This dedicated cleanup path removes stored options and data, with multisite support and an optional data-preservation toggle to prevent unexpected data loss.

Does WordPress multisite network activation affect plugin lifecycle hooks differently than single-site?

Yes, WordPress multisite network activation affects plugin lifecycle hooks differently by introducing network-wide versus per-site scopes. Correct multisite handling requires proper site switching logic during activation, deactivation, and uninstall flows across all blogs in the network.

Why does my WordPress plugin leave ghost cron events after deactivation?

Ghost cron events remain after WordPress plugin deactivation when scheduled hooks are not explicitly removed. You must call wp_unschedule_hook during the deactivation process to clean up stale scheduled tasks and ensure proper transient management.

What's the difference between deactivation and uninstall in WordPress plugin development?

Deactivation in WordPress plugin development is reversible, pausing functionality and clearing transients or cron schedules. Uninstall is permanent removal of all plugin data, options, and tables through an isolated uninstall.php file, ensuring no orphan data remains.