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
{{ message }}
This repository was archived by the owner on Aug 18, 2026. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 18, 2026. It is now read-only.
Describe the bug
With WP_DEBUG on, I get a notice on the homepage: "Function WP_Scripts::localize was called incorrectly. The $l10n parameter must be an array."
It's coming from class-reader-activation.php line 199. The get_reader_activation_labels() method is supposed to return an array when called with no args, but it's returning a string. The cause is variable shadowing — the foreach on line 336 uses $key as the loop variable, which overwrites the method's $key parameter. After the loop, $key is the last array key instead of null, so the method hits the wrong return path and returns a single label string instead of the full array.
To Reproduce
Enable WP_DEBUG and WP_DEBUG_LOG in wp-config.php
Activate Newspack with Reader Activation enabled
Visit the homepage
Check debug.log or the page output for the notice
Expected behavior
No notice. The reader auth script should get the full labels array as intended.
Fix: Rename just the foreach variable from $key to $label_key in includes/reader-activation/class-reader-activation.php:336; Update the references inside the loop accordingly.
Full disclosure: This was a vibe coded fix. I've encountered the problem twice on two separate fresh installations.
The first time I worked through the problem with an agent and produced this issue.
The second time I tried fixing the issue manually using the specifics here, and struggled. I fed my agent the description and it fixed it immediately. I see the change, and it was specific to the $key variable in just the foreach loop (I accidentally went beyond the foreach loop when I did it manually).
I edited/updated the description here accordingly.
changed the title [-]Variable shadowing in get_reader_activation_labels() causes wp_localize_script notice[/-][+]Reader-activation foreach variable overwrites method parameter (WP_Scripts::localize notice)[/+]on Mar 12, 2026
Activity
grahamgrafx commentedon Mar 12, 2026
Full disclosure: This was a vibe coded fix. I've encountered the problem twice on two separate fresh installations.
The first time I worked through the problem with an agent and produced this issue.
The second time I tried fixing the issue manually using the specifics here, and struggled. I fed my agent the description and it fixed it immediately. I see the change, and it was specific to the $key variable in just the foreach loop (I accidentally went beyond the foreach loop when I did it manually).
I edited/updated the description here accordingly.
[-]Variable shadowing in get_reader_activation_labels() causes wp_localize_script notice[/-][+]Reader-activation foreach variable overwrites method parameter (WP_Scripts::localize notice)[/+]fix(reader-activation): return all labels when no key is requested (#…