[wp-trac] [WordPress Trac] #64208: Defining interactivity API context with single quotes fail

WordPress Trac noreply at wordpress.org
Thu Nov 6 11:11:01 UTC 2025


#64208: Defining interactivity API context with single quotes fail
-------------------------------+-------------------------------
 Reporter:  Fab1en             |       Owner:  (none)
     Type:  enhancement        |      Status:  new
 Priority:  normal             |   Milestone:  Awaiting Review
Component:  Interactivity API  |     Version:  6.8.3
 Severity:  minor              |  Resolution:
 Keywords:                     |     Focuses:  javascript, docs
-------------------------------+-------------------------------

Comment (by jonsurrell):

 Ideally, folks rely on the
 [https://developer.wordpress.org/reference/functions/wp_interactivity_data_wp_context/
 wp_interactivity_data_wp_context()] function for this. It outputs the HTML
 attribute ready to be printed to the page. There's no need to write or
 encode the data on your own.

 [https://developer.wordpress.org/block-editor/reference-guides
 /interactivity-api/api-reference/#wp_interactivity_data_wp_context It's
 mentioned in the linked documentation], but it would be good to update
 more examples to use it.

 If no errors or warnings are printed when the directive is invalid JSON,
 or is not an object which I believe is a requirement, then it could
 certainly help to display some errors in debug environements.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64208#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list