wordpress.org – Deprecated: stripos(): Error in WordPress After Updating to php 8.1

Question

Showing this error msg after upgrading to php 8.1 in wordpress

Deprecated: stripos(): Passing null to parameter #1 ($haystack) of type string is deprecated in /public_html/wp-includes/functions.wp-styles.php on line 90

Here is the function which i found in the functions.wp-styles.php

function wp_add_inline_style( $handle, $data ) {
    _wp_scripts_maybe_doing_it_wrong( __FUNCTION__, $handle );

    if ( false !== stripos( $data, '</style>' ) ) {
        _doing_it_wrong(
            __FUNCTION__,
            sprintf(
                /* translators: 1: <style>, 2: wp_add_inline_style() */
                __( 'Do not pass %1$s tags to %2$s.' ),
                '<code>&lt;style&gt;</code>',
                '<code>wp_add_inline_style()</code>'
            ),
            '3.7.0'
        );
        $data = trim( preg_replace( '#<style[^>]*>(.*)</style>#is', '$1', $data ) );
    }

    return wp_styles()->add_inline_style( $handle, $data );
}

Here is the 90 number line inside this code which causes the error,

if ( false !== stripos( $data, '</style>' ) ) {

I upgraded to php 8.1 and then i got this error message, i want to solve this problem.

0
Sourav Pan 3 weeks 2023-01-15T02:24:02-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse