private function _enqueueThemeResources(tubepress_wordpress_impl_wp_WpFunctions $wpFunctions, tubepress_api_version_Version $version) { $callback = array($this, '__callbackConvertToWpUrlString'); $stylesUrls = $this->_htmlGenerator->getUrlsCSS(); $scriptsUrls = $this->_htmlGenerator->getUrlsJS(); $stylesStrings = array_map($callback, $stylesUrls); $scriptsStrings = array_map($callback, $scriptsUrls); $styleCount = count($stylesStrings); $scriptCount = count($scriptsStrings); for ($x = 0; $x < $styleCount; $x++) { $handle = 'tubepress-theme-' . $x; $wpFunctions->wp_register_style($handle, $stylesStrings[$x], array(), "{$version}"); $wpFunctions->wp_enqueue_style($handle); } for ($x = 0; $x < $scriptCount; $x++) { if ($this->_stringUtils->endsWith($scriptsStrings[$x], '/web/js/tubepress.js')) { $handle = 'tubepress'; $deps = array(); } else { $handle = 'tubepress-theme-' . $x; $deps = array('tubepress'); } $wpFunctions->wp_register_script($handle, $scriptsStrings[$x], $deps, "{$version}"); $wpFunctions->wp_enqueue_script($handle, false, array(), false, false); } }
/** * Filter the content (which may be empty). */ public function onAction_admin_enqueue_scripts(tubepress_api_event_EventInterface $eventInterface) { $args = $eventInterface->getSubject(); $hook = $args[0]; /* only run on TubePress settings page */ if ($hook !== 'settings_page_tubepress') { return; } $callback = array($this, '__callbackConvertToWpUrlString'); $cssUrls = $this->_form->getUrlsCSS(); $jsUrls = $this->_form->getUrlsJS(); $cssStrings = array_map($callback, $cssUrls); $jsStrings = array_map($callback, $jsUrls); for ($x = 0; $x < count($cssStrings); $x++) { $this->_wpFunctions->wp_register_style('tubepress-' . $x, $cssStrings[$x]); $this->_wpFunctions->wp_enqueue_style('tubepress-' . $x); } for ($x = 0; $x < count($jsStrings); $x++) { $this->_wpFunctions->wp_register_script('tubepress-' . $x, $jsStrings[$x]); $this->_wpFunctions->wp_enqueue_script('tubepress-' . $x, false, array(), false, false); } }