You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix subsite enumeration bypass and PHP 5.6 compat; document PHP range in CLAUDE.md
- get_sub_sites(): use is_multisite() instead of $this->networkactive for the
capability guard — a per-site-activated plugin must never let a regular
subsite admin enumerate all network sites regardless of activation mode
- update_options(): remove bool scalar type hint to restore PHP 5.6 compat
- CLAUDE.md: add PHP Compatibility section covering features to avoid on 5.6
and deprecated patterns that cause warnings on PHP 7/8; add rule of thumb
for is_multisite() vs $this->networkactive
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CLAUDE.md
+50Lines changed: 50 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -87,10 +87,60 @@ composer install # Install PHP dev deps (Brain/Monkey for tests)
87
87
88
88
---
89
89
90
+
## PHP Compatibility
91
+
92
+
**Target range: PHP 5.6 – 8.x.** Code must run without fatal errors, warnings, or deprecation notices across the full range. Two kinds of problems to avoid:
93
+
94
+
### Must not break on PHP 5.6 (do not use these newer features)
| Dynamic properties on non-`stdClass` objects without `#[AllowDynamicProperties]`| Deprecated PHP 8.2 |
130
+
| Calling `count()` on non-countable value | Warning PHP 7.2+ |
131
+
132
+
Short array syntax `[]` is fine — it was introduced in PHP 5.4.
133
+
134
+
---
135
+
90
136
## Architecture Notes
91
137
92
138
-**Singleton pattern:** Always access via `Disable_Comments::get_instance()`.
93
139
-**CLI support:**`includes/cli.php` calls the same handler methods with `$_args` to bypass nonce (expected for WP-CLI context; nonce bypass is gated on `$this->is_CLI`).
94
140
-**Multisite vs single-site:** Plugin behaviour branches heavily on `$this->networkactive` (set in constructor) and `$this->sitewide_settings`.
95
141
-**Database queries:** Use `$wpdb->prepare()` throughout `delete_comments()`. Safe against SQL injection.
-**`is_multisite()` vs `$this->networkactive` — know the difference:**
144
+
-`$this->networkactive` = plugin is activated network-wide. Use this for **routing** decisions: which options table to read/write, which admin menu to register, whether to show network-wide UI.
145
+
-`is_multisite()` = WordPress is a multisite install (regardless of plugin activation mode). Use this for **capability guards** on any operation that touches network-level data (e.g. enumerating all sites). A per-site-activated plugin on multisite must never allow a regular subsite admin to list or access all network sites.
146
+
- Rule of thumb: if the question is "where do I save this?" use `$this->networkactive`. If the question is "can this user touch network data?" use `is_multisite()`.
0 commit comments