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); }
/** * 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()); }