/**
  * Render IMDb styled Headbox.
  *
  * @since    2.1.4
  * 
  * @param    string    $content The original post content
  *
  * @return   string    Filtered content
  */
 public function render($content = null)
 {
     $theme = wp_get_theme();
     if (!is_null($theme->stylesheet)) {
         $theme = 'theme-' . $theme->stylesheet;
     } else {
         $theme = '';
     }
     if ('bottom' == wpmoly_o('headbox-position')) {
         $theme .= ' position-bottom';
     } else {
         $theme .= ' position-top';
     }
     $id = get_the_ID();
     $meta = self::get_movie_meta($id, 'meta');
     $details = self::get_movie_meta($id, 'details');
     $poster = get_the_post_thumbnail($id, 'medium');
     $images = $this->get_imdb_headbox_images($id);
     $collections = get_the_terms($id, 'collection');
     if ($collections && !is_wp_error($collections)) {
         foreach ($collections as $i => $c) {
             $collections[$i] = $c->name;
         }
     }
     if (is_array($collections)) {
         $collections = implode(',', $collections);
     }
     $meta['collections'] = WPMOLY_Utils::format_movie_terms_list($collections, 'collection');
     $meta['year'] = apply_filters('wpmoly_format_movie_year', $meta['release_date'], 'Y');
     $meta['_year'] = date_i18n('Y', strtotime($meta['release_date']));
     $meta['_runtime'] = $meta['runtime'];
     $_meta = array('title', 'director', 'writer', 'certification', 'runtime', 'genres', 'cast', 'release_date', 'overview', 'tagline', 'genres', 'homepage', 'production_countries', 'spoken_languages', 'budget', 'revenue', 'production_companies');
     foreach ($_meta as $m) {
         $meta[$m] = apply_filters("wpmoly_format_movie_{$m}", $meta[$m]);
     }
     $details['rating_stars'] = apply_filters('wpmoly_movie_rating_stars', $details['rating'], $id, $base = 10);
     $attributes = compact('id', 'meta', 'details', 'poster', 'images', 'theme');
     $content = WPMovieLibrary::render_template('movies/movie-imdb-headbox.php', $attributes, $require = 'always');
     return $content;
 }
 /**
  * Format a Movie's casting for display
  * 
  * Match each actor against the actor taxonomy to detect missing
  * terms. If term actor exists, provide a link, raw text value
  * if no matching term could be found.
  * 
  * @since    1.1
  * 
  * @param    string    $data field value
  * 
  * @return   string    Formatted output
  */
 public static function format_movie_cast($data)
 {
     $output = WPMOLY_Utils::format_movie_terms_list($data, 'actor');
     $output = self::format_movie_field($output);
     return $output;
 }
 /**
  * Render Allocine styled Headbox 'Overview' Tab.
  *
  * @since    2.1.4
  * 
  * @return   string    Headbox Tab HTML content
  */
 private function render_main_tab()
 {
     $id = get_the_ID();
     $poster = get_the_post_thumbnail($id, 'medium');
     $images = get_posts(array('post_type' => 'attachment', 'orderby' => 'title', 'numberposts' => 5, 'post_status' => null, 'post_parent' => $id, 'meta_key' => '_wpmoly_image_related_tmdb_id', 'exclude' => get_post_thumbnail_id($id)));
     if ($images) {
         foreach ($images as $i => $image) {
             $images[$i] = array('thumbnail' => wp_get_attachment_image_src($image->ID, 'thumbnail'), 'full' => wp_get_attachment_image_src($image->ID, 'full'));
         }
         $images = WPMovieLibrary::render_template('shortcodes/images.php', array('size' => 'thumbnail', 'movie_id' => $id, 'images' => $images), $require = 'always');
     }
     $collections = get_the_terms($id, 'collection');
     if ($collections && !is_wp_error($collections)) {
         foreach ($collections as $i => $c) {
             $collections[$i] = $c->name;
         }
     }
     if (is_array($collections)) {
         $collections = implode(',', $collections);
     }
     $meta = array();
     $_meta = array('title', 'director', 'composer', 'writer', 'local_release_date', 'runtime', 'genres', 'overview', 'production_countries', 'spoken_languages', 'budget', 'revenue');
     foreach ($_meta as $m) {
         $meta[$m] = apply_filters("wpmoly_format_movie_{$m}", self::get_movie_meta($id, $m));
     }
     $meta['collections'] = WPMOLY_Utils::format_movie_terms_list($collections, 'collection');
     $meta['release_date'] = self::get_movie_meta($id, 'release_date');
     $meta['year'] = apply_filters('wpmoly_format_movie_year', $meta['release_date'], 'Y');
     $meta['release_date'] = apply_filters('wpmoly_format_movie_release_date', $meta['release_date']);
     $meta = array_map('WPMOLY_Formatting_Meta::format_movie_field', $meta);
     $meta['cast'] = self::get_movie_meta($id, 'cast');
     $casting = $meta['cast'];
     $meta['cast'] = array_slice(explode(', ', $meta['cast']), 0, 3);
     $meta['cast'] = implode(', ', $meta['cast']);
     $meta['cast'] = apply_filters('wpmoly_format_movie_cast', $meta['cast']);
     $casting = apply_filters('wpmoly_format_movie_cast', $casting);
     $casting = array_slice(explode(', ', $casting), 0, 4);
     $rating = apply_filters('wpmoly_movie_rating_stars', self::get_movie_meta($id, 'rating'), $id, $base = 10);
     if (empty($images)) {
         $images = sprintf(__('No image to show for %s', 'wpmovielibrary'), '<em>' . $meta['title'] . '</em>');
     }
     $attributes = compact('id', 'meta', 'rating', 'casting', 'poster', 'images');
     $content = self::render_template('movies/headbox-allocine/tabs/overview.php', $attributes, $require = 'always');
     return $content;
 }