diff --git a/class-RegisterJS.php b/class-RegisterJS.php index ad30481..0747fb5 100644 --- a/class-RegisterJS.php +++ b/class-RegisterJS.php @@ -1,189 +1,190 @@ . /** * Register and enqueue JS libraries */ class RegisterJS { /** * Default position */ public static $DEFAULT = 'header'; /** * Script names */ private $js = []; /** * Get the singleton instance * * @return self */ public static function instance() { static $me = false; if( ! $me ) { $me = new self(); } return $me; } /** * Register a new script name * * @param string $name Script name, like: "jquery" * @param mixed $url Script url, like "http://example.org/lib/jquery.js" * @param string $position header|footer * @param array $dependencies Dependent script names */ public function register( $uid, $url, $position = null, $dependencies = [] ) { if( ! $position ) { $position = self::$DEFAULT; } $this->js[ $uid ] = new JS( $uid, $url, $position, $dependencies ); } /** * Register an inline script * * @param string $uid Script name, like: "jquery" * @param array $data Inline JavaScript content (without "; if( DEBUG ) { echo ""; } } } /** * Print the normal JS inclusion * * @param $glue string */ public function printNormal( $glue ) { $url = $this->url; + $url = site_page( $url ); if( CACHE_BUSTER ) { $url .= false === strpos( $url, '?' ) ? '?' : '&'; $url .= CACHE_BUSTER; } echo "$glue"; if( DEBUG ) { echo ""; } } }