Skip to content

Commit

Permalink
Correctly stop further execution when autoloader is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
swissspidy committed Jul 16, 2020
1 parent d7bfcb7 commit 6ee628e
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions includes/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,24 +116,24 @@ function _print_missing_build_admin_notice() {
add_action( 'admin_notices', __NAMESPACE__ . '\_print_missing_build_admin_notice' );
}

// In CLI context, existence of the JS files is not required.
if (
! class_exists( '\Google\Web_Stories\Plugin' ) &&
( ( defined( 'WP_CLI' ) && WP_CLI ) || 'true' === getenv( 'CI' ) || 'cli' === PHP_SAPI )
) {
$heading = esc_html__( 'Web Stories plugin could not be initialized.', 'web-stories' );
$body = sprintf(
/* translators: %s: build commands. */
esc_html__( 'You appear to be running an incomplete version of the plugin. Please run %s to finish installation.', 'web-stories' ),
'`composer install && npm install && npm run build`'
);

if ( class_exists( '\WP_CLI' ) ) {
\WP_CLI::warning( "$heading\n$body" );
} else {
echo "$heading\n$body\n"; // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
if ( ! class_exists( '\Google\Web_Stories\Plugin' ) ) {
// In CLI context, existence of the JS files is not required.
if ( ( defined( 'WP_CLI' ) && WP_CLI ) || 'true' === getenv( 'CI' ) || 'cli' === PHP_SAPI ) {
$heading = esc_html__( 'Web Stories plugin could not be initialized.', 'web-stories' );
$body = sprintf(
/* translators: %s: build commands. */
esc_html__( 'You appear to be running an incomplete version of the plugin. Please run %s to finish installation.', 'web-stories' ),
'`composer install && npm install && npm run build`'
);

if ( class_exists( '\WP_CLI' ) ) {
\WP_CLI::warning( "$heading\n$body" );
} else {
echo "$heading\n$body\n"; // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
}
}

// However, we still need to stop further execution.
return;
}

Expand Down

0 comments on commit 6ee628e

Please sign in to comment.