diff --git a/class-RegisterJS.php b/class-RegisterJS.php index e8c2420..77b920f 100644 --- a/class-RegisterJS.php +++ b/class-RegisterJS.php @@ -1,185 +1,189 @@ . /** * 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 $name string - * @param $data string - * @param $position before|after + * @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; if( CACHE_BUSTER ) { $url .= false === strpos( $url, '?' ) ? '?' : '&'; $url .= CACHE_BUSTER; } echo "$glue"; if( DEBUG ) { echo ""; } } }