/** * Register the asset. * * @param Asset $asset * @return void */ protected function register(Asset $asset) { // Avoid duplicate calls to each instance. if ($this->getArea() !== $asset->getArea()) { return; } if ($asset->getType() === 'script') { $this->registerScript($asset); } else { $this->registerStyle($asset); } // Add asset to list of called instances. static::$instantiated[$this->getArea()][$this->getKey()] = $this; }
/** * Register the asset. * * @param Asset $asset * @return void */ protected function register(Asset $asset) { if ($asset->getType() === 'script') { $this->registerScript($asset); } else { $this->registerStyle($asset); } }
/** * Register inline code. * * @param Asset $asset */ protected function registerInline(Asset $asset) { $args = $asset->getArgs(); if (empty($args) || !isset($args['inline'])) { return; } // Process if there are inline codes. $inlines = $args['inline']; foreach ($inlines as $inline) { if ('script' === $asset->getType()) { wp_add_inline_script($args['handle'], $inline['data'], $inline['position']); } elseif ('style' === $asset->getType()) { wp_add_inline_style($args['handle'], $inline['data']); } } }