• Hi

    I fixed two errors in this file /wp-content/plugins/eu-tyre-label-shortcode/php/get-eu-tyre-label.php which occurs when running PHP 8.1

    • FILTER_SANITIZE_STRING is deprecated in PHP 8.1 and PHP documentation recommends use htmlspecialchars() but I’ve fixed using WordPress function sanitize_text_field():
    if ( !function_exists( 'sanitize_text_field' ) )
    {
    	require_once( explode( "wp-content" , __FILE__ )[0] . "wp-load.php" );
    }
    
    $v1 = sanitize_text_field( $_GET['fuel'] );
    …
    $v2 = sanitize_text_field( $_GET['grip'] );
    …
    • Font cannot be loaded and text over label is not shown, so I’ve completed the file location:
    $font = dirname( __FILE__ ) . '/../font/opensans/OpenSans-Bold.ttf';

    I guess this improvements will also work if running PHP 7.4 and lower.

    Regards

    • This topic was modified 1 year, 5 months ago by Jairo Ochoa.
  • The topic ‘Deprecated functions PHP 8.1’ is closed to new replies.