diff --git a/class-RegisterJS.php b/class-RegisterJS.php
index 50360d5..75edf49 100644
--- a/class-RegisterJS.php
+++ b/class-RegisterJS.php
@@ -1,212 +1,208 @@
.
/**
* 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 ) {
+ if( !$me ) {
$me = new self();
}
return $me;
}
/**
* Register a new script name
*
* This will not automatically enqueue it (normally).
*
* @param string $name Script name, like: "jquery" (or just true for whatever, to enqueue it)
* @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 = [] ) {
// assume the default position
if( !$position ) {
$position = self::$DEFAULT;
}
// create the object
$js = new JS( $uid, $url, $position, $dependencies );
- // if the UID is just true, automatically enqueue
- if( $uid === true ) {
- $js->enqueue = true;
- }
-
// append
$this->js[ $uid ] = $js;
}
/**
* 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 "";
+ if( $this->url ) {
+ $url = site_page( $this->url );
+ if( CACHE_BUSTER ) {
+ $url .= false === strpos( $url, '?' ) ? '?' : '&';
+ $url .= CACHE_BUSTER;
+ }
+ echo "$glue";
+ if( DEBUG ) {
+ echo "";
+ }
}
}
}