/**
  * Render Images.
  * 
  * @since    2.1.4
  * 
  * @param    int       $post_id Current Post ID
  *
  * @return   string    Filtered content
  */
 private function get_imdb_headbox_images($post_id)
 {
     $attachments = get_posts(array('post_type' => 'attachment', 'orderby' => 'title', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post_id, 'meta_key' => '_wpmoly_image_related_tmdb_id', 'exclude' => get_post_thumbnail_id($post_id)));
     $images = array();
     $content = __('No images were imported for this movie.', 'wpmovielibrary');
     if ($attachments) {
         foreach ($attachments as $attachment) {
             $images[] = array('thumbnail' => wp_get_attachment_image_src($attachment->ID, 'thumbnail'), 'full' => wp_get_attachment_image_src($attachment->ID, 'full'));
         }
         $content = WPMovieLibrary::render_template('shortcodes/images.php', array('size' => 'thumbnail', 'movie_id' => get_the_ID(), 'images' => $images), $require = 'always');
     }
     $attributes = array('images' => $content);
     $content = WPMovieLibrary::render_template('movies/headbox/tabs/images.php', $attributes, $require = 'always');
     return $content;
 }
Example #2
0
<?php

/**
 * Fired when the plugin is uninstalled.
 *
 * @package   WPMovieLibrary
 * @author    Charlie MERLAND <*****@*****.**>
 * @license   GPL-3.0+
 * @link      http://www.caercam.org/
 * @copyright 2014 CaerCam.org
 */
// If uninstall not called from WordPress, then exit
if (!defined('WP_UNINSTALL_PLUGIN')) {
    exit;
}
require_once plugin_dir_path(__FILE__) . 'wpmovielibrary.php';
WPMovieLibrary::uninstall();
 /**
  * Generate the content of the widget.
  * 
  * @since    1.2
  *
  * @param    array    $args The array of form elements
  * @param    array    $instance The current instance of the widget
  * 
  * @return   string   The Widget Content
  */
 public function widget_content($args, $instance)
 {
     if (!in_array($instance['taxonomy'], array('collection', 'genre', 'actor'))) {
         return false;
     }
     $defaults = array('title' => __('Movie Taxonomies', 'wpmovielibrary'), 'description' => '', 'taxonomy' => '', 'list' => 0, 'count' => 0, 'orderby' => 'count', 'order' => 'DESC', 'css' => 0, 'limit' => WPMOLY_MAX_TAXONOMY_LIST);
     $args = wp_parse_args($args, $defaults);
     extract($args, EXTR_SKIP);
     extract($instance);
     $title = apply_filters('widget_title', $title);
     $archive = wpmoly_o("rewrite-{$taxonomy}");
     if ('ASC' != $order) {
         $order = 'DESC';
     }
     if ('name' != $orderby) {
         $orderby = 'count';
     }
     $args = array("order={$order}", "orderby={$orderby}");
     if (0 < $limit) {
         $args[] = "number={$limit}";
     }
     $args = implode('&', $args);
     $taxonomies = get_terms(array($taxonomy), $args);
     if ($taxonomies && !is_wp_error($taxonomies)) {
         $items = array();
         $this->widget_css .= " {$taxonomy} list";
         if ($css) {
             $this->widget_css .= ' custom';
         }
         foreach ($taxonomies as $term) {
             $items[] = array('attr_title' => sprintf(__('Permalink for &laquo; %s &raquo;', 'wpmovielibrary'), $term->name), 'link' => get_term_link(sanitize_term($term, $taxonomy), $taxonomy), 'title' => esc_attr($term->name . ($count ? sprintf('&nbsp;(%d)', $term->count) : '')));
         }
         if ($limit) {
             $url = WPMOLY_Utils::get_taxonomy_permalink($archive, $value = false);
             if ('' != $url) {
                 $items[] = array('attr_title' => $this->taxonomies[$taxonomy]['view_all'], 'link' => $url, 'title' => __('View the complete list', 'wpmovielibrary'));
             }
         }
         $items = apply_filters('wpmoly_widget_collection_list', $items, $list, $css);
         $attributes = array('items' => $items, 'description' => $description, 'default_option' => $this->taxonomies[$taxonomy]['default'], 'style' => $this->widget_css);
         if ($list) {
             $html = WPMovieLibrary::render_template('taxonomies-widget/taxonomies-dropdown-list.php', $attributes, $require = 'always');
         } else {
             $html = WPMovieLibrary::render_template('taxonomies-widget/taxonomies-list.php', $attributes, $require = 'always');
         }
     } else {
         $html = WPMovieLibrary::render_template('empty.php', array('message' => $this->taxonomies[$taxonomy]['empty']), $require = 'always');
     }
     return $before_widget . $before_title . $title . $after_title . $html . $after_widget;
 }
 /**
  * Retrieve paginated link for archive post pages.
  * 
  * This is a partial rewrite of WordPress paginate_links() function
  * that doesn't work on the plugin's built-in archive pages.
  * 
  * @since    1.1
  * 
  * @param    array    $args Optional. Override defaults.
  * 
  * @return   string   String of page links or array of page links.
  */
 public static function paginate_links($args = '')
 {
     $defaults = array('base' => '%_%', 'format' => '/page/%#%/', 'total' => 1, 'current' => 0, 'prev_text' => __('&laquo; Previous'), 'next_text' => __('Next &raquo;'), 'end_size' => 1, 'mid_size' => 2);
     $args = wp_parse_args($args, $defaults);
     extract($args, EXTR_SKIP);
     // Who knows what else people pass in $args
     $total = (int) $total;
     if ($total < 2) {
         return;
     }
     $current = (int) $current;
     $end_size = 0 < (int) $end_size ? (int) $end_size : 1;
     // Out of bounds?  Make it the default.
     $mid_size = 0 <= (int) $mid_size ? (int) $mid_size : 2;
     $r = '';
     $links = array();
     $n = 0;
     $dots = false;
     if ($current && 1 < $current) {
         $link = str_replace('%_%', $format, $base);
         $link = str_replace('%#%', $current - 1, $link);
         $links[] = array('url' => esc_url($link), 'class' => 'prev page-numbers', 'title' => $prev_text);
     }
     for ($n = 1; $n <= $total; $n++) {
         if ($n == $current) {
             $links[] = array('url' => null, 'class' => 'page-numbers current', 'title' => number_format_i18n($n));
             $dots = true;
         } else {
             if ($n <= $end_size || $current && $n >= $current - $mid_size && $n <= $current + $mid_size || $n > $total - $end_size) {
                 $link = str_replace('%_%', $format, $base);
                 $link = str_replace('%#%', $n, $link);
                 $links[] = array('url' => esc_url($link), 'class' => 'page-numbers', 'title' => number_format_i18n($n));
                 $dots = true;
             } else {
                 if ($dots) {
                     $links[] = array('url' => null, 'class' => 'page-numbers dots', 'title' => __('&hellip;'));
                     $dots = false;
                 }
             }
         }
     }
     if ($current && ($current < $total || -1 == $total)) {
         $link = str_replace('%_%', $format, $base);
         $link = str_replace('%#%', $current + 1, $link);
         $links[] = array('url' => esc_url($link), 'class' => 'next page-numbers', 'title' => $next_text);
     }
     $attributes = array('links' => $links);
     $content = WPMovieLibrary::render_template('archives/pagination.php', $attributes, $require = 'always');
     return $content;
 }
 // Self-speaking
 require_once WPMOLY_PATH . 'public/class-wpmoly-shortcodes.php';
 // Widgets
 require_once WPMOLY_PATH . 'includes/classes/class-wpmoly-widget.php';
 require_once WPMOLY_PATH . 'includes/widgets/class-statistics-widget.php';
 require_once WPMOLY_PATH . 'includes/widgets/class-taxonomies-widget.php';
 require_once WPMOLY_PATH . 'includes/widgets/class-details-widget.php';
 require_once WPMOLY_PATH . 'includes/widgets/class-movies-widget.php';
 // Legacy
 require_once WPMOLY_PATH . 'includes/classes/legacy/class-wpmoly-legacy.php';
 /*
  * Register hooks that are fired when the plugin is activated or deactivated.
  * When the plugin is deleted, the uninstall.php file is loaded.
  */
 if (class_exists('WPMovieLibrary')) {
     $GLOBALS['wpmoly'] = WPMovieLibrary::get_instance();
     register_activation_hook(__FILE__, array($GLOBALS['wpmoly'], 'activate'));
     register_deactivation_hook(__FILE__, array($GLOBALS['wpmoly'], 'deactivate'));
 }
 /*----------------------------------------------------------------------------*
  * Dashboard and Administrative Functionality
  *----------------------------------------------------------------------------*/
 /*
  * The code below is intended to to give the lightest footprint possible.
  */
 if (is_admin()) {
     require_once WPMOLY_PATH . 'includes/classes/class-wpmoly-ajax.php';
     require_once WPMOLY_PATH . 'admin/class-wpmoly-admin.php';
     require_once WPMOLY_PATH . 'admin/class-dashboard.php';
     require_once WPMOLY_PATH . 'admin/class-dashboard-stats-widget.php';
     require_once WPMOLY_PATH . 'admin/class-dashboard-latest-movies-widget.php';
 /**
  * Generate the content of the widget.
  * 
  * @since    1.2
  *
  * @param    array    $args The array of form elements
  * @param    array    $instance The current instance of the widget
  * 
  * @return   string   The Widget Content
  */
 public function widget_content($args, $instance)
 {
     $defaults = array('title' => __('Movie Details', 'wpmovielibrary'), 'description' => '', 'detail' => '', 'list' => 0, 'css' => 0);
     $args = wp_parse_args($args, $defaults);
     extract($args, EXTR_SKIP);
     extract($instance);
     $title = apply_filters('widget_title', $title);
     $details = call_user_func("WPMOLY_Settings::get_available_movie_{$detail}");
     $rewrite = wpmoly_o('rewrite-details');
     $movies = wpmoly_o('rewrite-movie');
     if (!empty($details)) {
         $baseurl = trailingslashit(get_post_type_archive_link('movie'));
         $this->widget_css .= " wpmoly {$detail}";
         if ($css) {
             $this->widget_css .= ' list custom';
         }
         $items = array();
         foreach ($details as $slug => $_title) {
             $item = array('attr_title' => sprintf(__('Permalink for &laquo; %s &raquo;', 'wpmovielibrary'), __($_title, 'wpmovielibrary')), 'link' => WPMOLY_Utils::get_meta_permalink(array('key' => $detail, 'value' => $slug, 'type' => 'detail', 'format' => 'raw', 'baseurl' => $baseurl)));
             if ('rating' != $detail) {
                 $item['title'] = __($_title, 'wpmovielibrary');
             } else {
                 if ('rating' == $detail && $list) {
                     $item['title'] = esc_attr__($_title, 'wpmovielibrary') . ' (' . $slug . '&#9733;)';
                 } else {
                     $item['title'] = '<div class="movie-rating-display">' . apply_filters('wpmoly_movie_rating_stars', $slug, null, null, true) . '<span class="rating-label">' . esc_attr__($_title, 'wpmovielibrary') . '</span></div>';
                 }
             }
             $items[] = $item;
         }
         $attributes = array('items' => $items, 'description' => $description, 'default_option' => $this->details[$detail]['default'], 'style' => $this->widget_css);
         if ($list) {
             $html = WPMovieLibrary::render_template('details-widget/details-dropdown-list.php', $attributes, $require = 'always');
         } else {
             $html = WPMovieLibrary::render_template('details-widget/details-list.php', $attributes, $require = 'always');
         }
     } else {
         $html = WPMovieLibrary::render_template('empty.php', array('message' => __('No detail no show', 'wpmovielibrary')), $require = 'always');
     }
     return $before_widget . $before_title . $title . $after_title . $html . $after_widget;
 }
 /**
  * form function.
  * 
  * @since    1.2
  * 
  * @param    array    $instance
  * 
  * @return   void
  */
 function form($instance)
 {
     if (!$this->widget_params || !$this->widget_form) {
         return;
     }
     foreach ($this->widget_params as $key => $setting) {
         if (isset($instance[$key])) {
             if ('html' === $setting['type']) {
                 $instance[$key] = wp_kses($instance[$key], array('ul', 'ol', 'li', 'p', 'span', 'em', 'i', 'p', 'strong', 'b', 'br'));
             } else {
                 $instance[$key] = sanitize_text_field($instance[$key]);
             }
         } else {
             $instance[$key] = $setting['std'];
         }
     }
     echo WPMovieLibrary::render_template($this->widget_form, array('widget' => $this, 'instance' => $instance), $require = 'always');
 }
 /**
  * Generate the content of the widget.
  *
  * @param	array	args		The array of form elements
  * @param	array	instance	The current instance of the widget
  */
 public function widget_content($args, $instance)
 {
     $defaults = array('title' => __('Movies', 'wpmovielibrary'), 'description' => '', 'select' => 'date', 'select_status' => 'all', 'select_media' => 'all', 'select_rating' => 'all', 'select_meta' => 'all', 'release_date' => '', 'spoken_languages' => '', 'production_companies' => '', 'production_countries' => '', 'certification' => '', 'sort' => 'DESC', 'limit' => 4, 'show_poster' => 'normal', 'show_title' => 'no', 'show_rating' => 'starsntext', 'exclude_current' => 'no');
     $args = wp_parse_args($args, $defaults);
     extract($args, EXTR_SKIP);
     extract($instance);
     $title = apply_filters('widget_title', $title);
     if ('no' != $show_poster) {
         $this->widget_css .= ' wpmoly-movies-with-thumbnail';
     }
     if ('normal' == $show_poster) {
         $thumbnail = 'medium';
     } else {
         $thumbnail = 'thumbnail';
     }
     switch ($select) {
         case 'status':
             $_select = $instance["select_{$select}"];
             $args = array('orderby' => 'post_date', 'meta_query' => array());
             if ('all' != $_select) {
                 $args['meta_query'][] = array('key' => "_wpmoly_movie_{$select}", 'value' => $_select, 'compare' => '=');
             } else {
                 $args['meta_query'][] = array('key' => "_wpmoly_movie_{$select}", 'value' => '', 'compare' => '!=');
             }
             break;
         case 'media':
             $_select = $instance["select_{$select}"];
             $args = array('orderby' => 'post_date', 'meta_query' => array());
             if ('all' != $_select) {
                 $args['meta_query'][] = array('key' => "_wpmoly_movie_{$select}", 'value' => $_select, 'compare' => 'LIKE');
             } else {
                 $args['meta_query'][] = array('key' => "_wpmoly_movie_{$select}", 'value' => '', 'compare' => 'NOT LIKE');
             }
             break;
         case 'rating':
             $args = array('orderby' => 'meta_value_num', 'meta_key' => '_wpmoly_movie_rating');
             if ('all' != $select_rating) {
                 $args['meta_value'] = $select_rating;
             }
             break;
         case 'title':
             $args = array('orderby' => 'title');
             break;
         case 'random':
             $args = array('orderby' => 'rand');
             if (is_single() && $exclude_current) {
                 global $post;
                 $args['post__not_in'] = array($post->ID);
             }
             break;
         case 'meta':
             switch ($select_meta) {
                 case 'release_date':
                 case 'production_companies':
                 case 'production_countries':
                 case 'spoken_languages':
                 case 'certification':
                     $args = array('meta_query' => array(array('key' => "_wpmoly_movie_{$select_meta}", 'value' => $instance[$select_meta], 'compare' => 'LIKE')));
                     break;
                 default:
                     break;
             }
             break;
         case 'date':
         default:
             $args = array('orderby' => 'date');
             break;
     }
     $args = array_merge(array('posts_per_page' => $limit, 'post_type' => 'movie', 'order' => $sort), $args);
     $movies = new WP_Query($args);
     if (empty($movies->posts)) {
         $html = WPMovieLibrary::render_template('empty.php', array('message' => __('Nothing to display.', 'wpmovielibrary')), $require = 'always');
         return $before_widget . $before_title . $title . $after_title . $html . $after_widget;
     }
     $items = array();
     foreach ($movies->posts as $movie) {
         $item = array('ID' => $movie->ID, 'attr_title' => sprintf(__('Permalink for &laquo; %s &raquo;', 'wpmovielibrary'), $movie->post_title), 'title' => $movie->post_title, 'link' => get_permalink($movie->ID), 'rating' => wpmoly_get_movie_meta($movie->ID, 'rating'), 'thumbnail' => get_the_post_thumbnail($movie->ID, $thumbnail));
         $item['_rating'] = apply_filters('wpmoly_movie_rating_stars', $item['rating'], $movie->ID, $base = 5);
         $items[] = $item;
     }
     $attributes = array('items' => $items, 'description' => $description, 'show_rating' => $show_rating, 'show_title' => $show_title, 'show_poster' => $show_poster, 'style' => $this->widget_css);
     $html = WPMovieLibrary::render_template('movies-widget/movies.php', $attributes, $require = 'always');
     return $before_widget . $before_title . $title . $after_title . $html . $after_widget;
 }
 /**
  * Format a Movie detail. If format is HTML, will return a
  * HTML formatted string; will return the value without change
  * if raw is asked.
  * 
  * @since    2.0
  * 
  * @param    string     $detail details slug
  * @param    string     $data detail value
  * @param    string     $format data format, raw or HTML
  * @param    boolean    $icon Show as icon or text
  * 
  * @return   string    Formatted output
  */
 public static function format_movie_detail($detail, $data, $format = 'html', $icon = false)
 {
     $format = 'raw' == $format ? 'raw' : 'html';
     if ('' == $data) {
         return $data;
     }
     if (true === $icon || wpmoly_o('details-icons') && 'html' == $format) {
         $view = 'shortcodes/detail-icon.php';
     } else {
         $view = 'shortcodes/detail.php';
     }
     $title = '';
     $default_fields = call_user_func("WPMOLY_Settings::get_available_movie_{$detail}");
     if (!is_array($data)) {
         $data = array($data);
     }
     $_data = '';
     foreach ($data as $d) {
         if (isset($default_fields[$d])) {
             $title = __($default_fields[$d], 'wpmovielibrary');
             $_data .= WPMovieLibrary::render_template($view, array('detail' => $detail, 'data' => $d, 'title' => $title), $require = 'always');
         }
     }
     return $_data;
 }
 /**
  * Render Allocine styled Headbox 'Images' Tab.
  *
  * @since    2.1.4
  * 
  * @return   string    Headbox Tab HTML content
  */
 private function render_images_tab()
 {
     $id = get_the_ID();
     $images = get_posts(array('post_type' => 'attachment', 'orderby' => 'post_date', 'numberposts' => -1, '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' => get_the_ID(), 'images' => $images), $require = 'always');
     }
     $posters = get_posts(array('post_type' => 'attachment', 'orderby' => 'post_date', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $id, 'meta_key' => '_wpmoly_poster_related_tmdb_id'));
     if ($posters) {
         foreach ($posters as $i => $poster) {
             $posters[$i] = array('thumbnail' => wp_get_attachment_image_src($poster->ID, 'thumbnail'), 'full' => wp_get_attachment_image_src($poster->ID, 'full'));
         }
         $posters = WPMovieLibrary::render_template('shortcodes/images.php', array('size' => 'thumbnail', 'movie_id' => get_the_ID(), 'images' => $posters), $require = 'always');
     }
     if (empty($images)) {
         $images = __('No image to show.', 'wpmovielibrary');
     }
     if (empty($posters)) {
         $posters = __('No poster to show.', 'wpmovielibrary');
     }
     $attributes = array('id' => get_the_ID(), 'images' => $images, 'posters' => $posters);
     $content = self::render_template('movies/headbox-allocine/tabs/images.php', $attributes, $require = 'always');
     return $content;
 }
 /**
  * Render Custom Taxonomies Archives pages.
  * 
  * This method is a bit complex because it can handle a couple of
  * things. If a letter param is set, will get the list of terms
  * starting with that letter, plus sorting/pagination options.
  * 
  * If no letter is set, simply render a paginated list of all
  * taxonomy' terms.
  * 
  * @since    2.1
  * 
  * @param    string    $taxonomy Taxonomy slug
  * 
  * @return   string    HTML markup
  */
 public static function taxonomy_archives($taxonomy)
 {
     global $wpdb;
     $term_title = '';
     if ('collection' == $taxonomy) {
         $term_title = __('View all movies from collection &laquo; %s &raquo;', 'wpmovielibrary');
     } else {
         if ('genre' == $taxonomy) {
             $term_title = __('View all &laquo; %s &raquo; movies', 'wpmovielibrary');
         } else {
             if ('actor' == $taxonomy) {
                 $term_title = __('View all movies staring &laquo; %s &raquo;', 'wpmovielibrary');
             }
         }
     }
     global $wp_query;
     $params = self::parse_terms_query_vars($wp_query->query);
     // Allow URL params to override settings
     $vars = array('number', 'orderby', 'letter');
     foreach ($vars as $var) {
         $params[$var] = get_query_var($var, $params[$var]);
     }
     $name = WPMOLY_Cache::wpmoly_cache_name("{$taxonomy}_archive");
     $content = WPMOLY_Cache::output($name, function () use($wpdb, $taxonomy, $term_title, $params) {
         $has_menu = wpmoly_o('tax-archives-menu', $default = true);
         $hide_empty = wpmoly_o('tax-archives-hide-empty', $default = true);
         extract($params);
         $_orderby = 't.name';
         if ('count' == $orderby) {
             $_orderby = 'tt.count';
         }
         // Limit the maximum number of terms to get
         $number = min($number, wpmoly_o('tax-archives-terms-limit', $default = true));
         if (!$number) {
             $number = wpmoly_o('tax-archives-terms-per-page', $default = true);
         }
         // Calculate offset
         $offset = 0;
         if ($paged) {
             $offset = $number * ($paged - 1);
         }
         $limit = sprintf('LIMIT %d,%d', $offset, $number);
         $where = '';
         if ('0' != $hide_empty) {
             $where = 'tt.count > 0 AND';
         }
         // This is actually a hard rewriting of get_terms()
         // to get exactly what we want without getting into
         // trouble with multiple filters and stuff.
         if ('' != $letter) {
             $like = wpmoly_esc_like($letter) . '%';
             $query = "SELECT SQL_CALC_FOUND_ROWS t.*, tt.*\n\t\t\t\t\t\t    FROM {$wpdb->terms} AS t\n\t\t\t\t\t\t   INNER JOIN {$wpdb->term_taxonomy} AS tt\n\t\t\t\t\t\t      ON t.term_id = tt.term_id\n\t\t\t\t\t\t   WHERE {$where} tt.taxonomy = %s\n\t\t\t\t\t\t     AND t.name LIKE %s\n\t\t\t\t\t\t   ORDER BY {$_orderby} {$order}\n\t\t\t\t\t\t   {$limit}";
             $query = $wpdb->prepare($query, $taxonomy, $like);
             $terms = $wpdb->get_results($query);
         } else {
             $query = "SELECT SQL_CALC_FOUND_ROWS t.*, tt.*\n\t\t\t\t\t\t    FROM {$wpdb->terms} AS t\n\t\t\t\t\t\t   INNER JOIN {$wpdb->term_taxonomy} AS tt\n\t\t\t\t\t\t      ON t.term_id = tt.term_id\n\t\t\t\t\t\t   WHERE {$where} tt.taxonomy = %s\n\t\t\t\t\t\t   ORDER BY {$_orderby} {$order}\n\t\t\t\t\t\t   {$limit}";
             $query = $wpdb->prepare($query, $taxonomy);
             $terms = $wpdb->get_results($query);
         }
         $total = $wpdb->get_var('SELECT FOUND_ROWS() AS total');
         $terms = apply_filters('get_terms', $terms, (array) $taxonomy, array());
         $links = array();
         // Setting up the terms list...
         if (is_wp_error($terms)) {
             $links = $terms;
         } else {
             foreach ($terms as $term) {
                 $links[] = array('url' => get_term_link($term), 'attr_title' => sprintf($term_title, $term->name), 'title' => $term->name, 'count' => sprintf(_n('%d movie', '%d movies', $term->count, 'wpmovielibrary'), $term->count));
             }
         }
         // ... the main menu...
         $menu = '';
         if ($has_menu) {
             $args = compact('order', 'orderby', 'number', 'letter');
             // PHP 5.3
             $menu = WPMOLY_Archives::taxonomy_archive_menu($taxonomy, $args);
         }
         $args['letter'] = $letter;
         $args['baseurl'] = get_permalink();
         $url = WPMOLY_Utils::build_meta_permalink($args);
         global $wp_rewrite;
         $format = '/page/%#%';
         if ('' == $wp_rewrite->permalink_structure) {
             $format = '&paged=%#%';
         }
         // ... and the pagination menu.
         $args = array('type' => 'list', 'total' => ceil(($total - 1) / $number), 'current' => max(1, $paged), 'format' => $url . $format);
         $pagination = WPMOLY_Utils::paginate_links($args);
         $pagination = '<div id="wpmoly-movies-pagination">' . $pagination . '</div>';
         $attributes = array('taxonomy' => $taxonomy, 'links' => $links);
         $content = WPMovieLibrary::render_template('archives/archives.php', $attributes, $require = 'always');
         $content = $menu . $content . $pagination;
         return $content;
     });
     return $content;
 }
 /**
  * Generate current movie's metadata list.
  *
  * @since    1.0
  *
  * @return   null|string    The current movie's metadata list
  */
 public static function movie_metadata()
 {
     if ('nowhere' == wpmoly_o('show-meta') || 'posts_only' == wpmoly_o('show-meta') && !is_singular()) {
         return null;
     }
     $metadata = wpmoly_get_movie_meta();
     $metadata = wpmoly_filter_undimension_array($metadata);
     $fields = wpmoly_o('sort-meta');
     $default_fields = WPMOLY_Settings::get_supported_movie_meta();
     if ('' == $metadata || empty($fields) || !isset($fields['used'])) {
         return null;
     }
     $fields = $fields['used'];
     if (isset($fields['placebo'])) {
         unset($fields['placebo']);
     }
     $items = array();
     foreach ($fields as $slug => $field) {
         $_field = $metadata[$slug];
         // Custom filter if available
         if (has_filter("wpmoly_format_movie_{$slug}")) {
             $_field = apply_filters("wpmoly_format_movie_{$slug}", $_field);
         }
         // Filter empty field
         $_field = apply_filters("wpmoly_format_movie_field", $_field);
         $fields[$slug] = $_field;
         $items[] = array('slug' => $slug, 'title' => __($default_fields[$slug]['title'], 'wpmovielibrary'), 'value' => $_field);
     }
     $html = WPMovieLibrary::render_template('movies/movie-metadata.php', array('items' => $items), $require = 'always');
     return $html;
 }
 /**
  * Generates the administration form for the widget.
  *
  * @param	array	instance	The array of keys and values for the widget.
  */
 public function form($instance)
 {
     $instance = wp_parse_args((array) $instance);
     $instance['title'] = isset($instance['title']) && '' != $instance['title'] ? $instance['title'] : __('Statistics', 'wpmovielibrary');
     $instance['description'] = isset($instance['description']) && '' != $instance['description'] ? '<p>' . $instance['description'] . '</p>' : '';
     $instance['format'] = isset($instance['format']) && '' != $instance['format'] ? $instance['format'] : __('All combined you have a total of %total% in your library, regrouped in %collections%, %genres% and %actors%.', 'wpmovielibrary');
     // Display the admin form
     echo WPMovieLibrary::render_template('statistics-widget/statistics-admin.php', array('widget' => $this, 'instance' => $instance), $require = 'always');
 }
 /**
  * Movie Images shortcode. This shortcode supports aliases.
  *
  * @since    1.1
  * 
  * @param    array     Shortcode attributes
  * @param    string    Shortcode content
  * @param    string    Shortcode tag name
  * 
  * @return   string    Shortcode display
  */
 public static function movie_images_shortcode($atts = array(), $content = null, $tag = null)
 {
     // Is this an alias?
     if (!is_null($tag) && "{$tag}_shortcode" != __FUNCTION__) {
         $atts['type'] = str_replace('movie_', '', $tag);
     }
     $atts = self::filter_shortcode_atts('movie_images', $atts);
     $movie_id = WPMOLY_Shortcodes::find_movie_id($atts['id'], $atts['title']);
     if (is_null($movie_id)) {
         return $content;
     }
     $atts['movie_id'] = $movie_id;
     // Caching
     $name = apply_filters('wpmoly_cache_name', 'movie_images_shortcode', $atts);
     $content = WPMOLY_Cache::output($name, function () use($atts, $content) {
         extract($atts);
         if (!in_array($type, array('all', 'images', 'backdrops', 'posters'))) {
             $type = 'images';
         }
         $args = array();
         if ('posters' == $type) {
             $args = array('meta_key' => '_wpmoly_poster_related_tmdb_id');
         } elseif ('images' == $type || 'backdrops' == $type) {
             $args = array('meta_key' => '_wpmoly_image_related_tmdb_id');
         } else {
             $args = array('exclude' => get_post_thumbnail_id($movie_id));
         }
         if (!empty($args)) {
             $images = array();
             $args = array_merge($args, array('post_type' => 'attachment', 'orderby' => 'title', 'numberposts' => intval($count), 'post_status' => null, 'post_parent' => $movie_id));
             $attachments = get_posts($args);
             if ($attachments) {
                 foreach ($attachments as $attachment) {
                     $images[] = array('thumbnail' => wp_get_attachment_image_src($attachment->ID, $size), 'full' => wp_get_attachment_image_src($attachment->ID, 'full'));
                 }
                 $content = WPMovieLibrary::render_template('shortcodes/images.php', array('size' => $size, 'movie_id' => $movie_id, 'images' => $images), $require = 'always');
             }
         }
         return $content;
     }, $echo = false);
     return $content;
 }