search

Home  >  Q&A  >  body text

In WordPress 6.3.0, the function WP_Scripts::print_inline_script has been deprecated

<p>I am currently developing a WordPress website and encountered the following error message when running my code: </p> <p><code>HP Deprecated: Function WP_Scripts::print_inline_script is <strong>deprecated</strong> since version 6.3.0! Use WP_Scripts::get_inline_script_data() or WP_Scripts::get_inline_script_tag() instead. in C :laragon-8laragonwwwdev-myprojectswp-includesfunctions.php on line 5453</code></p> <p>I'm not sure how to handle this deprecation warning. I tried looking for information in the WordPress documentation but I'm still confused. Can anyone please guide me how to solve this problem? </p> <ul> <li>I have searched the WordPress documentation for this error. </li> <li>I tried searching for a solution through search engines but didn't find a suitable answer. </li> </ul><p><br /></p>
P粉754477325P粉754477325540 days ago621

reply all(1)I'll reply

  • P粉562845941

    P粉5628459412023-08-17 13:56:35

    The function WP_Scripts::print_inline_script has been deprecated starting with WordPress version 6.3.0. To resolve this issue, you should update your code to use WP_Scripts::get_inline_script_data() or WP_Scripts::get_inline_script_tag(). These alternatives are recommended to ensure compatibility with newer versions of WordPress.

    For example, if your code looks like this:

    WP_Scripts::print_inline_script($handle, $position);

    You should replace it with:

    Use get_inline_script_data():

    $script_data = WP_Scripts::get_data($handle, 'data');
    echo $script_data;

    Use get_inline_script_tag():

    $script_data = WP_Scripts::get_data($handle, 'data');
    echo WP_Scripts::get_script_tag($handle, $script_data);

    This will help you avoid using deprecated functions and maintain compatibility with WordPress core updates.

    reply
    0
  • Cancelreply