예제 #1
0
 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);
     }
 }
예제 #2
0
 public function onAction_wp_head(tubepress_api_event_EventInterface $event)
 {
     /* no need to print anything in the head of the admin section */
     if ($this->_wpFunctions->is_admin()) {
         return;
     }
     /* this inline JS helps initialize TubePress */
     echo $this->_htmlGenerator->getCSS();
     echo $this->_htmlGenerator->getJS();
 }
예제 #3
0
 public function onShortcode(tubepress_api_event_EventInterface $incomingEvent)
 {
     $subject = $incomingEvent->getSubject();
     $rawShortcodeAttributes = $subject[0];
     $rawShortcodeContent = isset($subject[1]) ? $subject[1] : '';
     if (!is_array($rawShortcodeAttributes)) {
         $rawShortcodeAttributes = array();
     }
     if ($this->_loggingEnabled) {
         $this->_logRawShortcode($rawShortcodeAttributes, $rawShortcodeContent);
     }
     $normalizedOptions = $this->_normalizeIncomingShortcodeOptionMap($rawShortcodeAttributes);
     $this->_context->setEphemeralOptions($normalizedOptions);
     $event = $this->_buildShortcodeEvent($normalizedOptions, $rawShortcodeContent);
     $this->_eventDispatcher->dispatch(tubepress_wordpress_api_Constants::SHORTCODE_PARSED, $event);
     /* Get the HTML for this particular shortcode. */
     $toReturn = $this->_htmlGenerator->getHtml();
     /* reset the context for the next shortcode */
     $this->_context->setEphemeralOptions(array());
     $incomingEvent->setArgument('result', $toReturn);
 }
예제 #4
0
 /**
  * Registers all the styles and scripts for the front end.
  *
  * @param array $opts The options.
  *
  * @return void
  */
 public function printWidgetHtml(tubepress_api_event_EventInterface $event)
 {
     $opts = $event->getSubject();
     extract($opts);
     /* default widget options */
     $defaultWidgetOptions = array(tubepress_api_options_Names::FEED_RESULTS_PER_PAGE => 3, tubepress_api_options_Names::META_DISPLAY_VIEWS => false, tubepress_api_options_Names::META_DISPLAY_DESCRIPTION => true, tubepress_api_options_Names::META_DESC_LIMIT => 50, tubepress_api_options_Names::PLAYER_LOCATION => 'shadowbox', tubepress_api_options_Names::GALLERY_THUMB_HEIGHT => 105, tubepress_api_options_Names::GALLERY_THUMB_WIDTH => 135, tubepress_api_options_Names::GALLERY_PAGINATE_ABOVE => false, tubepress_api_options_Names::GALLERY_PAGINATE_BELOW => false, tubepress_api_options_Names::THEME => 'tubepress/default', tubepress_api_options_Names::GALLERY_FLUID_THUMBS => false);
     /* now apply the user's options */
     $rawTag = $this->_context->get(tubepress_wordpress_api_Constants::OPTION_WIDGET_SHORTCODE);
     $widgetTag = $this->_stringUtils->removeNewLines($rawTag);
     $this->_shortcodeParser->parse($widgetTag);
     /* calculate the final options */
     $finalOptions = array_merge($defaultWidgetOptions, $this->_context->getEphemeralOptions());
     $this->_context->setEphemeralOptions($finalOptions);
     if ($this->_context->get(tubepress_api_options_Names::THEME) === '') {
         $this->_context->setEphemeralOption(tubepress_api_options_Names::THEME, 'tubepress/default');
     }
     $out = $this->_htmlGenerator->getHtml();
     /* do the standard WordPress widget dance */
     /* @noinspection PhpUndefinedVariableInspection */
     echo $before_widget . $before_title . $this->_context->get(tubepress_wordpress_api_Constants::OPTION_WIDGET_TITLE) . $after_title . $out . $after_widget;
     /* reset the context for the next shortcode */
     $this->_context->setEphemeralOptions(array());
 }