WordPress.org

Make WordPress Core

Ticket #48154: script-loader.php.patch

File script-loader.php.patch, 1.4 KB (added by pbearne, 23 months ago)

added wp_die example change text as needed

  • src/wp-includes/script-loader.php

     
    287287
    288288        foreach ( $packages as $package ) {
    289289                $handle = 'wp-' . $package;
    290                 $path   = "/wp-includes/js/dist/$package$suffix.js";
     290                $path   = WPINC . '/js/dist/$package$suffix.js';
     291                $php_support_file_path =  ABSPATH . WPINC . '/assets/dist/$package$suffix.asset.php';
    291292
    292                 if ( ! file_exists( ABSPATH . $path ) ) {
    293                         continue;
     293                if( ! file_exists( $php_support_file_path ) ){
     294                        wp_die(__('You need to run "npm build:dev" for this site to create the assets/dist files' ) );
    294295                }
    295296
    296                 $asset_file   = include ABSPATH . WPINC . "/assets/dist/$package$suffix.asset.php";
     297                $asset_file   = include $php_support_file_path;
    297298                $dependencies = $asset_file['dependencies'];
     299                $version = $asset_file['version'];
    298300
    299301                // Add dependencies that cannot be detected and generated by build tools.
    300302                switch ( $handle ) {
     
    305307                                array_push( $dependencies, 'media-models', 'media-views', 'postbox', 'wp-dom-ready' );
    306308                                break;
    307309                }
     310                $scripts->add( $handle, $path, $dependencies, $version, 1 );
    308311
    309                 $scripts->add( $handle, $path, $dependencies, $asset_file['version'], 1 );
    310 
    311312                if ( in_array( $package, $package_translations, true ) ) {
    312313                        $scripts->set_translations( $handle );
    313314                }