Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset build file - remove unused vars and add defaults if build file can't be found #675

Merged
merged 1 commit into from
Jun 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 9 additions & 20 deletions inc/scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,16 @@
* @author WDS
*/
function _s_scripts() {
/**
* Global variable for IE.
*/
global $is_IE; // @codingStandardsIgnoreLine
$asset_file_path = __DIR__ . '/../build/index.asset.php';

/**
* If WP is in script debug, or we pass ?script_debug in a URL - set debug to true.
*/
// phpcs:ignore WordPress.Security.NonceVerification -- CSRF OK
$debug = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) || ( isset( $_GET['script_debug'] ) ) ? true : false;
/**
* If we are debugging the site, use a unique version every page load so as to ensure no cache issues.
*/
$version = '1.0.0';

/**
* Should we load minified files?
*/
$suffix = ( true === $debug ) ? '' : '.min';

$asset_file = include __DIR__ . '/../build/index.asset.php';
if ( is_readable( $asset_file_path ) ) {
$asset_file = include $asset_file_path;
} else {
$asset_file = [
'version' => '1.0.0',
'dependencies' => [],
];
}

// Register styles & scripts.
wp_enqueue_style( 'wd_s', get_stylesheet_directory_uri() . '/build/index.css', [], $asset_file['version'] );
Expand Down