[wp-trac] [WordPress Trac] #60331: Clarify in phpdoc that wp_print_inline_script_tag() and wp_get_inline_script_tag() are not only for JavaScript

WordPress Trac noreply at wordpress.org
Tue Jan 23 21:42:57 UTC 2024


#60331: Clarify in phpdoc that wp_print_inline_script_tag() and
wp_get_inline_script_tag() are not only for JavaScript
---------------------------+----------------------------------------
 Reporter:  westonruter    |      Owner:  (none)
     Type:  defect (bug)   |     Status:  new
 Priority:  normal         |  Milestone:  6.5
Component:  Script Loader  |    Version:  trunk
 Severity:  normal         |   Keywords:  good-first-bug needs-patch
  Focuses:                 |
---------------------------+----------------------------------------
 In #56313 the `wp_print_inline_script_tag()` function is used to output
 the `importmap` script for script modules. The content of an `importmap`
 script is JSON, and not JavaScript. This is indicated by passing a `type`
 argument to `wp_print_inline_script_tag()`:

 {{{#!php
 <?php
 wp_print_inline_script_tag(
         wp_json_encode( $import_map, JSON_HEX_TAG | JSON_HEX_AMP ),
         array(
                 'type' => 'importmap',
                 'id'   => 'wp-importmap',
         )
 );
 }}}

 Nevertheless, in the phpdoc for `wp_print_inline_script_tag()` and
 `wp_get_inline_script_tag()` it is specifically mentioning "JavaScript"
 and `$javascript`. These should be made less-specific to JavaScript since
 the function can be used to print any script. For example, the Speculation
 Rules plugin
 [https://github.com/WordPress/performance/blob/13bc15492d576c3fe791fa3d27c5c22f7c3abd12/modules
 /js-and-css/speculation-rules/hooks.php#L16-L27 uses it to print] the
 `speculationrules` script.

 This is split out from a [https://github.com/WordPress/wordpress-
 develop/pull/5925#issuecomment-1905081468 PR discussion] in #60320.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60331>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list