Skip to content

Commit

Permalink
Check if GUTENBERG_VERSION is defined.
Browse files Browse the repository at this point in the history
Switches the check around to determine if in production mode:

- GUTENBERG_VERSION is defined
- SCRIPT_DEBUG is not defined || is not true.

Else, defaults to time().
  • Loading branch information
hellofromtonya committed Mar 16, 2021
1 parent f31f27b commit 352e06a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/client-assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,9 @@ function gutenberg_register_vendor_scripts( $scripts ) {
* @param WP_Scripts $scripts WP_Scripts instance.
*/
function gutenberg_register_packages_scripts( $scripts ) {
// Defines default version.
// For development, uses the current time (in microseconds) as the asset version.
// For production, uses the plugin's version as the asset version.
$default_version = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? time() : GUTENBERG_VERSION;
// When in production, use the plugin's version as the default asset version;
// else (for development or test) default to use the current time.
$default_version = defined( 'GUTENBERG_VERSION' ) && ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? GUTENBERG_VERSION : time();

foreach ( glob( gutenberg_dir_path() . 'build/*/index.js' ) as $path ) {
// Prefix `wp-` to package directory to get script handle.
Expand Down Expand Up @@ -290,9 +289,10 @@ function gutenberg_register_packages_scripts( $scripts ) {
* @param WP_Styles $styles WP_Styles instance.
*/
function gutenberg_register_packages_styles( $styles ) {
// For development, uses the current time (in microseconds) as the asset version.
// For production, uses the plugin's version as the asset version.
$version = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? time() : GUTENBERG_VERSION;
// When in production, use the plugin's version as the asset version;
// else (for development or test) default to use the current time.
$version = defined( 'GUTENBERG_VERSION' ) && ! ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? GUTENBERG_VERSION : time();


// Editor Styles.
gutenberg_override_style(
Expand Down

0 comments on commit 352e06a

Please sign in to comment.