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
Isn't this should be instead replaced by wp_interactivity_data_wp_context to get a local context or moved out the div without echo to set global state?
The issue is in the getServerState() PHP example, it incorrectly uses echo wp_interactivity_state() inside a <div> tag as if it outputs HTML attributes (like wp_interactivity_data_wp_context() does), but wp_interactivity_state() sets global state and doesn't return HTML attributes. The fix is to call it without echo, outside the <div>, and add data-wp-interactive="myPlugin" to the element.
Let me raise the PR with this fix.
Activity
Mustafabharmal commentedon Feb 24, 2026
The issue is in the
getServerState()PHP example, it incorrectly usesecho wp_interactivity_state()inside a<div>tag as if it outputs HTML attributes (likewp_interactivity_data_wp_context()does), butwp_interactivity_state()sets global state and doesn't return HTML attributes. The fix is to call it withoutecho, outside the<div>, and adddata-wp-interactive="myPlugin"to the element.Let me raise the PR with this fix.