/**
  * Constructor. Calls WP_List_Table and set up data.
  * 
  * @since    1.0
  */
 function __construct()
 {
     if (!is_admin()) {
         return false;
     }
     global $status, $page;
     parent::__construct(array('singular' => 'movie', 'plural' => 'movies', 'ajax' => true, 'screen' => get_current_screen()));
     $this->posts_per_page = 15;
     $this->metadata = WPMOLY_Settings::get_supported_movie_meta();
     $this->columns = WPMOLY_Import::get_imported_movies();
     $this->column_names = array('poster' => __('Poster', 'wpmovielibrary'), 'movietitle' => __('Title', 'wpmovielibrary'), 'director' => __('Director', 'wpmovielibrary'), 'actions' => __('Actions', 'wpmovielibrary'));
 }
 /**
  * Specifies the classname and description, instantiates the widget. No
  * stylesheets or JavaScript needed, localization loaded in public class.
  */
 public function __construct()
 {
     $this->widget_name = __('WPMovieLibrary Details', 'wpmovielibrary');
     $this->widget_description = __('Display a list of the available details: status, media and rating.', 'wpmovielibrary');
     $this->widget_css = 'wpmoly details';
     $this->widget_id = 'wpmovielibrary-details-widget';
     $this->widget_form = 'details-widget/details-admin.php';
     $this->widget_params = array('title' => array('type' => 'text', 'std' => __('Movie Details', 'wpmovielibrary')), 'description' => array('type' => 'text', 'std' => ''), 'detail' => array('type' => 'select', 'std' => ''), 'list' => array('type' => 'checkbox', 'std' => 0), 'css' => array('type' => 'checkbox', 'std' => 0));
     $this->details = array();
     $supported = WPMOLY_Settings::get_supported_movie_details();
     foreach ($supported as $slug => $detail) {
         $this->details[$slug] = array('default' => sprintf(__('Select a %s', 'wpmovielibrary'), $slug), 'empty' => sprintf(__('No %s to display.', 'wpmovielibrary'), $slug));
     }
     parent::__construct();
 }
 /**
  * Specifies the classname and description, instantiates the widget. No
  * stylesheets or JavaScript needed, localization loaded in public class.
  */
 public function __construct()
 {
     $this->widget_name = __('WPMovieLibrary Movies', 'wpmovielibrary');
     $this->widget_description = __('Display a list of movies from a specific taxonomy, media, status, rating…', 'wpmovielibrary');
     $this->widget_css = 'wpmoly movies';
     $this->widget_id = 'wpmovielibrary-movies-widget';
     $this->widget_form = 'movies-widget/movies-admin.php';
     $this->widget_params = array('title' => array('type' => 'text', 'std' => __('Movies', 'wpmovielibrary')), 'description' => array('type' => 'text', 'std' => ''), 'select' => array('type' => 'select', 'std' => 'date'), 'select_status' => array('type' => 'select', 'std' => 'all'), 'select_media' => array('type' => 'select', 'std' => 'all'), 'select_rating' => array('type' => 'select', 'std' => 'all'), 'select_meta' => array('type' => 'select', 'std' => 'all'), 'release_date' => array('type' => 'text', 'std' => ''), 'spoken_languages' => array('type' => 'text', 'std' => ''), 'production_companies' => array('type' => 'text', 'std' => ''), 'production_countries' => array('type' => 'text', 'std' => ''), 'certification' => array('type' => 'text', 'std' => ''), 'sort' => array('type' => 'select', 'std' => 'DESC'), 'limit' => array('type' => 'number', 'std' => 4), 'show_poster' => array('type' => 'select', 'std' => 'normal'), 'show_title' => array('type' => 'select', 'std' => 'no'), 'show_rating' => array('type' => 'select', 'std' => 'starsntext'), 'exclude_current' => array('type' => 'select', 'std' => 'no'));
     $this->movies_by = array('status' => __('Status', 'wpmovielibrary'), 'media' => __('Media', 'wpmovielibrary'), 'rating' => __('Rating', 'wpmovielibrary'), 'title' => __('Title', 'wpmovielibrary'), 'date' => __('Date', 'wpmovielibrary'), 'meta' => __('Metadata', 'wpmovielibrary'), 'random' => __('Random', 'wpmovielibrary'));
     $this->status = WPMOLY_Settings::get_available_movie_status();
     $this->media = WPMOLY_Settings::get_available_movie_media();
     $this->rating = WPMOLY_Settings::get_available_movie_rating();
     $this->meta = array('release_date' => __('Release Date', 'wpmovielibrary'), 'production_companies' => __('Production', 'wpmovielibrary'), 'production_countries' => __('Country', 'wpmovielibrary'), 'spoken_languages' => __('Languages', 'wpmovielibrary'), 'certification' => __('Certification', 'wpmovielibrary'));
     $this->years = WPMOLY_Utils::get_used_years($count = true);
     $this->languages = WPMOLY_Utils::get_used_languages($count = true);
     $this->companies = WPMOLY_Utils::get_used_companies($count = true);
     $this->countries = WPMOLY_Utils::get_used_countries($count = true);
     $this->certifications = WPMOLY_Utils::get_used_certifications($count = true);
     parent::__construct();
 }
		<label for="<?php 
echo $widget->get_field_id('detail');
?>
"><strong class="wpmoly-widget-title"><?php 
_e('Detail', 'wpmovielibrary');
?>
</strong></label><br />
		<select id="<?php 
echo $widget->get_field_id('detail');
?>
" name="<?php 
echo $widget->get_field_name('detail');
?>
">
<?php 
$supported = WPMOLY_Settings::get_supported_movie_details();
foreach ($supported as $slug => $s) {
    ?>
			<option value="<?php 
    echo $slug;
    ?>
" <?php 
    selected($slug, $detail);
    ?>
><?php 
    _e($s['title'], 'wpmovielibrary');
    ?>
</option>

<?php 
}
 /**
  * Register the plugin's custom admin menu.
  * 
  * Page and subpages are defined in the related config file and
  * can be extended by filters.
  * 
  * @since    1.0
  */
 public function admin_menu()
 {
     $admin_menu = WPMOLY_Settings::get_admin_menu();
     add_dashboard_page($page_title = __('About WPMovieLibrary', 'wpmovielibrary'), $menu_title = __('About WPMovieLibrary', 'wpmovielibrary'), $capability = 'manage_options', $menu_slug = 'wpmovielibrary-about', $function = 'WPMovieLibrary_Admin::about_page');
     remove_submenu_page('index.php', 'wpmovielibrary-about');
     extract($admin_menu['page']);
     add_menu_page($page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position);
     foreach ($admin_menu['subpages'] as $id => $subpage) {
         extract($subpage, EXTR_PREFIX_ALL | EXTR_OVERWRITE, 'subpage');
         if (is_null($subpage_condition) || !is_null($subpage_condition) && false != call_user_func($subpage_condition)) {
             $screen_hook = add_submenu_page($menu_slug, $subpage_page_title, __($subpage_menu_title, 'wpmovielibrary'), $subpage_capability, $subpage_menu_slug, $subpage_function);
             $this->screen_hooks[$id] = $screen_hook;
             if (true === $subpage_hide) {
                 $this->hidden_pages[] = array('menu_slug' => $menu_slug, 'subpage_menu_slug' => $subpage_menu_slug);
             }
             if (!empty($subpage_actions)) {
                 foreach ($subpage_actions as $hook => $callback) {
                     if (is_callable($callback)) {
                         $hook = str_replace('{screen_hook}', $screen_hook, $hook);
                         add_action($hook, $callback);
                     }
                 }
             }
         }
     }
 }
 /**
  * Generate a list of all meta used in movies
  * 
  * This method returns a list of all distinct values for a specific
  * meta.
  * 
  * @since    2.0
  * 
  * @param    string     $meta meta_key to collect
  * @param    boolean    $count Shall we add count?
  * 
  * @return   array   
  */
 public static function get_used_meta($meta, $count = false)
 {
     $supported = array_keys(WPMOLY_Settings::get_supported_movie_meta());
     if (!in_array($meta, $supported)) {
         return array();
     }
     $used = array();
     if (true !== $count) {
         $count = false;
     }
     $distinct = !$count ? 'DISTINCT' : '';
     global $wpdb;
     $values = $wpdb->get_results("SELECT {$distinct} meta_value\n\t\t\t\t FROM {$wpdb->postmeta}\n\t\t\t\t WHERE meta_key LIKE '_wpmoly_movie_{$meta}'\n\t\t\t\t ORDER BY meta_value");
     foreach ($values as $i => $value) {
         $value = explode(',', $value->meta_value);
         foreach ($value as $v) {
             $v = trim($v);
             if ($v) {
                 if (!isset($used[$v])) {
                     $used[$v] = array('name' => '', 'count' => '');
                 }
                 $used[$v]['name'] = $v;
                 if ($count) {
                     $used[$v]['count']++;
                 }
             }
         }
     }
     if ($count) {
         usort($used, __CLASS__ . '::order_by_count');
         $used = array_reverse($used);
     }
     return $used;
 }
 /**
  * Filter the Movie Details submitted when saving a post to
  * avoid storing unexpected data to the database.
  * 
  * @since    2.1
  * 
  * @param    array    $data The Movie Details to filter
  * 
  * @return   array    The filtered Details
  */
 private static function validate_details($data)
 {
     if (!is_array($data) || empty($data)) {
         return $data;
     }
     $data = wpmoly_filter_empty_array($data);
     $supported = WPMOLY_Settings::get_supported_movie_details();
     $movie_details = array();
     foreach ($supported as $slug => $detail) {
         if (isset($data[$slug])) {
             $_detail = $data[$slug];
             if (is_array($_detail) && 1 == $detail['multi']) {
                 $_d = array();
                 foreach ($_detail as $d) {
                     if (in_array($d, array_keys($detail['options']))) {
                         $_d[] = $d;
                     }
                 }
                 $movie_details[$slug] = $_d;
             } else {
                 if ('select' == $detail['type'] && in_array($_detail, array_keys($detail['options']))) {
                     $movie_details[$slug] = $_detail;
                 } else {
                     if ('text' == $detail['type']) {
                         $movie_details[$slug] = $_detail;
                     }
                 }
             }
         } else {
             $movie_details[$slug] = null;
         }
     }
     return $movie_details;
 }
 public static function get_language_native_name($language)
 {
     $languages = WPMOLY_Settings::get_available_languages();
     if (2 == strlen($language)) {
         $code = strtolower($language);
     } else {
         $code = array_search($language, $languages['native']);
     }
     if (false !== $code) {
         $language = $languages['native'][$code];
     }
     return $language;
 }
 /**
  * Filter page's title to feature letters, meta, value in archives
  * pages' titles. Hooked to 'the_title' and 'wp_title' filters.
  * 
  * @since    2.1.1
  * 
  * @param    string        $title Current title
  * @param    int|string    $id Current page ID if current filter if 'the_title', separator if filter is 'wp_title'
  * 
  * @return   string    
  */
 public function movie_archives_title($title, $id = null)
 {
     // Exclude admin
     if (is_admin()) {
         return $title;
     }
     // 'wp_title' filter second parameter is separator, not id
     $filter = current_filter();
     $sep = '&nbsp;|&nbsp;';
     if ('wp_title' == $filter) {
         $id = get_the_ID();
     }
     // Exclude not-archive pages
     if (!in_array($id, $this->pages)) {
         return $title;
     }
     $is_movie = $id == $this->pages['movie'];
     $translate = '1' == wpmoly_o('rewrite-enable');
     $rewrite_movie = '1' == wpmoly_o('movie-archives-title-rewrite');
     $rewrite_taxonomy = '1' == wpmoly_o('tax-archives-title-rewrite');
     if ($is_movie && !$rewrite_movie || !$is_movie && !$rewrite_taxonomy) {
         return $title;
     }
     $page = array_search($id, $this->pages);
     $titles = array('movie' => __('Movies', 'wpmovielibrary'), 'collection' => __('Collections', 'wpmovielibrary'), 'genre' => __('Genres', 'wpmovielibrary'), 'actor' => __('Actors', 'wpmovielibrary'));
     /**
      * Filter Archive Pages Titles
      * 
      * @since    2.1.1
      * 
      * @param    array    $titles Default Archive Pages titles
      * 
      * @return   array    Filtered titles
      */
     $titles = apply_filters('wpmoly_filter_archive_pages_titles', $titles);
     /**
      * Filter Archive Page's default title
      * 
      * @since    2.1.1
      * 
      * @param    string    $title Current Archive Page title
      * @param    int       $id Current Archive Page Post ID
      * 
      * @return   string    Filtered title
      */
     $title = apply_filters("wpmoly_filter_{$page}_archive_page_default_title", $titles[$page], $id);
     if (!is_single($id) && !is_page($id) || 'the_title' == $filter && !in_the_loop()) {
         return $title;
     }
     $meta = get_query_var('meta');
     $detail = get_query_var('detail');
     $value = get_query_var('value');
     $sorting = get_query_var('sorting');
     $_detail = '';
     $_meta = '';
     if ($is_movie && $rewrite_movie) {
         if ('' != $meta) {
             if ($translate) {
                 $meta = WPMOLY_L10n::untranslate_rewrite($meta);
             }
             $supported = WPMOLY_Settings::get_supported_movie_meta();
             if (isset($supported[$meta])) {
                 $_meta = $supported[$meta]['title'];
             }
             if ('' != $value) {
                 $value = WPMOLY_L10n::untranslate_rewrite($value);
             }
         } elseif ('' != $detail) {
             if ($translate) {
                 $detail = WPMOLY_L10n::untranslate_rewrite($detail);
             }
             $supported = WPMOLY_Settings::get_supported_movie_detail();
             if (isset($supported[$detail])) {
                 $_detail = $supported[$detail]['title'];
             }
             if ('' != $value) {
                 $value = WPMOLY_L10n::untranslate_rewrite($value);
             }
         }
         if ('production_countries' == $meta) {
             $value = WPMOLY_L10n::get_country_standard_name($value);
             $value = __($value, 'wpmovielibrary-iso');
         } else {
             if ('spoken_languages' == $meta) {
                 $value = WPMOLY_L10n::get_language_standard_name($value);
                 $value = __($value, 'wpmovielibrary-iso');
             } else {
                 $value = __($value, 'wpmovielibrary');
             }
         }
         if ('' == $_meta && '' != $_detail) {
             $_meta = $_detail;
         }
         if ('' != $_meta && '' == $value) {
             $title = sprintf(__('Movies by %s', 'wpmovielibrary'), $_meta);
         } elseif ('' != $_meta && '' != $value) {
             $title = sprintf(__('Movies by %s: %s', 'wpmovielibrary'), ucwords($_meta), $value);
         } else {
             $title = __('Movies', 'wpmovielibrary');
         }
     }
     if ('' != $sorting) {
         $sorting = self::parse_query_vars(compact('sorting'));
         if (isset($sorting['letter']) && '' != $sorting['letter']) {
             $title .= sprintf(' − %s ', sprintf(__('Letter %s', 'wpmovielibrary'), $sorting['letter']));
         }
         if (isset($sorting['paged']) && '' != $sorting['paged'] && 'wp_title' == $filter) {
             $title .= sprintf(__(' %s Page %d ', 'wpmovielibrary'), $sep, $sorting['paged']);
         }
     }
     /**
      * Filter Page's Post title as used in (get_)the_title()
      * 
      * @since    2.1.1
      * 
      * @param    string    $title Current Archive Page title
      * @param    int       $id Current Archive Page Post ID
      * 
      * @return   string    Filtered title
      */
     $title = apply_filters("wpmoly_filter_{$page}_archive_page_title", $title, $id);
     if ('wp_title' == $filter) {
         $title = str_replace(array(' : ', ' − '), $sep, $title) . $sep;
         /**
          * Filter Page's main title as used in wp_title()
          * 
          * @since    2.1.1
          * 
          * @param    string    $title Current Archive Page title
          * @param    int       $id Current Archive Page Post ID
          * 
          * @return   string    Filtered title
          */
         $title = apply_filters("wpmoly_filter_{$page}_archive_page_wp_title", $title, $id);
     }
     return $title;
 }
 /**
  * Render Allocine styled Headbox 'Details' Tab.
  *
  * @since    2.1.4
  * 
  * @return   string    Headbox Tab HTML content
  */
 private function render_details_tab()
 {
     $id = get_the_ID();
     $overview = self::get_movie_meta($id, 'overview');
     $tagline = self::get_movie_meta($id, 'tagline');
     $details = wpmoly_get_movie_details();
     $default_fields = WPMOLY_Settings::get_supported_movie_details();
     foreach ($details as $slug => $detail) {
         if (!is_array($detail)) {
             $detail = array($detail);
         }
         if (isset($default_fields[$slug]['panel']) && 'custom' == $default_fields[$slug]['panel']) {
             unset($details[$slug]);
         } else {
             foreach ($detail as $i => $d) {
                 if (!empty($d)) {
                     if (isset($default_fields[$slug]['options'])) {
                         $value = $default_fields[$slug]['options'][$d];
                     } else {
                         $value = $d;
                     }
                     if ('rating' == $slug) {
                         $d = apply_filters("wpmoly_movie_meta_link", array('key' => 'rating', 'value' => array_search($value, $default_fields[$slug]['options']), 'type' => 'detail', 'text' => $value));
                     } else {
                         $d = apply_filters("wpmoly_movie_meta_link", array('key' => $slug, 'value' => $value, 'meta' => 'detail', 'text' => $value));
                     }
                     $detail[$i] = apply_filters("wpmoly_format_movie_field", $d);
                 }
             }
             $detail = implode(', ', $detail);
             if (empty($detail)) {
                 $detail = apply_filters("wpmoly_format_movie_field", '');
             }
             $title = '';
             if (isset($default_fields[$slug])) {
                 $title = __($default_fields[$slug]['title'], 'wpmovielibrary');
             }
             $details[$slug] = array('slug' => $slug, 'title' => $title, 'value' => $detail);
         }
     }
     $metas = wpmoly_get_movie_meta();
     $metas = wpmoly_filter_undimension_array($metas);
     $default_fields = WPMOLY_Settings::get_supported_movie_meta();
     if (!empty($metas)) {
         unset($metas['title'], $metas['cast'], $metas['overview'], $metas['tagline']);
         foreach ($metas as $slug => $field) {
             if (isset($default_fields[$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);
                 $metas[$slug] = array('slug' => $slug, 'title' => __($default_fields[$slug]['title'], 'wpmovielibrary'), 'value' => $field);
             } else {
                 unset($metas[$slug]);
             }
         }
     }
     $attributes = compact('id', 'overview', 'tagline', 'details', 'metas');
     $content = self::render_template('movies/headbox-allocine/tabs/details.php', $attributes, $require = 'always');
     return $content;
 }
 /**
  * Retrieve a list of Movies based on media
  * 
  * @since    2.1
  * 
  * @param    array    $args Arguments to retrieve movies
  * 
  * @return   array    Array of Post objects
  */
 public static function get_movies($args = null)
 {
     $defaults = array('number' => 5, 'offset' => 0, 'collection' => '', 'genre' => null, 'actor' => null, 'orderby' => 'date', 'order' => 'DESC', 'include' => array(), 'exclude' => array(), 'media' => null, 'status' => null, 'rating' => null, 'language' => null, 'subtitles' => null, 'format' => null, 'meta' => null, 'meta_value' => null, 'post_status' => 'publish');
     $r = wp_parse_args($args, $defaults);
     $meta_query = array();
     if (!empty($r['numberposts']) && empty($r['posts_per_page'])) {
         $r['posts_per_page'] = $r['numberposts'];
     }
     if (!empty($r['include'])) {
         $r['post__in'] = wp_parse_id_list($r['include']);
     }
     if (!empty($r['exclude'])) {
         $r['post__not_in'] = wp_parse_id_list($r['exclude']);
     }
     if (!is_null($r['meta_value'])) {
         $meta = array_keys(WPMOLY_Settings::get_supported_movie_meta());
         $details = array_keys(WPMOLY_Settings::get_supported_movie_details());
         foreach ($details as $detail) {
             if (!is_null($r[$detail])) {
                 $meta_query[] = array('key' => "_wpmoly_movie_{$detail}", 'value' => $r['meta_value'], 'compare' => 'LIKE');
             }
         }
         if (!is_null($r['meta']) && in_array($r['meta'], $meta)) {
             $meta_query[] = array('key' => "_wpmoly_movie_{$r['meta']}", 'value' => $r['meta_value'], 'compare' => 'LIKE');
         }
     }
     $r['posts_per_page'] = $r['number'];
     $r['post_type'] = 'movie';
     $r['meta_query'] = $meta_query;
     unset($r['media'], $r['status'], $r['rating'], $r['language'], $r['subtitle'], $r['format'], $r['meta'], $r['meta_value'], $r['number']);
     $_query = new WP_Query();
     $movies = $_query->query($r);
     return $movies;
 }
 /**
  * Modern headbox details tab content callback.
  * 
  * @since    2.0
  * 
  * @return   string    Tab content HTML markup
  */
 public function get_wpmoly_headbox_details_tab()
 {
     // TODO: better filtering/formatting
     $details = wpmoly_get_movie_details();
     $fields = wpmoly_o('sort-details');
     $default_fields = WPMOLY_Settings::get_supported_movie_details();
     if (empty($fields) || !isset($fields['used'])) {
         return null;
     }
     $fields = $fields['used'];
     if (isset($fields['placebo'])) {
         unset($fields['placebo']);
     }
     $post_id = get_the_ID();
     $items = array();
     foreach ($fields as $slug => $field) {
         if (isset($details[$slug])) {
             $detail = $details[$slug];
             if (!is_array($detail)) {
                 $detail = array($detail);
             }
             foreach ($detail as $i => $d) {
                 if ('' != $d) {
                     if (isset($default_fields[$slug]['options'])) {
                         $value = $default_fields[$slug]['options'][$d];
                     } else {
                         $value = $d;
                     }
                     if ('rating' == $slug) {
                         $d = apply_filters("wpmoly_movie_meta_link", array('key' => 'rating', 'value' => array_search($value, $default_fields[$slug]['options']), 'type' => 'detail', 'text' => $value));
                     } else {
                         $d = apply_filters("wpmoly_movie_meta_link", array('key' => $slug, 'value' => $value, 'meta' => 'detail', 'text' => $value));
                     }
                 }
                 $detail[$i] = apply_filters("wpmoly_format_movie_field", $d);
             }
             if (empty($detail)) {
                 $detail[] = apply_filters("wpmoly_format_movie_field", '');
             }
             $title = '';
             if (isset($default_fields[$slug])) {
                 $title = __($default_fields[$slug]['title'], 'wpmovielibrary');
             }
             $items[] = array('slug' => $slug, 'title' => $title, 'value' => $detail);
         }
     }
     $attributes = array('details' => $items);
     $content = WPMovieLibrary::render_template('movies/headbox/tabs/details.php', $attributes, $require = 'always');
     return $content;
 }
 /**
  * Set the uninstallation instructions
  *
  * @since    1.0
  */
 private static function _uninstall()
 {
     WPMOLY_Utils::uninstall();
     WPMOLY_Movies::uninstall();
     WPMOLY_Collections::uninstall();
     WPMOLY_Genres::uninstall();
     WPMOLY_Actors::uninstall();
     WPMOLY_Settings::uninstall();
 }
 public function available_movie_tags($field)
 {
     $field['options'] = WPMOLY_Settings::get_available_movie_tags();
     return $field;
 }
 /**
  * Format a Movie's . 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     $data detail value
  * @param    string     $format data format, raw or HTML
  * 
  * @return   string    Formatted output
  */
 public static function format_movie_subtitles($data, $format = 'html')
 {
     $format = 'raw' == $format ? 'raw' : 'html';
     if ('' == $data) {
         return $data;
     }
     if (wpmoly_o('details-icons') && 'html' == $format) {
         $view = 'shortcodes/detail-icon-title.php';
     } else {
         if ('html' == $format) {
             $view = 'shortcodes/detail.php';
         }
     }
     $title = array();
     $lang = WPMOLY_Settings::get_available_movie_language();
     if (!is_array($data)) {
         $data = array($data);
     }
     foreach ($data as $d) {
         if ('none' == $d) {
             $title = array(__('None', 'wpmovielibrary'));
             break;
         } elseif (isset($lang[$d])) {
             $title[] = __($lang[$d], 'wpmovielibrary');
         }
     }
     $data = WPMovieLibrary::render_template($view, array('detail' => 'subtitle', 'data' => 'subtitles', 'title' => implode(', ', $title)), $require = 'always');
     return $data;
 }
/**
 * General settings accessor
 *
 * @since    2.0
 * 
 * @param    string        $setting Requested setting slug
 * 
 * @return   mixed         Requested setting
 */
function wpmoly_o($search, $default = false)
{
    return WPMOLY_Settings::get($search, $default);
}
 /**
  * Filter an array of Shortcode attributes.
  * 
  * Shortcodes have limited attributes and possibly limited values
  * for some attributes. This method matches each submitted attr
  * to its limited values if available, and apply a filter to the
  * value before returning the array.
  * 
  * @since    1.1.0
  * 
  * @param    string    $shortcode Shortcode's ID
  * @param    array     $atts Attributes to filter
  * @param    array     $defaults Default attributes if needed
  * 
  * @return   array    Filtered Attributes
  */
 public static function filter_shortcode_atts($shortcode, $atts = array(), $defaults = array())
 {
     if (!is_array($atts)) {
         $atts = array($atts);
     }
     if (empty($defaults)) {
         $defaults = WPMOLY_Settings::get_available_shortcodes();
         $defaults = $defaults[$shortcode]['atts'];
     }
     $attributes = array();
     // Loop through the Shortcode's attributes
     foreach ($defaults as $slug => $default) {
         if (isset($atts[$slug])) {
             $attr = $atts[$slug];
             // Attribute is not null
             if (is_null($attr)) {
                 $attributes[$slug] = $default['default'];
             } else {
                 if (!is_null($attr)) {
                     $value = $attr;
                     // Attribute has limited values
                     if (!is_null($default['values'])) {
                         // Value should be boolean
                         if ('boolean' == $default['values'] && in_array(strtolower($attr), array('true', 'false', 'yes', 'no'))) {
                             $value = wpmoly_is_boolean($attr);
                         } else {
                             if (is_array($default['values'])) {
                                 // multiple values
                                 if (false !== strpos($attr, '|')) {
                                     $value = str_replace('actors', 'cast', $attr);
                                     $value = explode('|', $value);
                                     foreach ($value as $i => $v) {
                                         if (!in_array($v, $default['values'])) {
                                             unset($value[$i]);
                                         }
                                     }
                                     array_unique($value);
                                 } else {
                                     if (in_array(strtolower($attr), $default['values'])) {
                                         $value = $attr;
                                     }
                                 }
                             }
                         }
                     }
                     // Attribute has a valid filter
                     if (is_string($value) && function_exists($default['filter']) && is_callable($default['filter'])) {
                         $value = call_user_func($default['filter'], $value);
                     }
                     $attributes[$slug] = $value;
                 }
             }
         } else {
             $attributes[$slug] = $default['default'];
         }
     }
     return $attributes;
 }