Пример #1
0
 public function register()
 {
     if (!$this->cacheEnable) {
         if ($this->gaEnable) {
             enqueue_theme_footer($this->gaAsync ? $this->gaScriptAsync() : $this->gaScript(), 'ga_script');
         }
         if ($this->mixPanelEnable) {
             enqueue_theme_footer($this->mixPanelScript(), 'mix_panel_script');
         }
     } else {
         enqueue_theme_footer(Html5::js(AssetHelper::jsUrl($this::EXTENSION_NAME)), $this::EXTENSION_NAME);
         if ($this->gaEnable && $this->gaAsync) {
             enqueue_theme_footer($this->gaJsAsync(), 'ga_js_async');
         }
     }
 }
Пример #2
0
 public function flush($echo = true)
 {
     $this->output = [];
     foreach ($this->queue as $name => $item) {
         switch ($item['type']) {
             case self::TYPE_RAW:
                 $this->output[] = Html5::jsInline($item['content']);
                 break;
             case self::TYPE_VAR:
                 $content = [];
                 foreach ($item['content'] as $varName => $varValue) {
                     $content[] = 'var ' . $varName . ' = ' . $this->getVarValue($varValue) . ';';
                 }
                 $this->output[] = Html5::jsInline(implode(PHP_EOL, $content));
                 break;
             default:
                 $this->output[] = Html5::js($item['content']);
                 break;
         }
     }
     return parent::flush($echo);
 }