Warn about using `register_activation_hook` ?

Open
#1,290 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
php
Domain
tooling

Research direction

Start by reading the linked discussion and the two Speaker Deck slides to understand the multisite concern and the recommended version-based pattern. Then inspect existing WordPress Coding Standards sniffs for how warnings are defined; done means a sniff detects register_activation_hook() usage and reports an actionable warning.

Written by the indexing model from the issue text.

Description

Focus: WP interoperability

Inspired by this discussion: https://github.com/TGMPA/TGM-Plugin-Activation/issues/722

Activation routines via register_activation_hook are generally speaking not compatible with WP multi-site.
It is better to use a plugin/theme version-based upgrade routine pattern to handle both activation as well as upgrade routines.
An example pattern which will work with multi-site, but also with updates via Composer or via FTP:
https://speakerdeck.com/jrf/the-secret-to-mastering-wordpress-multi-site-php-world?slide=26
https://speakerdeck.com/jrf/the-secret-to-mastering-wordpress-multi-site-php-world?slide=27

It might be worth having a sniff to check for usage of register_activation_hook() and warn against it.

Dominant language
PHP
Stars
2.8k
Forks
521
Avg merge
5d 20h
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WordPress/WordPress-Coding-Standards

All issues in WordPress/WordPress-Coding-Standards

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.