Make WordPress Core


Ignore:
Timestamp:
06/23/2023 03:43:31 PM (18 months ago)
Author:
SergeyBiryukov
Message:

Script Loader: Replace str_contains() usage in wp-includes/script-loader.php.

This avoids fatal errors on PHP < 8.0 if the file is included via wp-admin/load-scripts.php or wp-admin/load-styles.php, in which case the polyfills from wp-includes/compat.php are not loaded.

Follow-up to [55703], [55710], [55988].

Props ryelle.
See #58206.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/script-loader.php

    r55988 r56002  
    652652        require ABSPATH . WPINC . '/version.php';
    653653
    654         $develop_src = str_contains( $wp_version, '-src' );
     654        /*
     655         * Note: str_contains() is not used here, as this file can be included
     656         * via wp-admin/load-scripts.php or wp-admin/load-styles.php, in which case
     657         * the polyfills from wp-includes/compat.php are not loaded.
     658         */
     659        $develop_src = false !== strpos( $wp_version, '-src' );
    655660
    656661        if ( ! defined( 'SCRIPT_DEBUG' ) ) {
     
    14811486
    14821487    if ( ! defined( 'SCRIPT_DEBUG' ) ) {
    1483         define( 'SCRIPT_DEBUG', str_contains( $wp_version, '-src' ) );
     1488        /*
     1489         * Note: str_contains() is not used here, as this file can be included
     1490         * via wp-admin/load-scripts.php or wp-admin/load-styles.php, in which case
     1491         * the polyfills from wp-includes/compat.php are not loaded.
     1492         */
     1493        define( 'SCRIPT_DEBUG', false !== strpos( $wp_version, '-src' ) );
    14841494    }
    14851495
Note: See TracChangeset for help on using the changeset viewer.