[wp-trac] [WordPress Trac] #53792: About Docblock in wp_style_add_data

WordPress Trac noreply at wordpress.org
Thu Sep 30 12:08:48 UTC 2021


#53792: About Docblock in wp_style_add_data
-------------------------------------------+---------------------
 Reporter:  tmatsuur                       |       Owner:  (none)
     Type:  defect (bug)                   |      Status:  new
 Priority:  normal                         |   Milestone:  5.9
Component:  Script Loader                  |     Version:  5.8
 Severity:  normal                         |  Resolution:
 Keywords:  needs-patch needs-screenshots  |     Focuses:  docs
-------------------------------------------+---------------------

Comment (by tmatsuur):

 Thanks @hilayt24

 In the docblock of the wp_maybe_inline_styles function, which was added in
 version 5.8, there is a statement like this

 {{{
  * This improves performance and sustainability, and is opt-in.
 Stylesheets can opt in
  * by adding `path` data using `wp_style_add_data`, and defining the
 file's absolute path:
  *
  *     wp_style_add_data( $style_handle, 'path', $file_path );
 }}}

 In the docblock of the wp_style_add_data function in version 5.8.1, there
 is no description of "path" for the second parameter.

 {{{
 /**
  * Add metadata to a CSS stylesheet.
  *
  * Works only if the stylesheet has already been added.
  *
  * Possible values for $key and $value:
  * 'conditional' string      Comments for IE 6, lte IE 7 etc.
  * 'rtl'         bool|string To declare an RTL stylesheet.
  * 'suffix'      string      Optional suffix, used in combination with
 RTL.
  * 'alt'         bool        For rel="alternate stylesheet".
  * 'title'       string      For preferred/alternate stylesheets.
  *
  * @see WP_Dependencies::add_data()
  *
  * @since 3.6.0
  *
  * @param string $handle Name of the stylesheet.
  * @param string $key    Name of data point for which we're storing a
 value.
  *                       Accepts 'conditional', 'rtl' and 'suffix', 'alt'
 and 'title'.
  * @param mixed  $value  String containing the CSS data to be added.
  * @return bool True on success, false on failure.
  */
 }}}

 An example of the use of "path" as the second parameter of the
 wp_style_add_data function is the register_block_style_handle function
 added in version 5.5.

 Lines 169 - 171 of wp-includes/blocks.php

 {{{
         if ( $has_style_file ) {
                 wp_style_add_data( $style_handle, 'path', $style_file );
         }
 }}}

 This made me think that the docblock of the wp_style_add_data function
 needs to be modified.

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


More information about the wp-trac mailing list