Skip to content

P2: Add activation, deactivation, and uninstall hooks #108

Description

@Herm71

Roadmap item 17 (P2) — verified. Plugin-wide.

Problem

The plugin registers no activation, deactivation, or uninstall hooks at all. Three concrete consequences:

  1. Rewrite rules are never flushed. The photo-of-the-week CPT registers a rewrite slug, but nothing flushes on activation — single Photo of the Week URLs 404 until an admin re-saves permalinks manually.
  2. wp_template posts are never removed. Template\Template subclasses create wp_template posts on first load and tag them with the ucsc-2022 wp_theme term. Deactivating or deleting the plugin leaves orphaned template posts behind.
  3. Transients are never cleaned. The News block's taxonomy/term and media/coauthor transients survive deactivation, and there is no way to clear them short of a DB query. (There is currently no supported way for an editor to bust a stale editor dropdown.)

Fix

  • register_activation_hook → flush rewrite rules after CPT registration.
  • register_deactivation_hook → flush rewrite rules; delete plugin transients.
  • uninstall.php (or register_uninstall_hook) → remove generated wp_template posts, plugin options, and remaining transients.
  • Consider a small admin action to purge News transients on demand — useful independent of uninstall, since stale editor dropdowns are a known support burden.

Everything must be guarded for the non-ACF and non-UCSC_NEWS_SITE cases, since neither the CPT nor the templates exist there.

Acceptance

  • Fresh activation yields working photo-of-the-week permalinks with no manual permalink re-save
  • Deactivation clears plugin transients
  • Uninstall removes generated wp_template posts and plugin options
  • Hooks are safe on non-news sites and with ACF absent

Related: #109 — the ucsc-2022 coupling affects what "our templates" even means at uninstall time.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Performance & lifecyclebugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions