/**
  * The widget as shown to the user.
  *
  * @since 1.2.0
  * @param mixed array $args
  * @param mixed array $instance
  */
 function widget($args, $instance)
 {
     // Get slideshowId
     $slideshowId = '';
     if (isset($instance['slideshowId'])) {
         $slideshowId = $instance['slideshowId'];
     }
     // Get title
     $title = '';
     if (isset($instance['title'])) {
         $title = $instance['title'];
     }
     // Prepare slideshow for output to website.
     $output = SlideshowPlugin::prepare($slideshowId);
     $beforeWidget = $afterWidget = $beforeTitle = $afterTitle = '';
     if (isset($args['before_widget'])) {
         $beforeWidget = $args['before_widget'];
     }
     if (isset($args['after_widget'])) {
         $afterWidget = $args['after_widget'];
     }
     if (isset($args['before_title'])) {
         $beforeTitle = $args['before_title'];
     }
     if (isset($args['after_title'])) {
         $afterTitle = $args['after_title'];
     }
     // Output widget
     echo $beforeWidget . (!empty($title) ? $beforeTitle . $title . $afterTitle : '') . $output . $afterWidget;
 }
 /**
  * Function insertSlideshow uses the prepare method of class SlideshowPlugin
  * to insert the code for the slideshow on the location a bookmark was found.
  *
  * @since 2.1.8
  * @param String $content
  * @return String $content
  */
 static function insertSlideshow($content)
 {
     // Loop through post ids
     if (is_array(self::$postIds) && count(self::$postIds) > 0) {
         foreach (self::$postIds as $postId) {
             $updatedContent = preg_replace("/" . self::$bookmark . "/", SlideshowPlugin::prepare($postId), $content, 1);
             if (is_string($updatedContent)) {
                 $content = $updatedContent;
             }
         }
     }
     // Reset postIds, so a shortcode in a next post can be used
     self::$postIds = array();
     return $content;
 }