From 9a1ff175458f3ba0a130becb88515e0292ae150e Mon Sep 17 00:00:00 2001 From: Jereme Hancock Date: Sun, 5 Apr 2020 20:15:09 -0500 Subject: [PATCH] Allow passing in attributes for Theme js files This is a follow up to a previous PR. The async attribute can cause issues with some js files. For instance I added the lozad.js (https://github.com/ApoorvSaxena/lozad.js) for lazy loading and included it via my theme. However, with the current automatic inclusion of "async" things didn't work. So this update allows Theme developers to prevent the async attribute by passing in "null". Example: `````` If the Theme developer doesn't include "null" the default will be to use "async". --- bl-kernel/helpers/theme.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bl-kernel/helpers/theme.class.php b/bl-kernel/helpers/theme.class.php index 6645d35f..f2dd9393 100644 --- a/bl-kernel/helpers/theme.class.php +++ b/bl-kernel/helpers/theme.class.php @@ -206,7 +206,7 @@ class Theme { return $links; } - public static function javascript($files, $base=DOMAIN_THEME) + public static function javascript($files, $base=DOMAIN_THEME, $attributes="async") { if( !is_array($files) ) { $files = array($files); @@ -214,15 +214,15 @@ class Theme { $scripts = ''; foreach($files as $file) { - $scripts .= ''.PHP_EOL; + $scripts .= ''.PHP_EOL; } return $scripts; } - public static function js($files, $base=DOMAIN_THEME) + public static function js($files, $base=DOMAIN_THEME, $attributes="async") { - return self::javascript($files, $base); + return self::javascript($files, $base, $attributes); } public static function plugins($type)